function setCookie(NameOfCookie, value, expiredays, url)
{
	
	// Three variables are used to set the new cookie.
	// The name of the cookie, the value to be stored,
	// and finally the number of days until the cookie expires.
	// The first lines in the function convert
	// the number of days to a valid date.
	
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	
	// The next line stores the cookie, simply by assigning
	// the values to the "document.cookie" object.
	// Note the date is converted to Greenwich Mean time using
	// the "toGMTstring()" function.
	
	document.cookie = NameOfCookie + "=" + escape(value) +
	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
	
	if (url) document.location=url;
}