/* Start Directions for Hidden Password 1.2 script

1. Save this script as HiddenPassword1.2.js
2. Create new HTML file and include: <HTML><BODY>
<SCRIPT LANGUAGE="JavaScript" SRC="HiddenPassword1.2.js"></SCRIPT></BODY></HTML>
3. Save HTML file as HiddenPassword1.2.html

End Directions for Hidden Password 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>Access Granted!</h1></center>')
 
 if (confirm("Enter protected area?"))
     {
      window.location="http://www.stellingholidaylet.co.uk/_private/client02.htm" 
      // 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>Intruder Alert!</h1></center>')

 alert("Intruder Alert!")
 document.location="javascript: history.go(-1)"
}

function checkPassword()
{
 var turn
 var yourPassword = "sigma" // Replace "HappySmart" 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 to Client Area" onClick="checkPassword()">')
//Script ends
