
function tickerObject( contentID, dataUrl ) {
	this.contentID  = contentID;
	this.dataUrl    = dataUrl;
	this.tdura      = 5000;
	this.tspeed     = 500;
	this.theight    = 50;
	this.twidth     = 0;
	this.counter    = 0;
	this.messages   = [];
	this.mouseOver  = 0;
	this.contentdiv = document.getElementById( this.contentID );
	this.slideobj   = new dynObj( this.contentID, 0, 0 );
	this.slideobj.show();
	this.ajaxobj = createAjaxObj();
	this.getData();
}
tickerObject.prototype.getData = function() {
	if ( this.ajaxobj ) {
		var ticker = this;
		var url = this.dataUrl + "?bustcache=" + new Date().getTime();
		this.ajaxobj.onreadystatechange = function() { ticker.initialize(); }
		this.ajaxobj.open( 'GET', url, true );
		this.ajaxobj.send( null );
	}
}
tickerObject.prototype.initialize = function() { 
	if ( this.ajaxobj.readyState == 4 ) {
		if ( this.ajaxobj.status == 200 || window.location.href.indexOf("http") == -1 ) {
			var ticker = this;
			try { eval( "this.messages = "+ this.ajaxobj.responseText +";" ); }
			catch (e) { this.messages = null; }
			if ( window.attachEvent ) { window.attachEvent( "onunload", function() { ticker.contentdiv = ticker.ajaxobj = null; } ); }
			this.contentdiv.onmouseover = function() { ticker.mouseOver=1; }
			this.contentdiv.onmouseout = function() { ticker.mouseOver=0; }
			this.rotate();
		}
	}
}
tickerObject.prototype.rotate = function() {
	if ( this.messages ) {
		var ticker = this;
		if ( this.mouseOver == 1 ) {
			this.t3 = setTimeout( function() { ticker.rotate() }, 100 );
		} else {
			ticker.slideobj.slideTo( this.twidth, this.theight, ticker.tspeed, -1 );
			this.t1 = setTimeout( function(){ ticker.setcontent('t1') }, ticker.tspeed );
			this.t2 = setTimeout( function(){ ticker.slideobj.slideTo(0, 0, ticker.tspeed, -1); clearTimeout(this.t2); }, ticker.tspeed+50 )
			if ( this.messages.length>1 ) {
				this.t3 = setTimeout( function(){ ticker.rotate() }, (ticker.tspeed*2)+100+ticker.tdura );
			}
		}
	}
}
tickerObject.prototype.setcontent = function( t ) {
	var ticker = this;
	for ( element in this.messages[ this.counter ] ) {
		try { document.getElementById( element ).innerHTML = this.messages[ this.counter ][ element ]; }
		catch (e) { }
	}
	this.counter = ( this.counter < this.messages.length - 1 ) ? this.counter + 1 : 0
	ticker.slideobj.shiftTo( this.twidth*-1, this.theight*-1 );
	clearTimeout( this[t] );
}
tickerObject.prototype.hold = function() {
	clearTimeout( this.t3 );
}


function createAjaxObj() {
	request = ( window.XMLHttpRequest ) ? new XMLHttpRequest() : new ActiveXObject( "MSXML2.XMLHTTP" );
	return request;
}


dynObj.holder = {}; 
function dynObj(id,x,y,w,h) {
  var el = dynObj.getElemRef(id);
  if (!el) return;  this.id = id; 
  dynObj.holder[this.id] = this; this.animString = "dynObj.holder." + this.id;
  var px = window.opera? 0: "px";
	this.x = x || 0;	if (x) el.style.left = this.x + px;
	this.y = y || 0;	if (y) el.style.top = this.y + px;
	this.w = w || el.offsetWidth || 0;	this.h = h || el.offsetHeight || 0;
	if (w) el.style.width = w + px; if (h) el.style.height = h + px;
}
dynObj.prototype.slideTo = function (destX,destY,slideDur,acc,endFn) {
  if (!document.getElementById) return;
  this.slideDur = slideDur || .0001; var acc = -acc || 0;
  if (endFn) this.onSlideEnd = endFn;
 	if (destX == null) this.destX = this.x;	else this.destX = destX;
  if (destY == null) this.destY = this.y; else this.destY = destY;
  this.startX = this.x; this.startY = this.y;
	this.st = new Date().getTime();
  this.xc1 = this.x + ( (1+acc) * (this.destX-this.x)/3 );
	this.xc2 = this.x + ( (2+acc) * (this.destX-this.x)/3 );
  this.yc1 = this.y + ( (1+acc) * (this.destY-this.y)/3 );
	this.yc2 = this.y + ( (2+acc) * (this.destY-this.y)/3 );
	this.sliding = true;
  this.onSlideStart();
  dw_Animation.add(this.animString + ".doSlide()");
}
dynObj.prototype.shiftTo = function(x,y) {
  var el = this.el? this.el: dynObj.getElemRef(this.id)? dynObj.getElemRef(this.id): null;
  if (el) {
    if (x != null) el.style.left = (this.x = x) + "px";
    if (y != null) el.style.top = (this.y = y) + "px";
  }
}
dynObj.prototype.show = function() { 
  var el = this.el? this.el: dynObj.getElemRef(this.id)? dynObj.getElemRef(this.id): null;
  if (el) el.style.visibility = "visible"; 
}
dynObj.prototype.hide = function() { 
  var el = this.el? this.el: dynObj.getElemRef(this.id)? dynObj.getElemRef(this.id): null;
  if (el) el.style.visibility = "hidden"; 
}
dynObj.prototype.doSlide = function() {
	if (!this.sliding) return;	
	var elapsed = new Date().getTime() - this.st;
	if (elapsed < this.slideDur) {
    var x = dw_Bezier.getValue(elapsed/this.slideDur, this.startX, this.destX, this.xc1, this.xc2);
    var y = dw_Bezier.getValue(elapsed/this.slideDur, this.startY, this.destY, this.yc1, this.yc2);
		this.shiftTo( Math.round(x) ,Math.round(y) );
		this.onSlide();
	} else {
    dw_Animation.remove(this.animString + ".doSlide()");
		this.shiftTo(this.destX,this.destY);
		this.onSlide();
		this.sliding = false;
		this.onSlideEnd();
	}
}
dynObj.prototype.onSlideStart = function () {}
dynObj.prototype.onSlide = function () {}
dynObj.prototype.onSlideEnd = function () { if (this.el) this.el = null; }
dynObj.getElemRef = function(id) { 
  var el = document.getElementById? document.getElementById(id): null;
  return el;
} 
dw_Animation = {
  instances: [],
  add: function(fp) {
    this.instances[this.instances.length] = fp;
  	if (this.instances.length == 1) this.timerID = window.setInterval("dw_Animation.control()", 10);
  },
  remove: function(fp) {
    for (var i = 0; this.instances[i]; i++) {
  		if (fp == this.instances[i]) {
  			this.instances = this.instances.slice(0,i).concat( this.instances.slice(i+1) );
  			break;
  		}
  	}
  	if (this.instances.length == 0) {
  		window.clearInterval(this.timerID);	this.timerID = null;
  	}
  },
  control: function() {
    for (var i = 0; this.instances[i]; i++) {
  		if (typeof this.instances[i] == "function" ) this.instances[i]();
      else eval(this.instances[i]);
    }
  }
}
var dw_Bezier = {
  B1: function (t) { return t*t*t },
  B2: function (t) { return 3*t*t*(1-t) },
  B3: function (t) { return 3*t*(1-t)*(1-t) },
  B4: function (t) { return (1-t)*(1-t)*(1-t) },
  getValue: function (percent,startVal,endVal,c1,c2) {
    return endVal * this.B1(percent) + c2 * this.B2(percent) + c1 * this.B3(percent) + startVal * this.B4(percent);
  }
}