	function getexpirydate( nodays){
		var UTCstring;
		Today = new Date();
		nomilli=Date.parse(Today);
		Today.setTime(nomilli+nodays*24*60*60*1000);
		UTCstring = Today.toUTCString();
		return UTCstring;
	}

    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, duration) {
	var today = new Date()
	var defaultExpire = new Date()
	var currentCookie = name + "=" +
		escape(value) + "; expires=" + getexpirydate(duration);
	document.cookie = currentCookie;
}
  
	function handleCheckbox(){
		if (document.loginForm.rememberID.checked)
		{
			var currLoginName = document.loginForm.login_name.value;
			var currPassword = document.loginForm.password.value;
			var currCookie;
			var duration = 365;
		
			if (currLoginName != "" && currPassword != ""){
				setCookie("loginName", currLoginName, duration);
				setCookie("pwd", currPassword, duration);
			}
		}
		else
		{
			if(getcookie("loginName")){
				duration = -1;
				setCookie("loginName", currLoginName, duration);
				setCookie("pwd", currPassword, duration);
			}	
		}
	}

function intiLoginBox(){
	if(getcookie("loginName")){
		document.loginForm.login_name.value = getcookie("loginName");
		document.loginForm.password.value = getcookie("pwd");
		document.loginForm.rememberID.checked = true;
	}
}

function submitLogin(){
	formObj = eval("document.loginForm");
	loginName = formObj.login_name.value;
	password = formObj.password.value;
	
	if (loginName == "" && password == ""){	
		document.location.href = "login.aspx?msg=0";
	}
	else{
		formObj.submit();
	}
}

function handleKeyPress(){
	if (event.keyCode == 13){
		submitLogin();
			event.returnValue = false;
	}
}
