function setCookie(cookieName, cookieValue, expireDays) {
    var expitryDate = new Date();
    expitryDate.setDate(expitryDate.getDate() + expireDays);
    document.cookie = cookieName + "=" + escape(cookieValue) + ((expireDays == null) ? "" : ";expires=" + expitryDate.toGMTString());
}

function getCookie(cookieName) {
    if (document.cookie.length > 0) {
        cookieStartIndex = document.cookie.indexOf(cookieName + "=");
        if (cookieName != -1) {
            cookieStartIndex = cookieStartIndex + cookieName.length + 1;
            cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex);
            if (cookieEndIndex == -1)
                cookieEndIndex = document.cookie.length;
            return unescape(document.cookie.substring(cookieStartIndex, cookieEndIndex));
        }
    }
    return null;
}
