function showsplash(){
 moveidto( loaderID, -1000, wy);
 moveidto( loaderdotsID, -1000, wy);
 moveidto( getid("loaderbox"), -1000, wy);
  changeOpac(50, getid("pH")) ;
 moveidto( getid("menu"), wx, wy);
 }
 function checkPage(page){
 if (!getid("play_img")) return;
 menuID.style.left="0px";
 getid("gAD").style.display="block";
 getid("play_img").style.display="block";
 menuID.style.display="block";
 getid("BoxAlert").style.display="none";
 getid("BoxAlertText").style.display="none";
 
 if (page.id=="Choose") 
   {getid("play_img").style.display="none";
    menuID.style.left="30px";
	choosedStep=0;
	getid("Step1").style.display="block";
   getid("Step2").style.display="none";
   getid("cP").style.display="none";
   getid("cO").style.display="none";
 
   }
 
 if (page.id=="Play") {
  menuID.style.display="none";
  
     getid("readytext").innerHTML="READY!";
  isgameOver=false;
 getid("nosO").style.width="0px";getid("nosP").style.width="0px";
  changeOpac(100, getid("readytext")) ;
  pScore=20;oScore=20;
  getid("score").innerHTML="SCORE: 0";
  readytexttimeout=200;
  oHit=0;
  pHit=0;
  oStatus=0;
  pStatus=0;
  gametime=0;

   }
 if (page.id=="Interstitial") {
 getid("gAD").style.display="none";
  skiptimeout=5;   setTimeout(skip,1000);
    }
 }
 function skip(){
if(currentPage!=getid("Interstitial")) return;
  if (skiptimeout==0) {
  showPage(getid("Choose")); return;}
  skiptimeout--;
  getid("skiptext").innerHTML="Game will start in "+skiptimeout+" seconds.";
  setTimeout(skip,1000); 
 }
 function chooseP(opt)
 {
 if (choosedStep==0) {
  choosedStep=1;
  getid("Step1").style.display="none";
  getid("Step2").style.display="block";
  step2blinkcount=1;
  blinkStep2();
  getid("cP").style.display="block";
  
  choosedP=opt;
  if (opt==1) moveidto(getid("cP"),125,210);  if (opt==2) moveidto(getid("cP"),115,110);  if (opt==3) moveidto(getid("cP"),245,210);  if (opt==4) moveidto(getid("cP"),260,110);
   }
   if (choosedStep==1) {
   if (opt==choosedP) return;
  choosedStep=2;
  getid("cO").style.display="block";
   getid("Step2").style.display="none";
  choosedO=opt;
  if (opt==1) moveidto(getid("cO"),125,210);  if (opt==2) moveidto(getid("cO"),115,110);  if (opt==3) moveidto(getid("cO"),245,210);  if (opt==4) moveidto(getid("cO"),260,110);
  setTimeout(playReady,800);
   }
 }
 function blinkStep2(){
if (choosedStep!=1) return;
 if (step2blinkcount==1) step2blinkcount=0; else step2blinkcount=1;
  changeOpac(step2blinkcount*100, getid("Step2")) ;
 setTimeout(blinkStep2,200);
 }
 function playReady(){
 getid("pH").src="images/Player/"+players[choosedP]+"HeadBack.gif";
 getid("oH").src="images/opponent/"+players[choosedO]+"Front1.gif";
 if (choosedP==1)   getid("pB").src="images/Player/bodyFemale.gif";
                    else getid("pB").src="images/Player/bodyMale.gif";
 showPage(getid("Play"));
 setTimeout(hideReadyText,500);
 }
 function startPlay(){
   moveP();
   moveOpp();
 }
 function hideReadyText(){
 readytexttimeout-=5;
 if (readytexttimeout<200 && readytexttimeout>150) getid("readytext").innerHTML="READY!";
 else if (readytexttimeout<150 && readytexttimeout>100) getid("readytext").innerHTML="SET!";
 else getid("readytext").innerHTML="GO!";
 if (readytexttimeout<0) {startPlay(); return; }
 changeOpac(readytexttimeout, getid("readytext")) ;
  setTimeout(hideReadyText,40);
 }
function moveOpp(){
if (isgameOver || currentPage!=getid("Play")) return;
gametime++;
secs=Math.floor((gametime*200)/1000);
sec=Math.floor(secs%60);
min=Math.floor(secs/60);
getid("time").innerHTML="TIME: "+min+":"+sec;
rnd=Math.floor(Math.random()*2);
rnd2=Math.floor(Math.random()*2);
rnd3=Math.floor(Math.random()*2);
oStatus=rnd;
moveidto( getid("oH"),115-rnd*40,70-rnd2*10);
moveidto( getid("oL"),90-rnd*40,140);
moveidto( getid("oR"),160-rnd*40,140);
hitType=Math.floor(Math.random()*10)+1; /* (5,6,7,...)=No Punch     1=Punch Left 2=Punch Right 3=Punch LO Left 4=Punch LO Right */
getid("oL").src="images/opponent/OppGlove1LFT.gif";
getid("oR").src="images/opponent/OppGlove1RT.gif"; 
if  (  hitType == 1) {getid("oL").src="images/opponent/OppGlove4LFT.gif"; oHit=1}
if  (  hitType == 2) {getid("oR").src="images/opponent/OppGlove4RT.gif";oHit=2}
if  (  hitType == 3) {getid("oL").src="images/opponent/OppGlove5LFT.gif";oHit=1}
if  (  hitType == 4) {getid("oR").src="images/opponent/OppGlove5RT.gif";oHit=2}
if (hitType<5) checkOscore();
setTimeout(moveOpp,200);
 }
function moveP(){
if (isgameOver || currentPage!=getid("Play")) return;
rndP=Math.floor(Math.random()*2);
rndP1=Math.floor(Math.random()*2);
pStatus=rndP;
moveidto( getid("pH"),100-rndP*30,130-rndP1*10);
moveidto( getid("pB"),60-rndP*30,230-rndP1*10);
getid("pL").style.left= (50-rndP*40)+"px";
if (getid("pR").src.indexOf("images/Player/playerGlove1RT.gif")==-1) getid("pR").style.left= (160-rndP*40)+"px";
setTimeout(moveP,200);
}/*
function pMove(LFTorRT){
if (isgameOver) return;
pStatus=LFTorRT;
moveidto( getid("pB"),60-LFTorRT*32,230);
moveidto( getid("pH"),100-LFTorRT*32,130);
moveidto( getid("pL"),50-LFTorRT*32,180);
moveidto( getid("pR"),160-LFTorRT*32,180);
}*/
function pPunch(UPorDown){
if (isgameOver || punchIsOut ) return;
punchIsOut=true;
pHit=UPorDown;
if (UPorDown==1) {
getid("pL").src="images/Player/playerGlove1LFT.gif";  getid("pL").style.top="100px";
 }
if (UPorDown==2) {
 
getid("pR").src="images/Player/playerGlove1RT.gif"; moveidto( getid("pR"),80-pStatus*32,80);
 }
 if (UPorDown==3) {
getid("pL").src="images/Player/playerGlove3LFT.gif"; moveidto( getid("pL"),40-pStatus,120);
 }
if (UPorDown==4) {
getid("pR").src="images/Player/playerGlove3RT.gif"; moveidto( getid("pR"),140-pStatus,120);
 }
checkPscore();
setTimeout(pNoPunch,200);
}
function pNoPunch(){
pHit=0;
getid("pL").src="images/Player/playerGlove6LFT.gif"; getid("pL").style.top="180px";
getid("pR").src="images/Player/playerGlove6RT.gif"; moveidto( getid("pR"),160,180);
punchIsOut=false;
}
function checkPscore() {
if ((pHit==1 && oStatus==0)
|| (pHit==2 && oStatus==1)
|| (pHit==3 && oStatus==1)
|| (pHit==4 && oStatus==0)
) {
addPscore();
showTiltOp();
setTimeout(noshowTiltOp,600);
  }
}
function addPscore(){
oScore--;
getid("nosO").style.width=20+(20-oScore)*9.7 +"px";
getid("nosO").style.left=197-(20-oScore)*9.7  +"px";
updateScoreText();
if (oScore==0) {gameOver(); return;}
}
function showTiltOp(){
getid("oH").src="images/opponent/"+players[choosedO]+"Front2hit.gif";
}
function noshowTiltOp(){
getid("oH").src="images/opponent/"+players[choosedO]+"Front1.gif";
}
function checkOscore() {
if ((oHit==1 && pStatus==0)
|| (oHit==2 && pStatus==1)
) {
addOscore();
showTiltP();
setTimeout(noshowTiltP,600);
  }
}
function addOscore(){
pScore--;
getid("nosP").style.width=20+(20-pScore)*9.7 +"px";
getid("nosP").style.left=197-(20-pScore)*9.7  +"px";
updateScoreText();
if (pScore==0) {gameOver(); return;}
}
function showTiltP(){
getid("pH").src="images/Player/"+players[choosedP]+"HeadBackTilt.gif";
moveidto( getid("pH"),100-pStatus*32,162);
}
function noshowTiltP(){
getid("pH").src="images/Player/"+players[choosedP]+"HeadBack.gif";
moveidto( getid("pH"),100-pStatus*32,130);
}
function  updateScoreText(){
sc=(pScore-oScore)*50;
if (sc<0) sc=0;
getid("score").innerHTML="SCORE: "+(sc);
getid("scoreknock").innerHTML="Knock Out Score: "+(sc);
}
function gameOver() {
isgameOver=true;
if (oScore==0) {getid("winorlost").innerHTML="YOU WIN!"; getid("oH").src="images/opponent/"+players[choosedO]+"Front2hit.gif";}
else  getid("winorlost").innerHTML="YOU LOST!";
getid("BoxAlert").style.display="block";
getid("BoxAlertText").style.display="block";

 
}
function showHighScore(){
getid("highScore").style.display="block";
getid("highScoreResult").style.display="none";
}
function getHighScore(page){ 
//if (getid("user").value=="") return;
scoreAjax=new Ajax(getHighScoreCall);
scoreAjax.process("high.php","page="+page+"&score="+((pScore-oScore)*50)+"&userName="+getid("user").value);
getid("highScore").style.display="none";
}
function getHighScoreCall(response){
getid("BoxAlert").style.display="none";
getid("BoxAlertText").style.display="none";

getid("highScoreResult").style.display="block";
getid("highScoreResult").innerHTML=response.responseText;
}
function closeHighScore(){
getid("highScore").style.display="none";
getid("highScoreResult").style.display="none";
}
