/*
@Author Remigijus Kiminas
@License GPL
@Home Page http://remdex.info
*/

var marqueRunner={

//Changable elements
stopOnMouseOver: true, 	//Stop movement on mouse over
marqueID: 'marqueBody', //Element id
marqueDirection:1,		//0 From left to right, 1 From right to left
marqueWidth:582,		//Marque width

// Change stepSize and timeout for your need
stepSize:1,				//Step size in pixels
marquetimeout: 40,		//Marque timeout speed
timeoutBefoveMove:500,	//Miliseconds before continue animation on mouse out


//Do not change these
marqueElement: null,
ismouseOver: false,
marqueBodyWidth:null,
running: false,
leftMargin: 0, 
canRestoreMovement:true,


// From left to right
moveMarqueRight:function(){	
	
	if (this.ismouseOver == false)
	{
		if (this.running == false)	
		{
			setInterval("marqueRunner.moveMarqueRight()",marqueRunner.marquetimeout);
			this.running = true;
		}
		else
		{
			
			if (this.leftMargin >= this.marqueWidth)
			{	
				this.marqueElement.style.left=-this.marqueBodyWidth+"px";				
				this.leftMargin = -this.marqueBodyWidth;
			}
			this.leftMargin +=this.stepSize; 
			this.marqueElement.style.left=this.leftMargin+"px";	
		}	
	}	
},

// From right to left
moveMarqueLeft:function(){	
	
	if (this.ismouseOver == false)
	{
		if (this.running == false)	
		{
			setInterval("marqueRunner.moveMarqueLeft()",marqueRunner.marquetimeout);
			this.running = true;
		}
		else
		{		
				
			if (this.leftMargin <= -this.marqueBodyWidth)
			{	
				this.marqueElement.style.left=this.marqueWidth+"px";				
				this.leftMargin = this.marqueWidth;
			}
			
			this.leftMargin -=this.stepSize; 
			this.marqueElement.style.left=this.leftMargin+"px";	
		}	
	}	
},

restoreMove:function(){	
	
	if (this.canRestoreMovement == true) marqueRunner.ismouseOver=false;			
},


init:function(){ //Initialize marque

	this.marqueElement=document.getElementById(this.marqueID);	
	this.marqueBodyWidth=this.marqueElement.offsetWidth;	
	
	
	if (this.marqueDirection == 0)	
	{	
		this.leftMargin=-this.marqueBodyWidth;
		this.marqueElement.style.left=this.leftMargin+"px";
		this.moveMarqueRight();
	}
	else
	{
		this.leftMargin=this.marqueWidth;		
		this.marqueElement.style.left=this.leftMargin+"px";		
		this.moveMarqueLeft();
	}
	
	if (this.stopOnMouseOver == true)
	{
		this.marqueElement.onmouseover=function(){marqueRunner.ismouseOver=true;marqueRunner.canRestoreMovement=false;};
		this.marqueElement.onmouseout=function(){marqueRunner.canRestoreMovement=true;setTimeout("marqueRunner.restoreMove()",marqueRunner.timeoutBefoveMove)};
	}

} //END init() function

}


