
var timeZeroVB = -2209161600*1000; //Date.UTC(1899,11,30); //30.12.1899 00:00:00
var timeZeroJS = 0; //Date.UTC(1970,0,1); //01.01.1970 00:00:00
var timeResponseCookieExpiresMin = 315532800*1000; //Date.UTC(1980,0,1); //01.01.1980 00:00:00
var timeResponseCookieExpiresMax = 2147483647*1000; //(Math.pow(2,31)-1)*1000; //Date.UTC(2038,0,19,3,14,7); 19.01.2038 03:14:07

/**
 * Read the JavaScript cookies tutorial at:
 *   http://www.netspade.com/articles/javascript/cookies.xml
 */

/**
 * Set a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie = escape(name).replace("_", "%5F") + "=" + escape(value).replace(" ", "+") +
        ((expires!=null) ? "; expires=" + expires.toGMTString() : "") +
        ((path!=null) ? "; path=" + path : "") +
        ((domain!=null) ? "; domain=" + domain : "") +
        ((secure!=null) ? "; " + (secure ? "secure" : "") : "");
}

/**
 * Get the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or undefined if cookie does not exist.
 */
function getCookie(name, default_value)
{
    var cookies1 = (";" + document.cookie + ";").replace(/; /g, ";");
//alert(cookies1);
    var name1 = ";" + escape(name).replace("_", "%5F") + "=";
alert(name1);
    var begin1 = cookies1.indexOf(name1);
    if(begin1 < 0) return default_value;
    var end1 = cookies1.indexOf(";", begin1 + name1.length);
    return unescape(cookies1.substring(begin1 + name1.length, end1).replace("+", " "));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function delCookie(name, path, domain)
{
//    if (getCookie(name))
//    {
//        document.cookie = name + "=" + 
//            ((path) ? "; path=" + path : "") +
//            ((domain) ? "; domain=" + domain : "") +
//            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
//    }
	setCookie(name, "", new Date(1000), path, domain);
}

function setRootCookie(name, value, expires)
{
	setCookie(name, value, expires!=null?exires:new Date(timeResponseCookieExpiresMax-86400*1000), "/");
}

function delRootCookie(name)
{
	delCookie(name, "/");
}

function setTempCookie(name, value)
{
	setCookie(name, value, undefined, "/");
}

