var coding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMabcdefghijklmnopqrstuvwxyzabcdefghijklm';

function rot13(input) {
    if (!input) return '';
    for (var output = '',i=0;i<input.length;i++) {
        character = input.charAt(i);
        position = coding.indexOf(character);
        if (position > -1)
            character = coding.charAt(position + 13);
        output += character;
    }
    return output;
}


// create an instance of the Date object
var now = new Date();
// fix the bug in Navigator 2.0, Macintosh
fixDate(now);
// cookie expires in one year (actually, 365 days)
// 365 days in a year
// 24 hours in a day
// 60 minutes in an hour
// 60 seconds in a minute
// 1000 milliseconds in a second
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
var username = getCookie("username");
var pass = rot13(getCookie("pass"));

function cooks() {

	if (username) {
		document.forms[0].elements['request.username'].value = username;
	}
	if (pass) {
		document.forms[0].elements['request.password'].value = pass;
	}	
}

function logMeIn() {

	// set the new cookie
	if (document.forms[0].remember.checked) {
		username = document.forms[0].elements['request.username'].value;
		pass = document.forms[0].elements['request.password'].value;
		//alert("Username is: " + username + "Password is: " + pass);
		setCookie("username", username, now);
		setCookie("pass", rot13(pass), now);
	}
	
	document.forms[0].submit();
}

function deleteCook() {
	deleteCookie('username');
	deleteCookie('pass');
	document.location.reload();
}
