function startmarquee(tmplh,speed,delay) 
{
	var p=false;
	var t;
	var intCount = 0;
	var tmplh = 90;
	var o=document.getElementById(rollElementId);
	o.innerHTML+=o.innerHTML;
	o.style.marginTop=0;
/*	鼠标经过时暂停
	o.onmouseover=function(){p=true;}
	o.onmouseout=function(){p=false;}*/
	
	
	function start()
	{
		t=setInterval(scrolling,speed);
		if(!p) o.style.marginTop=parseInt(o.style.marginTop)-1+"px";
		
		chageImg();//每次开始滚动时更换图片
	}
	
	function scrolling()
	{
		if(parseInt(o.style.marginTop)%tmplh!=0)
		{
			o.style.marginTop=parseInt(o.style.marginTop)-1+"px";
			if(Math.abs(parseInt(o.style.marginTop))>=o.scrollHeight/2) o.style.marginTop=0;
		}
		else
		{
			clearInterval(t);
			intCount++;
			if(intCount == 0)
				tmplh = 90;
			else if(intCount == 1)
				tmplh = 80;
			else if(intCount == 2)
				tmplh = 76;
			else
				tmplh = lh;
			//document.getElementById('lhSpan').innerHTML = tmplh + "|" + lh + "|" + intCount;
			setTimeout(start,delay);
		}
	}
	
	setTimeout(start,delay);
}
	
function chageImg()
{
	if(intImgIndex + 1 >= imgArray.length)
		intImgIndex = -1;
	
	var targetImg = document.getElementById(rollTargetId);
	var viewProduct = document.getElementById(rollViewId);
	var numImg = document.getElementById(rollNumID);
	targetImg.src = imgArray[++intImgIndex];
	viewProduct.href = linkArray[intImgIndex];
	numImg.src = "images/number/" + (intImgIndex + 1).toString() + ".gif";
	
	if(targetImg.height > 130)
		targetImg.height = 130;
	else
		if(targetImg.width > 178)
			targetImg.width = 178;			
}

function goToNextImg(tmplh)
{
	var o=document.getElementById(rollElementId);
	o.style.marginTop=parseInt(o.style.marginTop)-1-tmplh +"px";
	
	chageImg();
}

function goToPrevImg(tmplh)
{	
	var o=document.getElementById(rollElementId);
	
	if(intImgIndex == 0){
		intImgIndex = imgArray.length - 2;
		o.style.marginTop = -1-tmplh +"px";
	}
	else{
		intImgIndex = intImgIndex - 2;
	}
	
	o.style.marginTop=parseInt(o.style.marginTop)-1+tmplh +"px";
	
	chageImg();	
}

startmarquee(lh,60,0);