/*







-------------------------------------------------------------------







 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.















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="templates/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="templates/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 = "Protected1.html"; // The page users go to after login, if they have no personal page.







var loginpage = "http://www.pmrusa.net"; //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("client1","password1","Client1/clienthome1.html"); // Change these two entries to valid logins.







users[1] = new Array("indulac","pmr0508","INDULAC/clienthome1.html");          // Add addtional logins, straight after these, as







users[2] = new Array("indulac","admin0321","INDULAC/clienthome1.html");                    // required, followig the same format. Increment the 







users[3] = new Array("mjnrd","pmr0529","MEAD_JOHNSON RD/clienthome1.html");					               // numbers in the square brackets, in new each one. Note:







users[4] = new Array("mjnrd","admin0321","MEAD_JOHNSON RD/clienthome1.html");					       // the 3rd parameter is the the page that user goes to







users[5] = new Array("clorox","pmr0625","CLOROX/clienthome1.html");		             			       // after successful login. Ensure the paths are correct.







users[6] = new Array("clorox","admin0321","CLOROX/clienthome1.html");     // Make this "" if user has no personal page.







users[7] = new Array("royalborinquen","pmr0505","ROYAL_BORINQUEN/clienthome1.html");







users[8] = new Array("royalborinquen","admin0321","ROYAL_BORINQUEN/clienthome1.html");







users[9] = new Array("kraftfoods","kraft0575","KRAFT/clienthome1.html");







users[10] = new Array("kraftfoods","admin0321","KRAFT/clienthome1.html");







users[11] = new Array("poncecaribbean","pmr0525","PONCE_CARIBBEAN/clienthome1.html");







users[12] = new Array("poncecaribbean","admin0321","PONCE_CARIBBEAN/clienthome1.html");







users[13] = new Array("conagra","chef","CONAGRA/clienthome1.html");







users[14] = new Array("conagra","admin0321","CONAGRA/clienthome1.html");







users[15] = new Array("mercasid","pmroos","MERCASID/clienthome1.html");







users[16] = new Array("mercasid","admin0321","MERCASID/clienthome1.html");







users[17] = new Array("bms","pmr0529","BRISTOL_MYERS/clienthome1.html");







users[18] = new Array("bms","admin0321","BRISTOL_MYERS/clienthome1.html");







users[19] = new Array("gkl","emarsuite","GKL/clienthome1.html");







users[20] = new Array("gkl","admin0321","GKL/clienthome1.html");







users[21] = new Array("bacardi","pmr0546","BACARDI/clienthome1.html");







users[22] = new Array("bacardi","admin0321","BACARDI/clienthome1.html");







users[23] = new Array("pueblo","pmrpueblooos","PUEBLO/clienthome1.html");







users[24] = new Array("pueblo","admin0321","PUEBLO/clienthome1.html");







users[25] = new Array("open","pmr0519","KEEBLER/clienthome1.html");







users[26] = new Array("open","admin0321","KEEBLER/clienthome1.html");







users[27] = new Array("cortes","pmr0531","CHOCOLATE_CORTES/clienthome1.html");







users[28] = new Array("cortes","admin0321","CHOCOLATE_CORTES/clienthome1.html");







users[29] = new Array("pepsi","pmr0588","PEPSI/clienthome1.html");







users[30] = new Array("pepsi","admin0321","PEPSI/clienthome1.html");







users[31] = new Array("nestle","pmr0532","NESTLE/clienthome1.html");







users[32] = new Array("nestle","admin0321","NESTLE/clienthome1.html");







users[33] = new Array("vsuarez","pmr0503","V_SUAREZ/clienthome1.html");







users[34] = new Array("vsuarez","admin0321","V_SUAREZ/clienthome1.html");







users[35] = new Array("kraftcolomer","colomerpmr","COLOMER_SUAREZ/clienthome1.html");







users[36] = new Array("kraftcolomer","admin0321","COLOMER_SUAREZ/clienthome1.html");







users[37] = new Array("plazaprov","plaza0570","PLAZA_PROVISION/clienthome1.html");







users[38] = new Array("plazaprov","admin0321","PLAZA_PROVISION/clienthome1.html");







users[39] = new Array("glaxo","pmr0524","GLAXO/clienthome1.html");







users[40] = new Array("glaxo","admin0321","GLAXO/clienthome1.html");







users[41] = new Array("walmart","nooos","WAL_MART/clienthome1.html");







users[42] = new Array("walmart","admin0321","WAL_MART/clienthome1.html");







users[43] = new Array("packersprovision","pmr0514","PACKERS/clienthome1.html");







users[44] = new Array("packersprovision","admin0321","PACKERS/clienthome1.html");







users[45] = new Array("mrspecial","pmrms","MRSPECIAL/clienthome1.html");







users[46] = new Array("mrspecial","admin0321","MRSPECIAL/clienthome1.html");







users[47] = new Array("supermax","pmrmax","SUPERMAX/clienthome1.html");







users[48] = new Array("supermax","admin0321","SUPERMAX/clienthome1.html");







users[49] = new Array("productosfamilia","pmrnosotras","NOSOTRAS/clienthome1.html");







users[50] = new Array("productosfamilia","admin0321","NOSOTRAS/clienthome1.html");







users[51] = new Array("pmrusa","pmrdata","PMR_DATA/clienthome1.html");







users[52] = new Array("pmrusa","admin0321","PMR_DATA/clienthome1.html");







users[53] = new Array("lysol","desinfecta99","RECKITT_BENCKISER/clienthome1.html");







users[54] = new Array("lysol","admin0321","RECKITT_BENCKISER/clienthome1.html");







users[55] = new Array("kimberly","pmr0540","KIMBERLY_CLARK/clienthome1.html");







users[56] = new Array("kimberly","admin0321","KIMBERLY_CLARK/clienthome1.html");







users[57] = new Array("vsuarezchilled","pmr0503","V_SUAREZ/clienthome1.html");







users[58] = new Array("vsuarezbebidas","pmr0503","V_SUAREZ/clienthome1.html");







users[59] = new Array("unilever","pmr0510","UNILEVER/clienthome1.html");







users[60] = new Array("unilever","admin0321","UNILEVER/clienthome1.html");







users[61] = new Array("payco","pmr0543","PAYCO/clienthome1.html");







users[62] = new Array("payco","admin0321","PAYCO/clienthome1.html");







users[63] = new Array("payco","icecream1","PAYCO/clienthome1.html");







users[64] = new Array("vsuarezadmin","pmr0503","V_SUAREZ/clienthome1.html");







users[65] = new Array("rpu721","sagrado","RPU721/clienthome1.html");







users[66] = new Array("cloroxrd","pmr0585","CLOROX_RD/clienthome1.html");







users[67] = new Array("cloroxrd","admin0321","CLOROX_RD/clienthome1.html");







users[68] = new Array("cmu639","sagrado","CMU639/clienthome1.html");







users[69] = new Array("kraftrd","pmr0575","KRAFT_RD/clienthome1.html");







users[70] = new Array("kraftrd","admin0321","KRAFT_RD/clienthome1.html");







users[71] = new Array("mida","convencion2009","MIDA/clienthome1.html");







users[72] = new Array("mida","admin0321","MIDA/clienthome1.html");







users[73] = new Array("cortesrd","pmr0531","CHOCOLATE_CORTES RD/clienthome1.html");







users[74] = new Array("cortesrd","admin0321","CHOCOLATE_CORTES RD/clienthome1.html");







users[75] = new Array("generalmills","pmr0099","GENERAL_MILLS/clienthome1.html");







users[76] = new Array("generalmills","admin0321","GENERAL_MILLS/clienthome1.html");







users[77] = new Array("betis","XXXX","BETIS/clienthome1.html");







users[78] = new Array("betis","admin0321","BETIS/clienthome1.html");







users[79] = new Array("unileverrd","pmr0510","UNILEVER_RD/clienthome1.html");







users[80] = new Array("unileverrd","admin0321","UNILEVER_RD/clienthome1.html");







users[81] = new Array("cocacola","temporero","COCA-COLA/clienthome1.html");







users[82] = new Array("cocacola","admin0321","COCA-COLA/clienthome1.html");







users[83] = new Array("nestlewalmart","pmr0532","NESTLE/clienthome1.html");







users[84] = new Array("nestleestrategico","pmr0532","NESTLE/clienthome1.html");







users[85] = new Array("nestleregional","pmr0532","NESTLE/clienthome1.html");









users[86] = new Array("poncecaribbean","supervisores","PONCE_CARIBBEAN/clienthome1.html");









users[87] = new Array("bmsadministrativo","pmr0529","BRISTOL_MYERS/clienthome1.html");



users[88] = new Array("pueblo","pueblosamp","PUEBLO/clienthome1.html");









users[89] = new Array("pueblo","admin0321","PUEBLO/clienthome1.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; // User validated, terminate the for loop.







   }







 } 







 







 if(loggedin==1){







  if(users[member][2] != "") {







   successpage = users[member][2];







  }







  setCookie("login",1);



  setCookie("user",username);

  setCookie("password",password);






  if (top.location.href != location.href){







   location.href = successpage;           







  }else{







   top.location.href = successpage;  







  }







 }else{







  alert('access denied');







 }  







}















function logout() {







 deleteCookie("login");



 deleteCookie("user");



 deleteCookie("password");



 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'); 







  if(top.location.href != location.href){







   location.href = loginpage;           







  }else{







   top.location.href = loginpage;  







  }







 }







}















//----------------------------------------------------------------







//----------------------------------------------------------------// Login Panel







//----------------------------------------------------------------















function BuildPanel() {







document.write('<form name="logon" action="#" onSubmit="login(username.value,password.value);return false;"><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="submit" value="Logon" name="Logon" onclick="login(username.value,password.value)">'); 







} else {







 document.write('<tr><td align="center" colspan="2"><p><input type="image" src="templates/%27%2BimgSubmit%2B%27" 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="templates/%27%2BimgReset%2B%27" name="Reset" onclick="logon.reset();">');







}







document.write('</p></td></tr></table></form>');







}















