function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name)  {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)  {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break; 
}
return null;
}
function SetCookie (name, value)  {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie () { 
var exp = new Date();
exp.setTime (exp.getTime() - 1000000000);  
var cval = GetCookie ('FreeStuffL');
document.cookie ='FreeStuffL' + "=" + cval + "; expires=" + exp.toGMTString();    
}

function cookieCreater (loadPage) {
if(GetCookie('FreeStuffL') == null) {
var FreeStuffL_Name =  loadPage;
if (FreeStuffL_Name != null && FreeStuffL_Name != "") {
var expdate = new Date (); 
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 10));
SetCookie('FreeStuffL', FreeStuffL_Name, expdate);  

var data = document.cookie.split('=')
var recreate = data[1].split("//");

location.href = loadPage+".html"
   }
}
else {
DeleteCookie ();
cookieCreater ()
}
}

if(GetCookie('FreeStuffL') == "login") {
var data = document.cookie.split('=')

location.href=data[1]+".html"
cookieCreater ("logout");

}

function submitentry(){
password = document.password1.password2.value.toLowerCase()
username = document.password1.username2.value.toLowerCase()
passcode = 1
usercode = 1

for(i = 0; i < password.length; i++) {
passcode *= password.charCodeAt(i);
}
for(x = 0; x < username.length; x++) {
usercode *= username.charCodeAt(x);
}

if(usercode==1479778894440&&passcode==164637824752800)
{cookieCreater ("piersma");

} else if(usercode==16236794340&&passcode==1446839301600)
{cookieCreater ("client");

} else if(usercode==1796064943680&&passcode==14342602263000000)
{cookieCreater ("ondemand");

} else if(usercode==1374593086944&&passcode==1530119772720)
{cookieCreater ("copera");

} else if(usercode==211021540059145830000&&passcode==18860945290951680)
{cookieCreater ("garceworks");

} else if(usercode==172646085131520&&passcode==18901363498617600)
{cookieCreater ("new_hope");

}
else {
alert("password/username combination wrong")}
}
