//------------------------------------------------------------------------------------------ setCookie
function setCookie(sName, sValue, dExpires, sPath, sDomain, bSecure)
{
    if (!navigator.cookieEnabled) return;
    
      var sCookie = sName + "=" + escape(sValue) +
                  ((dExpires) ? "; expires=" + dExpires.toGMTString()   : "") +
                  ((sPath)    ? "; path="    + sPath                    : "") +
                  ((sDomain)  ? "; domain="  + sDomain                  : "") +
                  ((bSecure)  ? "; secure"                              : "");
                  
      document.cookie = sCookie;
}

//------------------------------------------------------------------------------------------ getCookie
function getCookie(sName) 
{
    if (!navigator.cookieEnabled) return '';
    
    var sCookie = document.cookie;
    var sIdent  = sName + "=";
    var nStart  = sCookie.indexOf("; " + sIdent);

    if (nStart == -1) 
    {
        nStart = sCookie.indexOf(sIdent);
        if (nStart != 0) 
            return '';
    } else
    {
        nStart += 2;
    }
    var nStop = document.cookie.indexOf(";", nStart);
    if (nStop == -1)
        nStop = sCookie.length;
    return unescape(sCookie.substring(nStart + sIdent.length, nStop));
}

//------------------------------------------------------------------------------------------ deleteCookie
function deleteCookie(sName, sPath, sDomain)
{
    if (!navigator.cookieEnabled) return;
    
    if (getCookie(sName)) 
    {
        document.cookie = name + "=" +
                        ((sPath)   ? "; path="   + sPath   : "") +
                        ((sDomain) ? "; domain=" + sDomain : "") +
                        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

