// Sets cookie values.
function GW_setCookie(name, value, domain, path) 
{
	var nextyear = new Date();
	nextyear.setFullYear(nextyear.getFullYear() + 1);
	document.cookie = name + "=" + escape(value) +
		((domain == null) ? "" : "; domain=" + domain) +
		((path == null) ? "" : "; path=" + path) +
		"; expires=" + nextyear.toGMTString();
}

function GW_getCookie(Name) 
{
	var strResultVal = "";
	var search = Name + "=";
	if (document.cookie.length > 0) // if there are any cookies
	{		
		offset = document.cookie.indexOf(search);
		if (offset != -1)// if cookie exists 
		{
			offset += search.length // set index of beginning of value
			end = document.cookie.indexOf(";", offset); 	// set index of end of cookie value
			if (end == -1) 
				end = document.cookie.length;
         	strResultVal = document.cookie.substring(offset, end)
		}
	}

    return unescape(strResultVal.replace( /\+/g, " " )); //asp writes spaces in cookies as +'s
}

function GW_DeleteCookie (name, domain, path)
{
  if (GW_getCookie(name))
  {
    document.cookie = name + "=" +
		((domain == null) ? "" : "; domain=" + domain) +
		((path == null) ? "" : "; path=" + path) +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";//a date in the past will delete it
  }
}

var noCookiesMsg = "Your browser does not appear to accept cookies.  This feature\n" +
					   "utilizes cookies.  If you have disabled cookies on your browser,\n"+
					   "you will not be able to use this feature.\n \n"+
					"For Internet Explorer Users, under Tools select\n"+
					"Internet Options and then the Privacy tab. Set\n"+
					"the Privacy Setting to Medium or below.\n\n"+
					"For Netscape 7.0 Users, under Tools select\n"+
					"Cookie Manager and make sure that cookies\n"+
					"are being accepted from our site.\n\n"+
					"For older versions of Netscape, under Edit\n"+
					"choose Preferences, then Privacy & Security,\n"+
					"then Cookies."; //for the nest function.  this is the default.

function GW_checkCookies()
//RETURNS: true if cookies are enabled. false if not enabled 
//         if false users are given an alert using the global string noCookiesMsg
{
	GW_DeleteCookie ("test", null, null);
    GW_setCookie("test", "testval", null, null);
 
    if (GW_getCookie("test") == '')
	{
		alert(noCookiesMsg);
		return 0;
	}
	else 
	{
		GW_DeleteCookie ("test", null, null);
		return 1;
	}
}