// The existing CookieStatus value may be left over from some previous visit
// to this page.  So to check whether cookies are *currently* enabled, we
// must try to change the existing value exactly once to some different
// value, then look for the (hopefully) new value.
function CookieStatus ()
    {
    var allcookies;
    allcookies = document.cookie;
    var OldCookieStatusValue = 0;
    if (allcookies == "")
	OldCookieStatusValue = 0;
    else
	{
	var prefix = "CookieStatus=";
	var start = allcookies.indexOf (prefix);
	if (start == -1)
	    OldCookieStatusValue = 0;
	else
	    {
	    start += prefix.length;
	    var just_past_end = allcookies.indexOf (';', start);
	    if (just_past_end == -1)
		just_past_end = allcookies.length;
	    // The strange arithmetic is used to force a conversion from string to number.
	    OldCookieStatusValue = allcookies.substring (start, just_past_end) - 1 + 1;
	    }
	}
    return (OldCookieStatusValue);
    }

function cookiesAreEnabled()
    {
    var OldValue;
    var SetValue;
    var NewValue;

    // The navigator.cookieEnabled object is always null in Netscape Navigator,
    // and in Internet Explorer it reflects whether cookies are possible, not
    // whether they are currently exchanged (specifically, it is false only for
    // the disable-cookies setting and true for both the enable-cookies and
    // prompt-for-cookies settings, even if the user turns down a test cookie).
    // This behavior is insufficient for our use, so we exchange a test cookie.

    OldValue = CookieStatus ();
    SetValue = OldValue + 1;
    document.cookie = "CookieStatus=" + SetValue;
    NewValue = CookieStatus ();

    return (NewValue != OldValue);
    }
	

