//----------------------------------------------------------------
//  Usernames, Passwords & User Pages - These require configuration.
//----------------------------------------------------------------
var successpage = "http://www.internetmarketingprofitscenter.com/private/index.html"; // The page users go to after login, if they have no personal page.
var loginpage = "http://www.internetmarketingprofitscenter.com/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("vault","test","");
//----------------------------------------------------------------
//  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); 
  top.location.href = successpage;           
  }
 else {
  alert('        <--- ACCESS DENIED --->\n\n\Please verify your monthly ID and password !! \n\You can use our Password Reminder service\n\just in case you forgot your login information.');
  }  
}

function logout() {
 deleteCookie("login");
 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'); 
 top.location.href=loginpage; }
}

//----------------------------------------------------------------
// Login Panel
//----------------------------------------------------------------
function BuildPanel(){document.write('<table border="0" cellPadding="4" cellSpacing="0"><TR><TD align="right">');document.write('<table border="0" cellPadding="2" cellSpacing="0"><TR><TD><font face="arial,helvetica,sans-serif" size="2">Monthly <B>ID</B>:</font></td>');document.write('<td><font face="arial,helvetica,sans-serif" size="2"><input type="text" name="username" size="17"></font></td></tr>');document.write('<tr><td><font face="arial,helvetica,sans-serif" size="2"><B>Password</B>:</font></td>');document.write('<td><font face="arial,helvetica,sans-serif" size="2"><input type="password" name="password" size="17"></font></td></tr></table>');if(imgSubmit == ""){document.write('<tr><td align="center"><input type="button" value="Sign In" 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;&nbsp;&nbsp;&nbsp;<input type="reset" value="Reset" name="Reset">');} else {document.write('<input type="image" src="'+imgReset+'" name="Reset" onclick="logon.reset();">');}document.write('</td></tr></table>');}
