var Speed=50;
var timer;
var myDiv = document.getElementById("myDiv");
var pic2= document.getElementById("pic2");
var pic0= document.getElementById("pic0");
pic2.innerHTML=document.getElementById("pic1").innerHTML;
pic0.innerHTML=document.getElementById("pic1").innerHTML;

function picMarqueeLeft(){
	/*document.getElementById("Label1").innerHTML = (pic2.offsetWidth-2);
	document.getElementById("Label2").innerHTML = myDiv.scrollLeft;*/
	var hidWidth = document.getElementById("hidWidth").value;
	if(hidWidth == 0){
		if(pic2.offsetWidth - myDiv.scrollLeft <= 0){
			myDiv.scrollLeft = 0;
			clearInterval(timer1);
		}
		else{
			myDiv.scrollLeft = myDiv.scrollLeft+36;
		}
	}
	else{
		if(myDiv.scrollLeft >= hidWidth){
			myDiv.scrollLeft = hidWidth;
			clearInterval(timer1);
		}else{
			myDiv.scrollLeft = myDiv.scrollLeft+36;
		}
	}
}

function picMarqueeRight(){
	/*document.getElementById("Label1").innerHTML = (pic0.offsetWidth-2);
	document.getElementById("Label2").innerHTML = (myDiv.scrollLeft);*/
	var hidWidth = document.getElementById("hidWidth").value;
	if(myDiv.scrollLeft > hidWidth){
			myDiv.scrollLeft -= 36;
		}else{
			myDiv.scrollLeft = hidWidth;
			clearInterval(timer2);
		}
}

function ProdVideoNext(){
	var i, TopDVDTable;
	i=getProdVideoCnt();
	
	var strScell = 540*i
	
	document.getElementById("hidWidth").value = strScell;
	timer1 = setInterval(picMarqueeLeft,Speed);
}

function ProdVideoPrev(){
	var i, TopDVDTable;
	i=getVideoCntPrev();
	
	//var strScell = ((pic0.offsetWidth-2)-(540*i));
	var strScell = 540*i;
	if((i+1)==document.all("hidVideoCnt").value)
		myDiv.scrollLeft = pic0.offsetWidth;
	
	document.getElementById("hidWidth").value = strScell;
	timer2 = setInterval(picMarqueeRight,Speed);
}

function getProdVideoCnt(){
	var	hidVideoCnt, hidVideo, intVideoArray=0;
	
	hidVideoCnt = document.all("hidVideoCnt").value;//總筆數
	hidVideoCnt=parseInt(hidVideoCnt-1);
	hidVideo = document.all("hidVideo").value;//目前停在那個array
	
	if((hidVideoCnt-1)>-1){
		if(hidVideo==hidVideoCnt)
			intVideoArray=0;
		else
			intVideoArray=parseInt(hidVideo) + 1;
	}
	document.all("hidVideo").value=intVideoArray;
	return intVideoArray;
}

function getVideoCntPrev(){
	var	hidVideoCnt, hidVideo, intVideoArray=0;
	
	hidVideoCnt = document.all("hidVideoCnt").value;//總筆數
	hidVideoCnt=parseInt(hidVideoCnt-1);
	hidVideo = document.all("hidVideo").value;//目前停在那個array
	
	if(hidVideo==0){
		intVideoArray=hidVideoCnt;
	}
	else{
			intVideoArray=parseInt(hidVideo) - 1;
	}
	document.all("hidVideo").value=intVideoArray;
	return intVideoArray;
}