﻿
function Scroller(object, objectWrapper, direction, tempo)
{
	var thisObj 		= this;
	this.xCoordinate 	= 0;
	this.yCoordinate 	= 0;
	this.offset			= 0;
	this.tempo			= tempo;
	this.strDirection	= direction;
	this.scrollerStatus	= true;
	this.htmlObj		= object;
	this.htmlObjWrapper	= objectWrapper;
	this.interval;
	
	this.htmlObj.style.position = "relative";
	this.htmlObjWrapper.style.position = "relative"; // needed to fix an overflow bug in IE7
	this.htmlObjWrapper.style.overflow = "hidden";

	this.move = function()
	{
		if(this.scrollerStatus)
		{
				// moving right
					this.xCoordinate++;
					this.htmlObj.style.left = this.xCoordinate+"px";

					if (this.xCoordinate > 860){
						this.xCoordinate = -this.offset;}
		}
	}
	this.start = function()
	{
		thisObj.offset = thisObj.htmlObj.offsetWidth; // need to check this line code, maybe it's not "width"
		this.xCoordinate=-this.offset;
    	thisObj.interval = setInterval(function() { thisObj.move(); }, thisObj.tempo);
	}
}
