function CookieHandler() {
    this.GetCookieObject = function () {
        var arr = document.cookie.split(";");
        for (var i = 0; i < arr.length; i++) {
            name = arr[i].split('=')[0];
            value = arr[i].split('=')[1];
            if (i > 0)
                name = name.substring(1);
            this[name] = this.Get(name);
        }
    }
    this.Get = function (c_name) {
        if (document.cookie.length > 0) {
            c_start = document.cookie.indexOf(c_name + "=");
            if (c_start != -1) {
                c_start = c_start + c_name.length + 1;
                c_end = document.cookie.indexOf(";", c_start);
                if (c_end == -1) c_end = document.cookie.length;
                return unescape(document.cookie.substring(c_start, c_end));
            }
        }
        return null;
    }

    this.Set = function (c_name, value, expiredays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        //alert("'" + c_name + "'='" + value + "'");
        document.cookie = c_name + "=" + escape(value) +
        ((expiredays == null) ? "" : ";expires=" + exdate.toUTCString());
        this[c_name] = value;
    }
    this.GetCookieObject();
}

CookieHandler.prototype = new Object;

var Cookie = new CookieHandler();
