function setDocCookie(NameOfCookie,Value,Expiry,Path,Domain,Secure) {
   	if(NameOfCookie == null || Value == null) { 
   		return;
   	}
	if (Expiry != null && !isNaN(Expiry)) {
   		var datenow = new Date();
   		datenow.setTime(datenow.getTime() + Math.round(86400000*Expiry));
   		Expiry = datenow.toGMTString();
   	}
	Expiry = (Expiry) ? '; expires='+Expiry : '';
	Path = (Path) ? '; path='+Path : '';
	Domain = (Domain) ? '; domain='+Domain : '';
	Secure = (Secure) ? '; secure' : '';
	Settings = Expiry + Path + Domain + Secure;
 	
	document.cookie = NameOfCookie + '=' + escape(Value) + Settings;
}

function getDocCookie(NameOfCookie) {

	var cookies = ' ' + document.cookie;

	if (cookies.indexOf(' ' + NameOfCookie + '=') == -1) {
//		alert("sorry, no cookie for " + NameOfCookie);
		return null;
   	}	
	var start = cookies.indexOf(' ' + NameOfCookie + '=') + (NameOfCookie.length + 2);
	var finish = cookies.substring(start,cookies.length);
	//finish = (finish.indexOf(';') == -1) ? cookies.length : start + finish.indexOf(';');
	finish = (finish.indexOf(';') == -1) ? start + finish.length : start + finish.indexOf(';');
	return unescape(cookies.substring(start,finish));
}

function delDocCookie(NameOfCookie) 
{
	if (NameOfCookie == "") {
		return;
	}	

	// The function simply checks to see if the cookie is set.
	// If so, the expiration date is set to Jan. 1st 1970.
	if (getDocCookie(NameOfCookie)) {
		setDocCookie(NameOfCookie, "");
		document.cookie = NameOfCookie + "=; path=/; expires=Fri, 02-Jan-1970 00:00:00 GMT";
		//alert("Deleted cookie: "+NameOfCookie+"\n Cookie="+document.cookie);
	}
} 