// $Id: $
//
// Taken from http://www.jibbering.com/faq/faq_notes/cookies.html, edited slightly to remove syntax error

function Get_Cookie(name) {
    if(typeof document.cookie == "string"){
        var start = document.cookie.indexOf(name+"=");
        var len = start+name.length+1;
        if ((!start)&&
            (name != document.cookie.substring(0,name.length))){
               return null;
           }
        if (start == -1) return null;
        var end = document.cookie.indexOf(";",len);
        if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(len,end));
    }else{
        /* document.cookie is not a string so return an
           empty string. When tested this will type-convert to
           boolean false (accurately) giving the impression that
           client-side cookies are not available on this system:-
        */
        return "";
    }
}

function Set_Cookie(name,value,expires,path,domain,secure) {
    if(typeof document.cookie == "string"){
        document.cookie = name + "=" +escape(value) +
            ( (expires) ? ";expires=" + expires.toGMTString() : "") +
            ( (path) ? ";path=" + path : "") +
            ( (domain) ? ";domain=" + domain : "") +
            ( (secure) ? ";secure" : "");
    }//else document.cookie is not a string so do not write to it.
}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}
