	function getCookie(name)
	{
		var cookieFound = false;
		var start = 0;
		var end = 0;
		var cookieString = document.cookie;
		var cookieValue;

		var i = 0;
		
		//scan the Cookie for the name
		while (i <= cookieString.length){
			start = i;
			end = start + name.length;
			if(cookieString.substring(start, end) == name){
				cookieFound = true;
				break;
			}
			i++;
		}
		
		//is name found/
		if(cookieFound){
			start = end+1;
			end = document.cookie.indexOf(";",start);
			if(end < start)
				end = document.cookie.length;
			cookieValue = document.cookie.substring(start, end);
			start = 0;
			end = cookieValue.indexOf(" ", start);
			if(end < start)
				end = cookieValue.length;
			return cookieValue.substring(start, end);
		}
		return "";
	}

	function initFields()
	{
		document.logon.userid.value = getCookie("IMail_UserId");
		document.logon.passwd.value = getCookie("IMail_password");
	}

	function deleteCookie(name, path, domain){
		if(getCookie(name)){
			document.cookie = name+ "=" + 
				((path) ? "; path=" + path : "") +
				((domain) ? "; domain=" + domain: "") +
				"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	}
	
// for Classics
function Set_Cookie(name,value,expires,domain,path,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

expires = new Date();
expires.setTime(expires.getTime() + (365 * 24 * 60 * 60 * 1000));


	function formSubmit()
	{
		deleteCookie("IMail_UserId", "/", null);
		deleteCookie("IMail_password", "/", null);
		deleteCookie("IMail_UserKey", "/", null);
	}
