ApMarquee = function(name, idPrefix, totalItems, speed, width, delay, direction)
{
	this._name = name;
	this._idPrefix = idPrefix;
	this._totalItems = totalItems;
	this._speed = speed;
	this._delay = delay;
	this._direction = direction;
	
	this._oVisDiv = new Array(this._totalItems);
	this._ImageWidth = this._totalItems - 1;
	this._iSeq = this._totalItems - 1;
	
	this._MediaData = new Array();
	
	for (var i = 0; i < this._totalItems; ++i)
	{
		this._MediaData[i] = { Width: width, Height: 0 }
	}
};

ApMarquee.prototype = {
	 _name: ''
	,_idPrefix: null
	,_totalItems: null
	,_speed: null
	,_delay: null
	,_iLeft: 0
	,_iLeader: 0
	,_oVisDiv: new Array()
	,_TimeOutID: null
	,_started: false
	,_ImageWidth: 0
	,_iSeq: 0
	,_MediaData: new Array()
	,startScroll: function(initialStart)
	{
		if (initialStart || this._started)
		{
			this._started = true;
			this._TimeOutID = window.setInterval(this._name + '.doIt();', this._speed);
		}
	}
	,stopScroll: function()
	{
		clearInterval(this._TimeOutID);
	}
	,loadVisibleDiv: function()
	{
		for (var iCnt=0; iCnt<=this._ImageWidth; iCnt++)
		{
			eval("this._oVisDiv[" + iCnt + "] = document.getElementById('" + this._idPrefix + iCnt + "')")
		}
	}
	,doIt: function()
	{
		var iLa;
		var iLb;
		var iLc;
		var iLd;
		var iAddIncr = 0;
		var iLocal = this._iLeader;
		var i;
		
		for (var iCnt=0; iCnt<=this._ImageWidth; iCnt++)
		{
			eval("this._oVisDiv[" + iLocal + "].style." + this._direction + "='" + (this._iLeft + iAddIncr)+"px'");
			iAddIncr += this._MediaData[iLocal].Width + 1; // + 1 is the spacer
			iLocal+=1;
			if (iLocal>this._ImageWidth)
			{
				iLocal=0;
			}
		}
		
		if (this._iLeft<=-(this._MediaData[this._iLeader].Width+1))
		{  
			this._iLeft=0;
			this._iSeq+=1;
			
			if (this._iSeq > this._ImageWidth)
			{
				this._iSeq=0;
			}
			
			this._iLeader+=1;
			
			if (this._iLeader > this._ImageWidth)
			{
				this._iLeader=0;
			}
		}
	
		this._iLeft-=1;
	}
	,run: function()
	{
		this.loadVisibleDiv();
		this.doIt();
		if (this._delay > 0)
		{
			setTimeout(this._name + '.startScroll(true);', this._delay);
		}
	}
};
