function setCookie(name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var ck = document.cookie;
    var index = ck.indexOf(name + "=");
    if (index == -1) return null;
    index = ck.indexOf("=", index) + 1; // first character
    var endstr = ck.indexOf(";", index);
    if (endstr == -1) endstr = ck.length; // last character
    return unescape(ck.substring(index, endstr));
}

// sets cookie if it doesn't already exist
function initCookie() {
    var cookieName = "cookie";
    if (getCookie(cookieName) == null)
	setCookie(cookieName, "set", "", "/");
}
