var wait=1;
var seq=1;
var pA=0;
var positionAdjustment=0;

positionAdjustment=window.screen.width/2-350;
pA=window.screen.width/2-350;

function KeyPressEvent()
{
if (window.event.keyCode==27)
{

if (getCookie("ByeByeScreen")=="" || getCookie("ByeByeScreen")==null ) {window.close();}
if (getCookie("ByeByeScreen")=="0") {location.href="lbyebye.htm"}
if (getCookie("ByeByeScreen")=="1") {location.href="lbyebyenap.htm"}
if (getCookie("ByeByeScreen")=="2") {location.href="lbyebyesleep.htm"}
if (getCookie("ByeByeScreen")=="3") {location.href="lbyebyebath.htm"}
if (getCookie("ByeByeScreen")=="4") {location.href="lbyebyelunch.htm"}
if (getCookie("ByeByeScreen")=="5") {location.href="lbyebyedinner.htm"}


}
}
function RedirectToGame()
{
switch (seq)
{
case 1:
setCookie("lp","1");
location.href="ltrain.htm"
break;
case 2:
setCookie("lp","2");
location.href="lmouse.htm"
break;
case 3:
setCookie("lp","3");
location.href="lhouse.htm"
break;
case 4:
setCookie("lp","4");
location.href="lshapes.htm"
break;

case 5:

location.href="check.asp"
break;
case 6:
location.href="check.asp"
break;
case 7:
location.href="check.asp"
break;
case 8:

location.href="check.asp"
break;


case 9:
location.href="check.asp"
break;
case 10:
location.href="check.asp"
break;
case 11:
location.href="check.asp"
break;
case 12:
location.href="check.asp"
break;

}
}
function KeyEvent()
{

if (window.event.keyCode!=27)
{
if (window.event.keyCode==13)
{
if (selectsnd.issoundcardenabled()) { 

   //Is there a sound card?
         if (selectsnd.readyState >= 3)   //Has enough downloaded that it can play?
         selectsnd.Run();}

setCookie("CurrentGame", seq);

setTimeout("RedirectToGame();",200); 

}
else 
{ClickEvent();}
if (window.event.keyCode==113)
{
//help
}


}
}

function setFrame()
{
if (seq==1) {showSeq('RedFrame',pA+40+11,133);}
if (seq==2) {showSeq('RedFrame',pA+40+11+138,133);}
if (seq==3) {showSeq('RedFrame',pA+40+11+276,133);}
if (seq==4) {showSeq('RedFrame',pA+40+11+276+138,133);}

if (seq==8) {showSeq('RedFrame',pA+40+11,259);}
if (seq==7) {showSeq('RedFrame',pA+40+11+138,259);}
if (seq==6) {showSeq('RedFrame',pA+40+11+276,259);}
if (seq==5) {showSeq('RedFrame',pA+40+11+276+138,259);}

if (seq==9) {showSeq('RedFrame',pA+40+11,259+126);}
if (seq==10) {showSeq('RedFrame',pA+40+11+138,259+126);}
if (seq==11) {showSeq('RedFrame',pA+40+11+276,259+126);}
if (seq==12) {showSeq('RedFrame',pA+40+11+276+138,259+126);} 
wait=0;
}

function ClickEvent()
{

if (wait==0)
{
wait=1;
   		if (snd1.issoundcardenabled()) {    //Is there a sound card?
         if (snd1.readyState >= 3)   //Has enough downloaded that it can play?
         snd1.Run();
			}

if (seq==12)
{seq=1;}
else
{++seq;}
if (parseInt(getCookie("Trials"))<1 && seq>4 && getCookie("SessionID")=="Guest" )
{
//no more trials
seq=1;
}


setFrame();

}
 }

function showSeq(divName,x,y)
{
 if (document.layers) 
	{
           eval("document." + divName + ".left= x");
 	   eval("document." + divName + ".top= y");
           eval("document." + divName + ".visibility= 'show'");  
  	  
        } else 
	{
            if (document.all) {
                eval(divName + ".style.left = x");
 		eval(divName + ".style.top = y");
 		eval(divName + ".style.visibility = 'visible'");
            }
        }
 }
 function endSeq()
{
  
++seq;
wait=0;


  
 }

 function hideSeq(divName)
{
 if (document.layers) 
	{
          
            eval("document." + divName + ".visibility= 'hidden'"); 
  	  
        } else 
	{
            if (document.all) {
                 
               eval(divName+".style.visibility = 'hidden'");
  		
            }
        }

 }



// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}







