

//----------------------------------------------------------------
//  Usernames, Passwords & User Pages - These require configuration.
//----------------------------------------------------------------
var successpage = "/proofing/login-fail.htm"; // The page users go to after login, if they have no personal page.
var loginpage = "/proofing/Logon.htm"; //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("alex","locked","/proofing/Alex-Espy/index.htm"); // Change these two entries to valid logins.
users[1] = new Array("jodierubley","admin","/proofing/Jodie-Rubley/index.htm"); // Add addtional logins, straight after these, as
users[2] = new Array("evanjack","bearden","/proofing/Evan-Jack/index.htm"); // required, followig the same format. Increment the 
users[3] = new Array("smit","logan","/proofing/smit/index.htm"); 
users[4] = new Array("ashton","ashton","/proofing/ashton/index.htm");
users[5] = new Array("frainey","2010","/proofing/frainey/index.htm");
users[6] = new Array("rath","leah","/proofing/rath/index.htm");
users[7] = new Array("amelie","harbison","/proofing/amelie/index.htm");
users[8] = new Array("smith","6months","/proofing/smith/index.htm");
users[9] = new Array("crosby","beach","/proofing/crosby/index.htm");
users[10] = new Array("oliviab","10days","/proofing/oliviab/index.htm");
users[15] = new Array("joseph","list","/proofing/joseph/index.htm");
users[11] = new Array("nelson","646","/proofing/nelson/index.htm");
users[12] = new Array("bard","alex","/proofing/bard/index.htm");
users[13] = new Array("damori","2011","/proofing/damori-family/index.htm");
users[14] = new Array("welcome","2010","/proofing/welcome/index.htm");
 // numbers in the square brackets, in new each one. Note:
											                  // the 3rd parameter is the the page that user goes to
											                  // after successful login. Ensure the paths are correct.
                                                              // Make this "" if user has no personal page.
//----------------------------------------------------------------
//  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('Please enter a correct Username and Password.'); // 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('Please enter a correct Username and Password.'); // 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">');
document.write('<h1>Please Login Below</h1>');
document.write('<p>&nbsp;</p>');
document.write('<p>Username: <input class="username" type="text" name="username" size="20">');
document.write('<br />Password: <input class="password" type="password" name="password" size="20">');
document.write('<br />');
if(imgSubmit == ""){
 document.write('<input class="loginBtn" type="button" value="Logon" name="Logon" onclick="login(username.value,password.value)">'); 
} else {
 document.write('<input type="image" src="'+imgSubmit+'" name="Logon" onclick="login(username.value,password.value)">');
}
if(imgReset == ""){
 document.write('&nbsp;&nbsp;<input class="loginBtn" type="reset" value="Reset" name="Reset">');
} else {
 document.write('&nbsp;&nbsp;<input type="image" src="'+imgReset+'" name="Reset" onclick="logon.reset();">');
}
document.write('</p></form>');
}
