/*
-------------------------------------------------------------------
 Login Script Version 1.9
 By H G Laughland 
 http://www.laughland.biz

This script can be used free of charge and may only be
redistributed the same way. The disclaimer must remain
intact.

DISCLAIMER: Use this script with caution. This script is not 
the most secure method available, for protecting material. Its
main purpose is to demonstrate the javascript techniques used.
The author takes no responsibility for data loss
resulting from the use of this script.
-------------------------------------------------------------------

INSTRUCTIONS - Read Before Using Script

If you are using frames, the code referred to in steps 2 - 5 must be put in the 
pages displayed in the frames and NOT in the parent document.

PLEASE NOTE For HodderPlus the login function is split into three files login-variables.js, login-functions.js and login-panel.js. The login variable should sit in the individual site folders. The other two files sit in the main 'scripts' folder.

Step 1
In the file login-variables, configure the variables as
indicated by the comments.
 
Step 2:
Add the following code to the <head> section of your login page: 
 <script src="scripts/login-variables.js"></script> this should go above the files
 
 <script src="../scripts/login-functions.js"></script>
<script src="../scripts/login-panel.js"></script>
 
Change "scripts/login.js" to reflect the correct path to this script
file on your server. 
 
Step 3:
Add this code to the login page, at the place you want the login
panel to show:
 
 <script language="JavaScript">
  BuildPanel();
 </script>
 
Step 4:
Add the following code to the <head> section of each page procteded
by this script:
 

 <script src="scripts/login-variables.js"></script>
<script src="../scripts/login-functions.js"></script>
 <script language="JavaScript">
  checkCookie();
 </script>

Change file paths to reflect the correct path to the script
file on your server.
 
Step 5: 
On the page that is to have the logout button, paste this code where you
want the button to be:

 <form action="" name="frmLogoff">
  <input type="button" name="btLogoff" value="log out" onclick="logout();">
 </form>
 
 To use your own image instead of the grey button change the type from button to image
 and add src="myimage.gif" where myimage.gif is the image (including the path to it if
 needed, you want to use.
 
Step 6:
Upload this script and your html pages to the relevant directories
on your server. 

*/
//----------------------------------------------------------------
// Login Panel
//----------------------------------------------------------------

function BuildPanel() {
document.write('<form name="logon" class="loginform"><table align="left" border="0" cellspacing="5"><tr><td align="right">');
document.write('Username:</td>');
document.write('<td><input type="text" name="username" size="30"></td></tr>');
document.write('<tr><td align="right">Password:</td>');
document.write('<td><input type="password" name="password" size="30" onkeydown="javascript:if (event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {login(username.value,password.value)}};"></td></tr>');

if(imgSubmit == ""){
document.write('<tr><td></td><td><p><input type="button" class="loginbutton" value="Log in" name="Logon" onclick="login(username.value,password.value)">');
}

else {
document.write('<tr><td align="center" colspan="2"><p><input type="image" src="'+imgSubmit+'" name="Logon" onclick="login(username.value,password.value)">');
}

/*else {
document.write('<tr><td></td><td><p><input type="image" src="'+imgSubmit+'" name="Logon" onclick="login(username.value,password.value)">');
}
if(imgReset == ""){
document.write('<input type="reset" value="Reset" name="Reset">');
} else {
document.write('<input type="image" src="'+imgReset+'" name="Reset" onclick="logon.reset();">');
}
*/
document.write('</p></td></tr></table></form>');
}


