/**********************************
 * 西门编写的操作的js类XCookie（Beat1.0）
 * 没什么特色，就是能很好的兼容FF
 * 完成时间：2008-02-20 16:00
 * 版权所有：AJAX中国
 * 网址：http://okajax.com
 * E-mail:westdoorking@163.com
 * 备注：您可以免费使用XCookie类，但是请不要删除版权信息。
 * 如果本类给您的网站造成bug，或者引起不良后果，作者不负任何责任。
 **********************************/
var XCookie = function(){
    this.setCookie = function(name, value, expires, path, domain){
        expires = new Date(new Date().getTime() + (((typeof expires == "undefined") ? 35600 * 3600 * 24 : expires)) * 1000);
        var tempcookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "; path=/") +
        ((domain) ? "; domain=" + domain : "");
        (tempcookie.length < 4096) ? document.cookie = tempcookie : alert("The cookie is bigger than cookie lagrest");
    }
    this.getCookie = function(name){
        var xarr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
        if (xarr != null) 
            return unescape(xarr[2]);
        return null;
    }
    this.delCookie = function(name, path, domain){
        if (this.getCookie(name)) 
            document.cookie = name + "=" +
            ((path) ? "; path=" + path : "; path=/") +
            ((domain) ? "; domain=" + domain : "") +
            ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
    }
    this.day = function(xd){
        return xd * 24 * 3600;
    }
    this.hour = function(xh){
        return xh * 3600;
    }
}
