function getExpire(curDays) {
    var toExpire = new Date();
    toExpire.setTime(toExpire.getTime() + (1000 * 60 * 60 * 24 * curDays));
    return toExpire;
}


function getCookie(theName) {
    theName = theName + "=";
    theCookie = document.cookie;
    if (theCookie.length > 0) {
        startString = theCookie.indexOf(theName);
        if (startString != -1) {
            startString += theName.length;
            endString = theCookie.indexOf(";", startString);
            if (endString == -1) endString = theCookie.length;
            theValue = theCookie.substring(startString, endString);
            theValue = unescape(theValue);
            return theValue;
        }
    }
    return null;
}

function setCookie(theName, thePath, curDays, theValue) {
    theName = theName + "=";
    theValue = escape(theValue) + ";";
    thePath = " path=" + thePath + ";";
    toExpire = getExpire(curDays);
    toExpire = " expires=" + toExpire.toGMTString();
    cookieValue = theName + theValue + thePath + toExpire;
    document.cookie = cookieValue;
}
