function GetCookie(NameOfCookie)
{
    if (document.cookie.length > 0)
    {
        c_start = document.cookie.indexOf(NameOfCookie + "=");
        if (c_start != -1)
        { 
			c_start = c_start + NameOfCookie.length + 1; 
			c_end = document.cookie.indexOf(";",c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end)) ;
		} 
	}
    return "";
}

function SetCookie(NameOfCookie,value,expiredays)
{
	if (!GetCookie(NameOfCookie)) 
    {
		var exdate = new Date();
        exdate.setDate(exdate.getDate()+expiredays);
        document.cookie = NameOfCookie+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
    }
}

function DelCookie(NameOfCookie) 
{
    if (GetCookie(NameOfCookie)) 
    {
        document.cookie = NameOfCookie + "=" + ";expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function CheckCookie()
{
	if(document.getElementById("Username"))
	{
		UserId = GetCookie('UserId');
		UserPwd = GetCookie('UserPwd');
		if (UserId != null && UserId != "" && UserPwd != null && UserPwd != "")
		{
			document.getElementById("Username").value = UserId;
			document.getElementById("Password").value = UserPwd;
			document.getElementById("ChkRemember").checked = true;
		}
    }
}

function Toggle()
{
    if(document.getElementById("ChkRemember").checked == true)
    {
		var UserId = document.getElementById("Username").value;
        var UserPwd = document.getElementById("Password").value;
        SetCookie('UserId',UserId,365);
        SetCookie('UserPwd',UserPwd,365);
    }
    else
    {
        DelCookie('UserId');
        DelCookie('UserPwd');
    }
} 



