//  Check whether cookies are enabled.  If so then redirect the user
//    to the given redirect page; otherwise output an error message
//    (which appears in the body of the HTML page)
//
function check_cookies(redirectUrl)
{
	var cookies_enabled = false;

	//  Check whether cookies are enabled
	//
	if ( document.cookie != "" )
	{
		//  A cookie is already present, so they must be enabled
		cookies_enabled = true;
	}
	else
	{
		//  No cookies are currently present, so they might be disabled.
		//    Try to set a cookie ...
		document.cookie = "TEST_IF_ACCEPTS_COOKIES=1";
		//  ... and see whether this worked
		if ( document.cookie.indexOf( "TEST_IF_ACCEPTS_COOKIES" ) != -1 )
		{
			//  The cookie was set successfully
			cookies_enabled = true;
		}
	}

	//  Redirect the user if cookies are enabled; otherwise output
	//    an error message
	//
	if ( cookies_enabled )
	{
		window.location = redirectUrl;
	}
	else
	{
		document.write( "<p><font face=arial, helvetica, sans-serif size=3><b>It appears that your browser will " +
						"not accept cookies.</b></font>\n" );
	}
}
