﻿<!-- //
function SetCookieValue(strName, strKey, strValue, strPath, dtExpiry)
    {    
    var strCookie = "";
    if(strKey.length > 0)
        {
        strCookie = GetCookieValue(strName, "");
        if(strCookie.length > 0)
            {
            var nStart = strCookie.indexOf(strKey + "=");
            if(nStart != -1)
                {
                nStart += (strKey.length + 1);
                var nEnd = strCookie.indexOf("&", nStart);
                if(nEnd == -1) nEnd = strCookie.length;
                if(nEnd != -1)
                    {
                    var strStart = strCookie.slice(0, nStart);
                    var strEnd = strCookie.slice(nEnd, strCookie.length);
                    strCookie = strStart + escape(strValue) + strEnd;
                    }
                }
            else
                strCookie += "&" + strKey + "=" + escape(strValue);
            }
        else
            strCookie = strKey + "=" + escape(strValue);
        }
    else
        strCookie = escape(strValue);
        
    document.cookie = strName + "=" + strCookie +
    ((dtExpiry.length > 0) ? "; expires=" + new Date(dtExpiry).toGMTString() : "") +
    ((strPath.length > 0) ? "; path=" + strPath : "");
    }
    
function GetCookieValue(strName, strKey)
    {
    var nCookieOffset = 1;
    var nStart = document.cookie.indexOf(" " + strName + "=");
    if(nStart == -1) 
        {
        nCookieOffset = 0;
        nStart = document.cookie.indexOf(strName + "=");
        }
        
    if(nStart != -1)
        {
        nStart += (strName.length + 1 + nCookieOffset);
        var nEnd = document.cookie.indexOf(";", nStart)
        if(nEnd == -1) nEnd = document.cookie.length;
        var strCookie = unescape(document.cookie.substring(nStart, nEnd));
        if(strKey.length > 0)
            {
            var astrCookies = strCookie.split("&");
            var nIndex;
            for(nIndex = 0; nIndex < astrCookies.length; nIndex++)
                {
                nStart = astrCookies[nIndex].indexOf(strKey + "=");
                if(nStart != -1)
                    {
                    nStart += (strKey.length + 1);
                    nEnd = astrCookies[nIndex].length;
                    strCookie = astrCookies[nIndex].substring(nStart, nEnd);
                    return strCookie;
                    }
                }
                
            return "";
            }
        else
            return strCookie;
        }
        
    return "";
    }
    
function IsCookiesValid(bAlert)
    {
    var dtNow = new Date();
    dtNow.setMinutes(dtNow.getMinutes() + 5);
    SetCookieValue("TEST", "", "Yes", "/", dtNow.toGMTString());
    if(GetCookieValue("TEST", "") == null)
        {
        if(bAlert) alert(g_strErrorCookiesDisabled);
        return false;
        }
    return true;
    }
// -->