function SNDABackPop() {
    this.PopUrl = '';
    this.PopTimeSpan = 1;
    this.GlobalePopTimeSpan = 15;
	this.GlobalPopKey = 'globlepopts';
    this.PopWindowWidth = '0';
    this.PopWindowHeight = '0';
    this.PopKeyName = '';
    this.PopType = 1;
    this.JsString = 'toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes';
    this.exp = new Date();
	this.GloblePopSpanTime = new Date();
};
SNDABackPop.prototype.Initialize = function(PopUrl, PopTimeSpan, PopWindowWidth, PopWindowHeight, PopKeyName, PopType, JsString) {
    this.PopUrl = PopUrl;
    this.PopTimeSpan = PopTimeSpan;
    this.PopWindowWidth = PopWindowWidth;
    this.PopWindowHeight = PopWindowHeight;
    this.PopKeyName = PopKeyName;
    this.PopType = PopType;
    this.JsString = JsString;
    this.exp.setTime(this.exp.getTime() + (this.PopTimeSpan * 60 * 1000))
	this.GloblePopSpanTime.setTime(this.GloblePopSpanTime.getTime()+ this.GlobalePopTimeSpan * 60 * 1000)
	
};
SNDABackPop.prototype.GetCookie = function(name) {
    var arg = name + '=';
    var alen = arg.length;
    var clen = document.cookie.length,
    i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) return this.getCookieVal(j);
        i = document.cookie.indexOf(' ', i) + 1;
        if (i == 0) break
    };
    return null
};
SNDABackPop.prototype.getCookieVal = function(offset) {
    var endstr = document.cookie.indexOf(';', offset);
    if (endstr == -1) endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr))
};
SNDABackPop.prototype.SetCookie = function(name, value) {
    var argv = this.SetCookie.arguments;
    var argc = this.SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + '=' + escape(value) + ((expires == null) ? '': ('; expires=' + expires.toGMTString())) + ((path == null) ? '': ('; path=' + path)) + ((domain == null) ? '': ('; domain=' + domain)) + ((secure == true) ? '; secure': '')
};
SNDABackPop.prototype.DeleteCookie = function(name) {
    var exp = new Date(),
    cval = 0;
    exp.setTime(exp.getTime() - 1);
    document.cookie = name + '=' + cval + '; expires=' + exp.toGMTString()
};
SNDABackPop.prototype.Pop = function() {
 
    if (document.referrer.indexOf('http://hao.360.cn') > -1) {
        return;
    }
    if (document.referrer.indexOf('http://i.maxthon.cn/index.v3.htm') > -1) {
        return;
    }

    if (this.GetCookie(this.PopKeyName) == null && this.GetCookie(this.GlobalPopKey) == null) {
        this.SetCookie(this.PopKeyName, 1, this.exp, '/', document.domain);
        this.SetCookie(this.GlobalPopKey, 1, this.GloblePopSpanTime, '/', document.domain);
        this.paypopup()

    }
};
SNDABackPop.prototype.paypopup = function() {
    popwin = window.open(this.PopUrl, 'newWindow', (this.PopWindowWidth > 0 ? 'width=' + this.PopWindowWidth: '') + ',' + (this.PopWindowHeight > 0 ? 'height=' + this.PopWindowHeight: '') + ',' + this.JsString);
    if (popwin) poped = true;
    if (this.PopType == 1) self.focus()
}; 
