/* Start Directions for apple2 script

1. Save this script as apple2.js
2. Create new HTML file and include: <HTML><BODY>
<SCRIPT LANGUAGE="JavaScript" SRC="apple2.js"></SCRIPT></BODY></HTML>
3. Save HTML file as apple2.html

End Directions for apple2 script */ 

//Script begins

function AccessGranted() 
{
 document.write('<bgsound src="AccessGranted.wav" loop=1>')
 // You can replace AccessGranted.wav audio file with your own

 document.write('<center><h1>Please wait...</h1></center>')
 
 if (confirm("Enter protected area?"))
     {
      window.location="http://www.westhigh.com/users/mkim/wks.html" 
      // Replace this URL with your own
     }
 else document.location="javascript: history.go(-1)" 

}

function IntruderAlert()
{
 document.write('<bgsound src="IntruderAlert.wav" loop=-1>')
 document.write('<center><h1>Access Denied!</h1></center>')

 alert("Access Denied!")
 document.location="javascript: history.go(-1)"
}

function checkPassword()
{
 var turn
 var yourPassword = "batman" // Replace "AppleSmart" with your own password

 for(turn=0;turn<3;++turn)
 {
  switch(turn)
  {
   case 0:
     password=prompt('Enter password:',"");
     if (password == yourPassword) AccessGranted()
     else alert("Password incorrect. This was your first attempt.")     
     break
    
   case 1:
     password=prompt('Enter password:',"");
     if (password == yourPassword) AccessGranted()
     else alert("Password incorrect. This was your second attempt.")     
     break

   case 2:
     password=prompt('Enter password:',"");
     if (password == yourPassword) AccessGranted()
     else alert("Password incorrect. This was your last attempt.")     
     IntruderAlert()
  }
 if (password == yourPassword) break;
 }
}

document.write('<form><input type=button value="Login" onClick="checkPassword()">')
//Script ends