
var intActPhoto=null;
var loadPhoto='';
var timerID=null;
var speed;
window.onload=init;

function getPhoto(strMoveType){

	var a=document.frmPersonalMain;
	var pgnm=$F('PageName');

	if(intActPhoto==null)
		intActPhoto=a.txtPhotoRange.value;

	switch(strMoveType){
		case 'First':
			intActPhoto=a.txtPhotoRange.getAttribute('FirstPhoto');
			break;
		case 'Last':
			intActPhoto=a.txtPhotoRange.getAttribute('LastPhoto');
			break;
		case 'Prev':
			intActPhoto--;
			if(intActPhoto<a.txtPhotoRange.getAttribute('FirstPhoto'))
				intActPhoto=a.txtPhotoRange.getAttribute('LastPhoto');
			break;
		case 'Next':
			intActPhoto++;
			if(intActPhoto>a.txtPhotoRange.getAttribute('LastPhoto'))
				intActPhoto=a.txtPhotoRange.getAttribute('FirstPhoto');
			break;
	}

	$('spActiveNum').innerHTML=intActPhoto;
	a.op.value='';

	if(parseInt(intActPhoto)<parseInt(a.txtPhotoRange.getAttribute('BookFirstPhoto')) || parseInt(intActPhoto)>parseInt(a.txtPhotoRange.getAttribute('BookLastPhoto'))){
		a.strPhotoPoint.value=intActPhoto;
		a.action=pgnm;
		a.submit();
	}
	else{
		var pbl=document.getElementsByName('PhtotBookList'+intActPhoto)[0];
		$('tdPhotoText').innerHTML=pbl.getAttribute('PhotoText');
		$("ifrmPhoto").src='photo_detail_pop_content.asp?strPID='+$F("strPID")+'&strMno='+$F("strMno")+'&strPhotoPoint=' + intActPhoto;
	}
}

function NextPhoto(){
	var a=document.frmPersonalMain;
	if(loadPhoto=='OK'){
		getPhoto('Next');
		if(intActPhoto>=a.txtPhotoRange.getAttribute('LastPhoto'))
			intActPhoto=0;//a.txtPhotoRange.FirstPhoto;
		loadPhoto='';
	}
}

function changeSpeed(objX){
	speed=objX.options[objX.selectedIndex].value*1000;
	clearInterval(timerID);
	timerID=null;
	playPhoto();
}

function playPhoto(){

	var a=document.frmPersonalMain;

	if(timerID==null){
		loadPhoto='OK';
		timerID=setInterval("NextPhoto()",speed); //1秒
		$('playButton').innerHTML='停止播放';
		a.strAutoPlay.value=1;
	}
	else{
		loadPhoto='';
		clearInterval(timerID);
		timerID=null;
		$('playButton').innerHTML='連續播放';
		a.strAutoPlay.value='';
	}
}

function giftCount(strID){
	var pgnm=$F('PageName');
	var a=document.frmPersonalMain;
	a.op.value='Gift';
	a.strPID.value=strID;
	a.action=pgnm;
	a.submit();
}

function PageGo(strPageNo){
	var pgnm=$F('PageName');
	var a=document.frmPersonalMain;
	a.op.value='';
	a.strPage.value=strPageNo;
	a.action=pgnm;
	a.submit();
}

function PhotoInfo(strMno,strID){
	var a=document.frmPersonalMain;
	a.op.value='G';
	a.strMno.value=strMno;
	a.strPID.value=strID;
	a.action='Photo_detail.asp';
	a.submit();
}

function PhotobookChange(){
	var pgnm=$F('PageName');
	var a=document.frmPersonalMain;
	a.op.value='';
	a.strPID.value=a.sltPBSno.options[a.sltPBSno.selectedIndex].value;
	a.strPage.value='';
	a.action=pgnm;
	a.submit();
}

function showPhoto(mintActPhoto,strPhotoText){
	var a=document.frmPersonalMain;
	if(intActPhoto==null)
		intActPhoto=a.txtPhotoRange.value;
	$('spActiveNum').innerHTML=mintActPhoto;
	a.op.value='';
	$('tdPhotoText').innerHTML=strPhotoText;
	intActPhoto=mintActPhoto;
	$('ifrmPhoto').src='photo_detail_pop_content.asp?strPID='+$F("strPID")+'&strMno='+$F("strMno")+'&strPhotoPoint=' + intActPhoto;
}

function init(){
	var timerID=null;
	speed=parseInt($F("sltSpeed"))*1000;
	document.title=$F("BookName")+document.title;
	self.focus();
	if($F("AutoPlay")=="1") playPhoto();
	if($F("sysMsg")!="") alert($F("sysMsg"));
}

