﻿var sh;
marqueesWidth=946;
preLeft=0; 
currentLeft=0; 
stopscroll=false; 
getlimit=0;
preTop=0; 
currentTop=0;

function scrollLeft()
{
	if(stopscroll==true) return;
	preLeft=marquees.scrollLeft;
	
	for(var i =0 ; i<10*96; i++){
	    marquees.scrollLeft += 10;
	}
	
	if(preLeft==marquees.scrollLeft)
	{
		//marquees.scrollLeft=templayer.offsetWidth-marqueesWidth+1;
	}
}

function scrollRight()
{
	if(stopscroll==true) return;

	preLeft=marquees.scrollLeft;
	for(var i =0 ; i <10*96; i++){
	    marquees.scrollLeft -=10;
	}
	if(preLeft==marquees.scrollLeft)
	{
		if(!getlimit)
		{
			marquees.scrollLeft=templayer.offsetWidth*2;
			getlimit=marquees.scrollLeft;
		}
		marquees.scrollLeft-=1;
	}
}

function Left()
{
	stopscroll = false;
	scrollLeft();
 	//sh = setInterval("scrollLeft()",1500); //
}

function Right()
{
	stopscroll = false;
	scrollRight();
	//sh = setInterval("scrollRight()",1500);//scrollRight();
}

function StopScroll()
{
	stopscroll = true;
	clearInterval( sh );
}

(function init() {
    if (typeof marquees == "undefined") {
        marquees = $("#marquees")[0];
    }

    with (marquees) {
        style.height = 200;
        style.width = marqueesWidth;
        /*firefox 不支持 overflowX,改为overflow*/
        style.overflow = "hidden";
        style.overflowX = "hidden";
        style.overflowY = "visible";
        style.align = "center";
        noWrap = true;
    }
})();
