var _COOKIE_JS_ = true;
var _TIMEZONETOOLS_JS_;

function cookiesEnabled(nonSession){
setCookie("testcookie", "testvalue", nonSession ? new Date(new Date().getTime() + 60) : null);
if(getCookie("testcookie") == null) return false;
deleteCookie("testcookie");
return true;
}

function getCookieNames(){
var out = new Array(), c = parseCookies(), i;
for(i in c)
out[i] = i;
return out;
}

function getCookie (name) {
return parseCookies()[name];
}

function setCookie (name,value,expires,path,domain,secure) {
COOKIE_MAP = null;
if(path == null) path = "/";
if(domain == null){
domain = getCurrentDomain();
}
document.cookie = escape(name) + "=" + escape(value) +
((expires) ? ";expires=" + fixCookieDate(expires).toGMTString() : "") +
((path) ? ";path=" + path : "") +
((domain) ? ";domain=" + domain : "") +
((secure) ? ";secure" : "");
}

function deleteCookie (name,path,domain,secure) {
if (getCookieNames()[name]) {
setCookie(name, getCookie(name), document.all ? new Date(0) : new Date(), path, domain, secure);
if(getCookie(name) != null && domain == null){
deleteCookie(name, null, getTopDomain());
}
}
}

var COOKIE_MAP;
function parseCookies(){
if(COOKIE_MAP != null) return COOKIE_MAP;
var out = new Array(), c = document.cookie;
if(c != null && c != ""){
var clen = c.length, i = 0;
do {
var end = c.indexOf("; ", i);
if(end == -1) end = clen;
var eq = c.indexOf("=", i);
if(eq == -1 || eq > end) eq = end;
out[unescape(c.substring(i, eq))] = (eq == end) ? "" : unescape(c.substring(eq + 1, end))
i = end + 2;
} while(i < clen);
}
COOKIE_MAP = out;
return out;
}

function getCurrentDomain(){
var l = window.location.href;
var start = l.indexOf("//") + 2;
var endColon = l.indexOf(":", start);
var endSlash = l.indexOf("/", start);
if(endColon == -1) endColon = l.length;
if(endSlash == -1) endSlash = l.length;
return l.substring(start, (endColon < endSlash) ? endColon : endSlash);
}
function getTopDomain(){
var d = getCurrentDomain();
return d.substring(d.lastIndexOf(".", d.lastIndexOf(".") - 1));
}

function fixCookieDate (date) {
var base = new Date(0);
var skew = base.getTime(); // dawn of (Unix) time - should be 0
if (skew > 0)  // Except on the Mac - ahead of its time
date.setTime (date.getTime() - skew);
return date;
}

if(_TIMEZONETOOLS_JS_ == true)
setTimeZoneCookie();
var _SR_;
if(_SR_ != null) _SR_.notify("cookie.js");