// Sets a Cookie with the given name and value
function SetCookie (piKey, piValue)
{
var sSubDomain;
var nPos;
 
	sSubDomain = location.hostname;
	nPos = sSubDomain.indexOf('.');
	if (nPos > 0)
	{
	 sSubDomain = sSubDomain.substring (nPos);
	 document.cookie= piKey + '=' + escape(piValue) + ';domain=' + sSubDomain + '; path=/';
	}
	else
	{
	 document.cookie= piKey + '=' + escape(piValue) + '; path=/';
	}

}

// Read the value of the specified cookie
function ReadCookie (piKey)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0)
           return null;
    }
    else
    {
        begin += 2;
    }
    
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    
    return unescape(dc.substring(begin + prefix.length, end));
}

// Remove the specified cookie
function RemoveCookie (piKey)
{
  UtWriteCookie (piKey, "", -1);
}

function DetectCookie ()
{
 if (! window.navigator.cookieEnabled)
 {
// alert('cookie disabled');
   
   window.location.href = "support/CookieHelp.aspx";
   return false;
 }
 else
 {
   return true;
 }
}

function GotoReuiredCookieUrl(piUrl)
{
 if (! DetectCookie())
    return false;
     
 window.location.href = piUrl;
 
 return true;
}

function GotoRequiredCookieUrlForAS(piUrl)
{
 if (! window.navigator.cookieEnabled)
 {
   var sMsg="Please Note: Your internet settings currently block cookies.\nYou must Allow Cookies before executing Advanced Search in order for Advanced Search to function without problems.";
   alert(sMsg);
 }
     
 window.location.href = piUrl;
 
 return true;
}


function GotoRequiredCookieWarning(piUrl)
{
	if (! window.navigator.cookieEnabled)
	{
        var sMsg="Your internet settings currently block cookies.\nYou will not be able to do this."
		alert(sMsg);
		//return false;
	}
	else
	{   
		window.location.href = piUrl;
	 
		return true;
	}
}
