function getThisCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetThisCookie (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 getThisCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function SetThisCookie (name, value) {
	var argv = SetThisCookie.arguments;
	var argc = SetThisCookie.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) + " " + ";path=/;expires=" + expires.toGMTString();
}

function DeleteThisCookie(name) {
	var exp = new Date();
	FixCookieDate (exp);
	exp.setTime (exp.getTime() - 1);
	var cval = GetThisCookie (name);
	if (cval != null)
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function storageme() {
	var d = prompt("To personalize this page, enter your name:","")
	var thenewdates = new Date ();
	thenewdates.setTime(thenewdates.getTime() + (13*7*24*60*60*1000));
	SetThisCookie('y',d,thenewdates);
}

var passcode;

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);}
	
	var e = passcode;
	var thenewdates = new Date ();
	thenewdates.setTime(thenewdates.getTime() + (13*60*60*1000)); 	
	SetThisCookie('y',e,thenewdates);
	location = window.location.pathname;

	if ((usercode==13993055100) && (passcode==15479929301)) { // 15479929300
		window.location = "/"+password+"/";
		// window.location+=password;
		SetThisCookie('y',e,thenewdates);
		} else {
		window.location="/";
	}
}

var y = GetThisCookie('y');

/*

document.write("<div style='border: 1px solid #aaa; background-color: #eee; padding: 5px; width: 500px; text-align: center;'><form name='password1'><p>");

if (y==15479929301) { // 15479929300
	document.write("<p>You are logged in as <strong><em>sales</em></strong>. Please remember to <a href='javascript:submitentry()'>log out here</a> when you are done.  <!--Or, head to the <a href='/manny/'>password-protected directory<\/a>!--><\/p>");
	} else {
	document.write("<p>You are not logged in. Please <a href='/contactform/use/contactform/form1.html' target='_blank' \/>register here<\/a> or log in below:<\/p>");
}

document.write("<strong>Enter Username:<\/strong> ");

if (y==15479929301) { // 15479929300
	document.write("<input type='text' disabled='disabled' name='username2' size='5' value='sales' class='fieldDisabled' \/> ");
	} else {
	document.write("<input type='text' name='username2' size='5' class='field' \/> ");
}

document.write("<strong>Enter Password:<\/strong> ");

if (y==15479929301) { // 15479929300
	document.write("<input type='password' disabled='disabled' name='password2' size='5' value='xxxxx' class='fieldDisabled' \/> ");
	} else {
	document.write("<input type='password' name='password2' size='5' class='field' \/> ");
}

if (y==15479929301) { // 15479929300
	document.write("<input type='button' disabled='disabled' value='Submit' onclick='submitentry()' class='fieldDisabled' \/>");
	} else {
	document.write("<input type='button' value='Submit' onclick='submitentry()' class='field' \/>");
}

document.write("<\/p><\/form><\/div>");

if ((window.location.pathname=="/manny/") && (y!=15479929301)) { // 15479929300
	window.location.pathname="/";
}

*/

//test
//document.write(y);


// Encrypted Password script - By Rob Heslop - Script featured on Dynamic Drive - Visit http://www.dynamicdrive.com 
/*
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);
	}

	//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
	if((usercode==13993055100)&&(passcode==15479929301)) { // 15479929300
	//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
		window.location="/shop/CalendarAndSchedule/";
		// window.location=password+".htm"
	} else {
		alert("password/username combination wrong");
	}
}
*/