// JavaScript Document

speed=25;
Count=5;
PCount=1;
Moves=200;
Pc=0;
Pnc=-936;
Pnm=100;
PnmN=1;

function Topmovestart(){
	Count=5;
	PCount=1;
	Moves=200;
	Pc=0;
	Pnc=-936;
	Pnm=100;
	PnmN=1;
	document.getElementById("Replay").innerHTML='';
	document.getElementById("photo_A").style.backgroundPosition="0px 0px"
	document.getElementById("photo_B").style.backgroundPosition="0px 0px";
	setTimeout('Topmove()',speed);
}

function Topmove(){
	PCount_A=PCount;
	if(PCount==4){ PCount_B=1; }else{ PCount_B=PCount+1; }
	if(Count>0){
		if(Count==1){
			document.getElementById("photo_A").style.backgroundImage="url(movephoto/1.jpg)";
			if(Moves>0){
				if(Moves>40){
					document.getElementById("photo_B").style.backgroundImage="url(movephoto/1.jpg)";
					document.getElementById("photo_B").style.backgroundPosition="0px "+Pc+"px";
					document.getElementById("photo_B").style.filter="Alpha(Opacity=100)";
					document.getElementById("photo_B").style.MozOpacity="1.0";
					document.getElementById("photo_B").style.opacity="1.0";
					Pc--;
				}else{
					userAgent = window.navigator.userAgent.toLowerCase();
					if (userAgent.indexOf("msie") > -1) {
						if(PnmN>99){
							PnmN=100;
						}
						document.getElementById("photo_B").style.backgroundImage="url(movephoto/txt.jpg)";
						document.getElementById("photo_B").style.backgroundPosition="0px 0px";
						document.getElementById("photo_B").style.filter="Alpha(Opacity="+PnmN+")";
						PnmN=PnmN+3;
					}else{
						document.getElementById("photo_B").style.backgroundImage="url(movephoto/txt.png)";
						document.getElementById("photo_B").style.backgroundPosition=Pnc+"px 0px";
						document.getElementById("photo_B").style.backgroundRepeat='no-repeat';
						document.getElementById("photo_B").style.filter="Alpha(Opacity=100)";
						document.getElementById("photo_B").style.MozOpacity="1.0";
						document.getElementById("photo_B").style.opacity="1.0";
						Pnc=Pnc+24;
					}
				}
				document.getElementById("photo_A").style.backgroundPosition="0px "+Pc+"px";
				document.getElementById("photo_A").style.filter="Alpha(Opacity=100)";
				document.getElementById("photo_A").style.MozOpacity="1.0";
				document.getElementById("photo_A").style.opacity="1.0";
				Moves--;
			}else{
				document.getElementById("Replay").innerHTML='≪ Replay';
				Count--;
				Moves=200;
				if(PCount>3){ PCount=1; }else{ PCount++ }
				Pc=0;
				Pnm=100;
			}
		}else{
			document.getElementById("photo_B").style.backgroundImage="url(movephoto/"+PCount_A+".jpg)";
			if(Moves>0){
				document.getElementById("photo_B").style.backgroundPosition="0px "+Pc+"px";
				if(Moves<101){
					if(Pnm>0){ Pnm--; if(Pnm>9){ Pnms=Pnm; }else{ Pnms="0"+Pnm; } }else{ Pnm=0; }
					document.getElementById("photo_B").style.filter="Alpha(Opacity="+Pnm+")";
					document.getElementById("photo_B").style.MozOpacity="0."+Pnms;
					document.getElementById("photo_B").style.opacity="0."+Pnms;
				}else{
					document.getElementById("photo_B").style.filter="Alpha(Opacity=100)";
					document.getElementById("photo_B").style.MozOpacity="1.0";
					document.getElementById("photo_B").style.opacity="1.0";		
				}
				Moves--;
				Pc--;
				document.getElementById("photo_A").style.backgroundImage="url(movephoto/"+PCount_B+".jpg)";
			}else{
				Count--;
				Moves=200;
				if(PCount>3){ PCount=1; }else{ PCount++ }
				Pc=0;
				Pnm=100;
			}
		}
		setTimeout('Topmove()',speed);
	}else{
		clearTimeout('Topmove()');
	}
}
