
var successpage = "";
var ul = "";

var loginpage = "login.html"; 

var imgSubmit = ""; 
var imgReset = "";  

var users = new Array();

users[0] = new Array("amazingbaby","letsparty",""); 

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);
  var str=window.location.search.substring(1);

  if (str.match("exc=girl1"))
  {
	  successpage = "cheap-baby-shower-invitation.html"
  }else if (str.match("exc=boy1"))
  {
	  successpage = "baby-boy-shower-invitations.html"
  }else if (str.match("exc=abc1"))
  {
	  successpage = "unique-baby-shower-invitations.html"
  }else if (str.match("exc=abc2"))
  {
	  successpage = "baby-shower-invitation-cards.html"
  }else if (str.match("exc=cb1"))
  {
	  successpage = "cowboy-baby-shower.html"
  }else if (str.match("exc=lua1"))
  {
	  successpage = "hawaiian-baby-shower.html"
  }else if (str.match("exc=lua2"))
  {
	  successpage = "hawaiian-baby-shower-invitations.html"
  }else if (str.match("exc=ori1"))
  {
	  successpage = "baby-boy-shower-invitation.html"
  }else if (str.match("exc=ori2"))
  {
	  successpage = "baby-girl-shower-invitations.html"
  }else if (str.match("exc=poo1"))
  {
	  successpage = "pooh-bear-baby-shower.html"
  }else if (str.match("exc=poo2"))
  {
	  successpage = "pooh-baby-shower-ideas.html"
  }else if (str.match("exc=xma1"))
  {
	  successpage = "christmas-baby-shower-invitations.html"
  }else if (str.match("exc=xma2"))
  {
	  successpage = "baby-girl-invitation-shower.html"
  }else if (str.match("exc=hal1"))
  {
	  successpage = "baby-boy-shower-idea.html"
  }else if (str.match("exc=hal2"))
  {
	  successpage = "halloween-baby-shower.html"
  }else if (str.match("exc=hal3"))
  {
	  successpage = "halloween-baby-shower-invitations.html"
  }else if (str.match("exc=hal4"))
  {
	  successpage = "halloween-baby-shower-invitation.html"
  }else if (str.match("exc=pre1"))
  {
	  successpage = "precious-moments-baby-shower.html"
  }else if (str.match("exc=pre2"))
  {
	  successpage = "precious-moments-baby-shower-invitations.html"
  }else if (str.match("exc=pss1"))
  {
	  successpage = "princess-baby-shower-invitation.html"
  }else if (str.match("exc=pir1"))
  {
	  successpage = "baby-shower-invitations-online.html"
  }else if (str.match("exc=pir2"))
  {
	  successpage = "thank-you-cards-for-baby-shower.html"
  }else if (str.match("exc=ali1"))
  {
	  successpage = "alice-in-wonderland-invitations.html"
  }else if (str.match("exc=ali2"))
  {
	  successpage = "alice-in-wonderland-baby-shower.html"
  }else if (str.match("exc=shr1"))
  {
	  successpage = "baby-shower-invites.html"
  }else if (str.match("exc=shr2"))
  {
	  successpage = "baby-shower-thank-you.html"
  }else if (str.match("exc=spo1"))
  {
	  successpage = "cheap-baby-shower-invitations.html"
  }else if (str.match("exc=spo2"))
  {
	  successpage = "baby-shower-thank-you-notes.html"
  }else if (str.match("exc=tea1"))
  {
	  successpage = "baby-shower-tea.html"
  }else if (str.match("exc=tea2"))
  {
	  successpage = "free-baby-shower-cards.html"
  }else if (str.match("exc=cow1"))
  {
	  successpage = "printable-baby-shower-invitation.html"
  }else if (str.match("exc=jng1"))
  {
	  successpage = "jungle-baby-shower-invitation.html"
  }else if (str.match("exc=jng2"))
  {
	  successpage = "jungle-baby-shower-invitations.html"
  }else if (str.match("exc=spa1"))
  {
	  successpage = "print-free-invitations-baby-shower.html"
  }else if (str.match("exc=spa2"))
  {
	  successpage = "free-baby-shower-printables.html"
  }else if (str.match("exc=ard1"))
  {
	  successpage = "around-the-clock-baby-shower-invitation.html"
  }else if (str.match("exc=ard2"))
  {
	  successpage = "around-the-clock-baby-shower-invitations.html"
  }else if (str.match("exc=thg1"))
  {
	  successpage = "thanksgiving-baby-shower-invitation.html"
  }else if (str.match("exc=thg2"))
  {
	  successpage = "thanksgiving-baby-shower-invitations.html"
  }else if (str.match("exc=val1"))
  {
	  successpage = "valentine-baby-shower-invitations.html"
  }else if (str.match("exc=val2"))
  {
	  successpage = "valentine-baby-shower-invitation.html"
  }else if (str.match("exc=ado1"))
  {
	  successpage = "baby-adoption-shower-invitations.html"
  }else if (str.match("exc=ado2"))
  {
	  successpage = "baby-shower-invitations-for-adoption.html"
  }else if (str.match("exc=twn1"))
  {
	  successpage = "twin-shower-invitations.html"
  }else if (str.match("exc=twn2"))
  {
	  successpage = "twin-shower-invitation.html"
  }else if (str.match("exc=twn3"))
  {
	  successpage = "baby-shower-for-twins.html"
  }else if (str.match("exc=fee1"))
  {
	  successpage = "baby-thank-you-cards.html"
  }else if (str.match("exc=fee2"))
  {
	  successpage = "invitations-for-baby-shower.html"
  }else if (str.match("exc=noa1"))
  {
	  successpage = "noahs-ark-baby-shower-invitations.html"
  }else if (str.match("exc=noa2"))
  {
	  successpage = "noahs-ark-baby-shower-invitation.html"
  }else if (str.match("exc=nur1"))
  {
	  successpage = "nursery-shower.html"
  }else if (str.match("exc=nur2"))
  {
	  successpage = "nursery-rhyme-shower-invitation.html"
  }else if (str.match("exc=mex1"))
  {
	  successpage = "invitaciones-baby-shower.html"
  }else if (str.match("exc=mex2"))
  {
	  successpage = "spanish-baby-shower-invitations.html"
  }else if (str.match("exc=ebk"))
  {
	  successpage = "get-ebook.html"
  }else{
	  successpage = "baby-shower-invitation.html"
  }
  
  if (top.location.href != location.href){
   location.href = successpage;           
  }else{
   top.location.href = successpage;  
  }
 }else{
  alert('Access denied');
 }  
}

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(ul) {
 var temp = getCookie("login");
 if(!temp==1) {
//  alert('Access denied'); 
  if(top.location.href != location.href){
   location.href = loginpage + ul;           
  }else{
   top.location.href = loginpage + ul;  
  }
 }
}

//----------------------------------------------------------------
// Login Panel
//----------------------------------------------------------------

function BuildPanel() {
document.write('<form name="logon"><table align="center" border="0" bgcolor="#ccccff"><tr><div align="center"><p><img src="image-files/babyshowerexpress2.gif" alt="baby-shower-idea" width="108" height="108" /></p></tr><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><div align="justify"><h6>Use your Baby Shower Express username and password to get our exclusive<br>printables. Not yet a subscriber? Click <a href="baby-shower-newsletter.html">here</a> to subscribe to Baby Shower Express.</h6></div></p>');
document.write('</p></td></tr></table></form>');
}

