// JavaScript Document
var iStartLeft = 0;
var iEverySub = 10;
var iPicWidth = 130;
var iPicCount = 0;
var toRollAction;
var iRollSpeed = 50;
var iStartPic = 0;
var iEndPic = 3;
var spicurl;
var spicWidth;
var spicHeight;
var iImageSpeed = 5000;
var iCurImg = 0;
var autoRollImg;
var albumhost;
var albumname;
function albumPlay(){
	//if (autoRollImg == null || autoRollImg == 'undefined'){
		iImageSpeed = 5000;
		autoRollImg = setInterval("autoRollImage()", iImageSpeed);
		$('btn_start').style.display = 'none';
		$('btn_pause').style.display = 'inline';
	//}
}
function albumPause(){
	if (autoRollImg != null && autoRollImg != 'undefined'){
		clearInterval(autoRollImg);
		$('btn_start').style.display = 'inline';
		$('btn_pause').style.display = 'none';
	}
}
function albumFaster(){
	if (iImageSpeed > 1000) iImageSpeed -= 1000;
	if (autoRollImg != null && autoRollImg != 'undefined'){
		clearInterval(autoRollImg);
		autoRollImg = setInterval("autoRollImage()", iImageSpeed);
	}
}
function albumLower(){
	if (iImageSpeed < 9000) iImageSpeed += 1000;
	if (autoRollImg != null && autoRollImg != 'undefined'){
		clearInterval(autoRollImg);
		autoRollImg = setInterval("autoRollImage()", iImageSpeed);
	}
}
function autoRollImage(){
	if (iCurImg > iPicCount + 3)
		iCurImg = iCurImg - iPicCount;
	else
		iCurImg++;
	document.getElementsByName('apage')[iCurImg].click();
}
function openpic(){
	if(window.navigator.appName=="Microsoft Internet Explorer"){
		window.open(spicurl, 'newwindow', 'height='+spicHeight+',width='+spicWidth+',scrollbars');
	}
	else if(window.navigator.appName=="Netscape" || window.navigator.appName=="Opera"){
		//window.open(url, 'newwindow', "left=0,top=0,height="+screenY+",width="+screenX+",menubar=no,location=no,resizable=yes,scrollbars="+condScroll+",status=no");
		window.open(spicurl, 'newwindow', 'height='+spicHeight+',width='+spicWidth+',scrollbars');
	}
}
function clickroll(picid, picurl, picwidth, picheight){
	//spicurl = picurl;
	//spicWidth = picwidth + 38;
	//spicHeight = picheight + 32;
	iCurImg = picid;
	if (iCurImg < iPicCount)
		window.location.hash = iCurImg + 1;
	else
		window.location.hash = iCurImg - iPicCount + 1;
	if (picid - iStartPic <= 0)
		roll2right();
	if (iEndPic - picid <= 0)
		roll2left();
}
function roll2left(){
	clearInterval(toRollAction);
	if (iStartLeft == iPicCount * iPicWidth){
		iStartLeft = 0;
		iStartPic = 0;
		iEndPic = 3;
	}
	iStartPic++;
	iEndPic++;
	toRollAction = setInterval("doRoll_left()", iRollSpeed);
}
function roll2right(){
	clearInterval(toRollAction);
	if (iStartLeft == 0){
		iStartLeft = iPicCount * iPicWidth;
		iStartPic = iPicCount;
		iEndPic = iPicCount + 3;
	}
	iStartPic--;
	iEndPic--;
	toRollAction = setInterval("doRoll_right()", iRollSpeed);
}
function doRoll_left(){
	if (iPicWidth - (iStartLeft % iPicWidth) < 6)
		iStartLeft = iStartLeft + 1;
	else if (iPicWidth - (iStartLeft % iPicWidth) < 18)
		iStartLeft = iStartLeft + 6;
	else
		iStartLeft = iStartLeft + iEverySub;
	document.getElementById('rollalbumpage').firstChild.style.marginLeft=(0-iStartLeft)+'px';
	if (iStartLeft % iPicWidth == 0){
		clearInterval(toRollAction);
	}
}
function doRoll_right(){
	if (iStartLeft % iPicWidth < 6)
		iStartLeft = iStartLeft - 1;
	else if (iStartLeft % iPicWidth < 18)
		iStartLeft = iStartLeft - 6;
	else
		iStartLeft = iStartLeft - iEverySub;
	document.getElementById('rollalbumpage').firstChild.style.marginLeft=(0-iStartLeft)+'px';
	if (iStartLeft % iPicWidth == 0){
		clearInterval(toRollAction);
	}
}
