var speed=1;
var scrollwidth = 2000;
var adswidth = 2000;
var cwidth = 150;

var p1,p2;



function Marquee(){

	var p1x = parseInt(p1.style.left);
	var p2x = parseInt(p2.style.left);
	
	
	p1.style.left = (p1x-1) + "px";
	p2.style.left = (p2x-1) + "px";	
	
	

	if(p2x<=0 && p1x<p2x)
	{
		p1.style.left = p2x + adswidth + "px";	
	}
	if(p1x<=0 && p2x<p1x)
	{
		p2.style.left = p1x + adswidth + "px";
	}

}

function toRight(){

	var p1x = parseInt(p1.style.left);
	var p2x = parseInt(p2.style.left);
	
	
	p1.style.left = (p1x+cwidth) + "px";
	p2.style.left = (p2x+cwidth) + "px";
	
	if(p1x+adswidth>=scrollwidth && p2x>p1x)
	{
		p2.style.left = p1x - adswidth + cwidth + "px";	

	}
	if(p2x+adswidth>=scrollwidth && p1x>p2x)
	{
		p1.style.left = p2x - adswidth + cwidth + "px";
	}
	

}

function toLeft(){

	var p1x = parseInt(p1.style.left);
	var p2x = parseInt(p2.style.left);
	
	
	p1.style.left = (p1x-cwidth) + "px";
	p2.style.left = (p2x-cwidth) + "px";	
	
	if(p2x<=0 && p1x<p2x)
	{
		p1.style.left = p2x + adswidth - cwidth + "px";	
	}
	if(p1x<=0 && p2x<p1x)
	{
		p2.style.left = p1x + adswidth - cwidth + "px";
	}


}


function init(){

	p1 = document.getElementById("pane1");
	p1.style.width = adswidth+"px";
	p1.style.left = "0px";

	p2 = document.getElementById("pane2");	
	p2.style.width = p1.style.width;
	p2.style.left = p1.style.width;
	p2.innerHTML=p1.innerHTML;
	
	var MyMar=setInterval(Marquee,speed);
	p1.onmouseover=function() {clearInterval(MyMar);};
	p1.onmouseout=function() {MyMar=setInterval(Marquee,speed);};
	p2.onmouseover=function() {clearInterval(MyMar);};
	p2.onmouseout=function() {MyMar=setInterval(Marquee,speed);};
	clearInterval(MyMar);
}
