// Function to create a cookie and set its value
function setCookie(name, value, expires) {
    document.cookie = escape(name) + "=" + escape(value) + "; path=/" + 
        ((expires == null) ? "" : "; expires=" + expires.toGMTString(  ));
}

// Function to retrieve a cookie's value
function getCookie(name) {
    var cookiename = name + "=";
    var dc = document.cookie;
    var begin, end;

    if (dc.length > 0) {
        begin = dc.indexOf(cookiename);
        if (begin != -1) {
            begin += cookiename.length;
            end = dc.indexOf(";", begin);
            if (end == -1) {
                end = dc.length;
            }
            return unescape(dc.substring(begin, end));
        } 
    }
    return null;
}

// Function to delete a cookie
function deleteCookie(name) {
    document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" +  
        "; path=/";
}
