common.js

/*
* 变量
*/
var G = {
	baseUrl: "",
	debug: "debug",             //调试logger组件	
	browser: {},                //浏览器
	platform: {},               //操作系统
	errors: {                   //错误提醒
		"-1": "undefined error"
	},

	errorHandlers: {},          //colorbox_up start
    analysis: true,             
	loadedScripts: {},
	ajaxLoadReturn: {},
	eventDepends: {},
	eventDependsParams: {},
	eventDependsTrigger: {},
	eventDependsHandlerMapping: {},
	eventDependsHandler: {},    //colorbox_up end

	tmp: {},                    //临时对象
	userinfo: {},               //用户信息
	leheButtons: {}             //页面按钮
};
/*
* 常量
*/
var C = {
	AJAX: {
		SUCCESS: 0
	},
	WEEKDAY: ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
	ERROR: {
		UNLOGIN: "0x3000001",   //内存问题(可能超频过了或者同步出错)
		UNREGISTER: "0x3000002"
	},
	EVENT: {
		LOGIN_INIT_NOT: "login_init_not",
		LOGIN_INIT_COMPLETE: "login_init_complete",
		LOGIN_SUCCESS: "login_success",
		PHASE_CURRENT_LOAD: "phase_current_load",
		BET_COMBO_SUCCESS: "bet_combo_success",
		BET_NORMAL_SUCCESS: "bet_normal_success",
		BET_SYNDICATE_SUCCESS: "bet_syndicate_success",
		BET_FOLLOW_SUCCESS: "bet_follow_success",
		BET_CHASE_SUCCESS: "bet_chase_success"
	},
	NAMESPACE: {
		DEFAULT: "default",
		CHATROOM: "chatroom",
		LOTTERY_BET: "lottery_bet",
		GAME: "game"
	},
	WALLET: {
		"1": "现金账户",
		"2": "彩金账户",
		"30": "测试账户",
		"50": "套餐账户",
		"101": "足球单场账户",
		"102": "竞彩篮球账户",
		"104": "快乐十分账户",
		"105": "竞技彩账户"
	},
	WALLET_ORDER: ["1", "2", "50", "101", "102", "104", "30"],
	WALLET_DEFAULT: {
		CASH: "1",
		GIFT: "2"
	},
	COOKIE_USERINFO: "lehecai_request_control_userinfo",
	COOKIE_USERSTATS: "lehecai_request_control_stats",
	COOKIE_TWODIMENSIONAL: "lehecai_two_dimensional_closed",
	FOOTBALL_DATA_TYPE: {
		ANALYSIS: "analysis",
		ODDS_ASIAN: "oddsAsian",
		ODDS_EURO: "oddsEuro"
	},
	BASKETBALL_DATA_TYPE: {
		ANALYSIS: "analysis",
		LET_GOAL: "letGoal",
		ODDS_EURO: "europeOdds"
	},
	CAPTCHA_LENGTH: 4
};
/*
* 获取客户端的浏览器信息
*/
(function() {
	G.browser.version = jQuery.browser.version;
	G.browser.msie = !!jQuery.browser.msie;
	G.browser.mozilla = !!jQuery.browser.mozilla;
	G.browser.opera = !!jQuery.browser.opera;
	G.browser.webkit = !!jQuery.browser.webkit;
	if (G.browser.msie && parseInt(G.browser.version, 10) == 6) {
		try {
			document.execCommand("BackgroundImageCache", false, true)
		} catch(a) {}
	}
})(); 
/*
* 获取客户端的操作系统
*/
(function() {
	if (typeof(navigator.platform) == "undefined") { 
		G.platform.unknown = true
	} else {
		var c = [{
			string: navigator.platform,
			subString: "Win",
			identity: "windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "linux"
		}];
		for (var a = 0; a < c.length; a++) {
			var b = c[a].string;
			if (b) {
				if (b.indexOf(c[a].subString) != -1) {
					G.platform[c[a].identity] = true
				}
			}
		}
	}
	G.platform.unkown = !!G.platform.unkown;
	G.platform.windows = !!G.platform.windows;
	G.platform.mac = !!G.platform.mac;
	G.platform.linux = !!G.platform.linux
})();

/*
* logger类
* 1)、logger.info(msg)
* 2)、logger.debug(msg);
* 3)、logger.error(a, msg);

* js调试logger组件,使用如下:
* logger.error(a, "CountdownTimer callback error!");
*/
if (typeof(logger) == "undefined") {
	var logger = {}
} 
(function() {
	logger._enable = typeof(console) != "undefined" && typeof(console.log) != "undefined";
	if (logger._enable) {
		if (typeof(console.log) == "function") {
			logger._log = function() {
				try {
					console.log.apply(console, arguments)
				} catch(d) {}
			}
		} else {
			if (typeof(console.log) == "object") {
				logger._log = function() {
					try {
						console.log(Array.prototype.slice.call(arguments))
					} catch(d) {}
				}
			} else {
				logger._log = function() {} ()
			}
		}
	} else {
		logger._log = function() {}
	}
	var b = {
		none: 0,
		debug: 1,
		info: 2,
		warn: 3,
		error: 4
	};
	var c = b[G.debug];
	if (typeof(c) == "undefined") {
		c = 0
	}
	for (var a in b) {
		if (c > 0) {
			if (b[a] > 0) {
				if (b[a] >= c) {
					logger[a] = function() {
						logger._log.apply(logger, arguments)
					}
				} else {
					logger[a] = function() {}
				}
			}
		} else {
			logger[a] = function() {}
		}
	}
})(); 
/*
*数字扩展类
*/
(function() {
	var b = window.parseInt;
	window.parseInt = function() {
		if (arguments.length == 1) {
			return b(arguments[0], 10)
		}
		return b.apply(null, arguments)
	};
	var a = window.parseFloat;
	window.parseFloat = function() {
		if (arguments.length == 1) {
			return a(arguments[0], 10)
		}
		return a.apply(null, arguments)
	}
})();
/*
*字符扩展类
*使用示例如下
*var s = String.format("S{0}T{1}","n","e");//结果:SnTe
*/
String.format = function() {
	var c = arguments[0];
	for (var a = 0; a < arguments.length - 1; a++) {
		var b = new RegExp("\{" + a + "\}", "gm");
		c = c.replace(b, arguments[a + 1])
	}
	return c
};
/*
var osb = new StringBuffer("Sn");
var str = osb.append("Te");//结果:SnTe
*/
function StringBuffer(a) {
	this._strings = new Array();
	this.append(a)
}
StringBuffer.prototype.append = function(a) {
	this._strings.push(a);
	return this
};
StringBuffer.prototype.toString = function() {
	var a = (arguments.length == 0) ? "": arguments[0];
	return this._strings.join(a)
}; 
/*
*字符填充类(长度小于,字符填充)
*调用实例
*var s = "471812366";
*s.leftpad(10, '00');    //结果:00471812366
*s.rightpad(10, '00');   //结果:47181236600
*左填充
*/
String.prototype.leftpad = function(b, f) {
	if (arguments.length == 1) {
		f = "0"
	}
	var e = new StringBuffer();
	for (var d = 0,
	a = b - this.length; d < a; d++) {
		e.append(f)
	}
	e.append(this);
	return e.toString()
};
//右填充
String.prototype.rightpad = function(b, f) {
	if (arguments.length == 1) {
		f = "0"
	}
	var e = new StringBuffer();
	e.append(this);
	for (var d = 0,
	a = b - this.length; d < a; d++) {
		e.append(f)
	}
	return e.toString()
};
/*
* 事件监听类
*/
function ClickHandler(a) {
	a = jQuery.extend({ //与jQuery事件合并
		clickable: undefined,
		click: function() {},
		disable: true
	},
	a);
	if (typeof(a.clickable) == "undefined" || typeof(a.click) != "function") {
		return
	}
	this.clickable = a.clickable;
	this.click = a.click;
	this.disable = !!a.disable;
	this.init()
}
//初始状态
ClickHandler.prototype.init = function() {
	var a = this;
	this.clickable.bind("click",
	function() {
		if (a.disable) {
			a.clickable.unbind()
		}
		a.click(a)
	})
};
//取消绑定
ClickHandler.prototype.disable = function() {
	this.clickable.unbind()
};
//返回初始状态绑定
ClickHandler.prototype.reset = function() {
	this.init()
};
/*
项目类,使用示例
var c = new LHC.URLParser(window.location.href);
var a = new LHC.QueryStringParser(c.getQueryString());
var b = a.get("default_float");
*/
var LHC = {};
LHC.getURLPlan;
LHC.Formatter = {
	formatInt: function(b, c) {
		if (typeof(c) == "undefined") {
			c = 0
		}
		var a = parseInt(b, 10);
		if (isNaN(a)) {
			a = c
		}
		return a
	}
};
(function() {
	var a = function() {
		var d, e = {},
		b;
		d = window.location.hash.replace(/^#/, "");
		if (d == "") {
			this.uhash = {}
		} else {
			d = d.split("|");
			for (var c = 0; c < d.length; c++) {
				b = d[c].split("=");
				e[b[0]] = b[1]
			}
			this.uhash = e
		}
	};
	a.prototype.set = function(e) {
		var d = [];
		if (arguments.length == 1 && /Object/.test(Object.prototype.toString.call(e))) {
			for (var c in e) {
				if (e.hasOwnProperty(c)) {
					this.uhash[c] = e[c]
				}
			}
			for (var b in this.uhash) {
				d.push(b + "=" + this.uhash[b])
			}
			window.location.hash = d.join("|")
		} else {
			logger.info("设置hash的参数不正确")
		}
	};
	a.prototype.get = function(b) {
		if (arguments.length == 1) {
			return this.uhash[b]
		} else {
			return this.uhash
		}
	};
	LHC.URLHash = new a()
})();
LHC.URLParser = function(a) {
	this._fields = {
		Username: 4,
		Password: 5,
		Port: 7,
		Protocol: 2,
		Host: 6,
		Path: 8,
		URL: 0,
		QueryString: 9,
		Fragment: 10
	};
	this._values = {};
	this._regex = null;
	this.version = 0.1;
	this._regex = /^((w+)://)?((w+):?(w+)?@)?([^/?:]+):?(d+)?(/?[^?#]+)???([^#]+)?#?(w*)/;
	for (var b in this._fields) {
		this["get" + b] = this._makeGetter(b)
	}
	if (typeof a != "undefined") {
		this._parse(a)
	}
};
LHC.URLParser.prototype.setURL = function(a) {
	this._parse(a)
};
LHC.URLParser.prototype._initValues = function() {
	for (var a in this._fields) {
		this._values[a] = ""
	}
};
LHC.URLParser.prototype._parse = function(a) {
	this._initValues();
	var b = this._regex.exec(a);
	if (!b) {
		throw "DPURLParser::_parse -> Invalid URL"
	}
	for (var c in this._fields) {
		if (typeof b[this._fields[c]] != "undefined") {
			this._values[c] = b[this._fields[c]]
		}
	}
};
LHC.URLParser.prototype._makeGetter = function(a) {
	return function() {
		return this._values[a]
	}
};
LHC.QueryStringParser = function(d) {
	var c = d.split("&");
	this.params = {};
	for (var b = 0,
	a = c.length; b < a; b++) {
		var e = c[b].split("=");
		if (e.length != 2) {
			continue
		}
		this.params[e[0]] = e[1]
	}
};
LHC.QueryStringParser.prototype.get = function(a) {
	return this.params[a]
};
//普通链接
LHC.LinkGenerator = {
	footballData: function(a, b) {
		a = parseInt(a);
		if (a == 0 || isNaN(a)) {
			return false
		}
		if (typeof(b) == "undefined") {
			b = C.FOOTBALL_DATA_TYPE.ANALYSIS
		}
		return G.baseDataUrl + "/football/match/" + b + "/?id=" + a
	},
	basketballData: function(a, b) {
		a = parseInt(a);
		if (a == 0 || isNaN(a)) {
			return false
		}
		if (typeof(b) == "undefined") {
			b = C.BASKETBALL_DATA_TYPE.ANALYSIS
		}
		return G.baseDataUrl + "/basketball/schedule/" + b + "/?id=" + a
	}
};
jQuery(document).ready(function() {
	var c = new LHC.URLParser(window.location.href);
	var a = new LHC.QueryStringParser(c.getQueryString());
	var b = a.get("default_float");
	if (typeof(b) == "string") {
		if (b == "register") {
			jQuery.executeErrorHandler(C.ERROR.UNREGISTER)
		}
	}
});
//倒计时功能的实现(CountDownTimer)
function CountdownTimer(b) {
	var a = {
		startTime: new Date(),
		endTime: new Date(),
		callback: undefined,
		endCallback: undefined
	};
	this.settings = jQuery.extend(a, b);
	this.startTime = this.settings.startTime;
	this.endTime = this.settings.endTime;
	this.callback = this.settings.callback;
	this.endCallback = this.settings.endCallback;
	this.running = false;
	this.intervalTimer = undefined
}
CountdownTimer.prototype.run = function() {
	this.running = true;
	var e = e || this.endTime.getTime();
	var d = d || this.startTime.getTime();
	var a = this.callback;
	var b = new Date();
	if (e <= d) {
		this.stop();
		if (a) {
			a({
				d: 0,
				h: 0,
				m: 0,
				s: 0
			})
		}
		return {
			d: 0,
			h: 0,
			m: 0,
			s: 0
		}
	}
	var c = this;
	var f = e - d;
	this.intervalTimer = setInterval(function() {
		var l = e - d;
		d += 1000;
		var i = new Date().valueOf() - b.valueOf() - 1000;
		var n = f - l;
		if (Math.abs(i - n) > 1000) {
			l = f - i
		}
		if (l <= 0) {
			c.stop.apply(c);
			if (a) {
				a({
					d: 0,
					h: 0,
					m: 0,
					s: 0
				})
			}
			return {
				d: 0,
				h: 0,
				m: 0,
				s: 0
			}
		}
		var o = parseInt(l / 86400000, 10);
		var k = parseInt(l % 86400000 / 3600000, 10);
		var g = parseInt(l % 86400000 % 3600000 / 60000, 10);
		var j = parseInt(l % 86400000 % 3600000 % 60000 / 1000, 10);
		if (a) {
			a({
				d: o,
				h: k,
				m: g,
				s: j
			})
		}
	},
	1000)
};
CountdownTimer.prototype.clear = function() {
	if (this.intervalTimer) {
		clearInterval(this.intervalTimer);
		this.intervalTimer = undefined
	}
	this.running = false
};
CountdownTimer.prototype.stop = function() {
	logger.debug("stop event fired");
	this.clear();
	if (this.endCallback) {
		this.endCallback()
	}
};
/*
* 为所有链接设置统一属性 'a[href*="redirect.lehecai.com"]'
*/
jQuery(function() {
	jQuery('a[href*="redirect.lehecai.com"]').each(function(d, c) {
		var c = jQuery(c),
		f = c.attr("href"),
		e = [];
		e = f.match(/^(.+?)(#.+)$/);
		var g = encodeURIComponent(location.href);
		if (/?/.test(f)) {
			if (e === null) {
				f += "&REF=" + g
			} else {
				f = e[1] + "&REF=" + g + e[2]
			}
		} else {
			if (e === null) {
				f += "?REF=" + g
			} else {
				f = e[1] + "?REF=" + g + e[2]
			}
		}
		c.attr("href", f)
	})
});
/*
* scroll事件
*/
function Scroll(w) {
	var a = {
		element: undefined,
		style: "v",
		 0,
		height: 0,
		scrollHeight: 0,
		innerWidth: 0,
		delay: 120,
		speed: 1,
		callback: undefined
	};
	var p = this;
	var u = jQuery.extend(a, w);
	if (!u.element) {
		return false
	}
	var h = u.element;
	var k = u.style;
	var x = u.delay;
	if (k == "h" && typeof(w.delay) == "undefined") {
		x = 1
	}
	var t;
	if (k == "h" && x == 1) {
		t = 1200
	} else {
		t = u.startDelay || x * u.speed * 10
	}
	var i, n;
	if (k == "h") {
		if (u.width) {
			i = u.width
		} else {
			i = h.offsetWidth
		}
		n = u.innerWidth || i
	}
	var s = u.scrollHeight || u.height;
	var j = false;
	var e = 0;
	var b = undefined;
	var f = 0;
	var o = 0;
	if (i) {
		h.style.width = i + "px"
	}
	h.style.height = u.height + "px";
	h.style.overflow = "hidden";
	h.noWrap = true;
	h.scrollLeft = 0;
	h.scrollTop = 0;
	var l, v, y, d;
	l = h.getElementsByTagName("div");
	if (l && l.length > 0) {
		l = l[0]
	} else {
		return false
	}
	var r = function(z) {
		if (z) {
			return z.cloneNode(true)
		}
		return null
	};
	h.onmouseover = function() {
		if (j) {
			j = false
		}
	};
	h.onmouseout = function() {
		if (!j) {
			j = true
		}
	};
	var q = {
		v: function() {
			v = r(l);
			h.appendChild(v)
		},
		h: function() {
			var A = l.getElementsByTagName("span");
			for (var z = 0; z < A.length; z++) {
				var D = A[z];
				D.style.width = n + "px";
				D.style.height = s + "px"
			}
			d = n * (A.length);
			if (A && A[0]) {
				var B = A[0]
			}
			l.innerHTML += l.innerHTML
		}
	};
	var g = {
		v: function() {
			f = 0;
			e = 0;
			h.scrollTop = 0;
			j = false
		},
		h: function() {
			o = 0;
			e = 0;
			h.scorllLeft = 0;
			j = false
		}
	};
	var c = {
		v: function() {
			if (!j) {
				return false
			}
			f++;
			if (f == s + 1) {
				e++;
				f--;
				if (e == x) {
					f = 0;
					e = 0
				}
			} else {
				if (v.offsetHeight - h.scrollTop <= 0) {
					h.scrollTop -= l.offsetHeight;
					h.scrollTop++
				} else {
					h.scrollTop++
				}
			}
		},
		h: function() {
			if (!j) {
				return false
			}
			o++;
			if (o == n + 1) {
				e++;
				o--;
				if (e == x) {
					o = 0;
					e = 0
				}
			} else {
				if (d - h.scrollLeft <= 0) {
					h.scrollLeft = 0 - i;
					h.scrollLeft++
				} else {
					h.scrollLeft++
				}
			}
		}
	};
	this.start = function() {
		if (j) {
			return false
		}
		if (k === "v" && jQuery(h).children(":first").height() < jQuery(h).height()) {
			return false
		}
		if (k === "h") {
			jQuery(l).find("span").css({
				 n,
				display: "inline-block"
			});
			var z = n * l.getElementsByTagName("span").length;
			if (z < jQuery(h).width()) {
				return false
			} else {
				jQuery(l).css("width", 2 * z)
			}
		}
		q[k]();
		var B = u.speed * 10;
		var A = function() {
			if (b) {
				clearTimeout(b)
			}
			c[k]();
			b = setTimeout(A, B)
		};
		A();
		j = true
	};
	this.isStarted = function() {
		return j
	};
	this.restart = function() {
		g[k]();
		p.start()
	}
} 
/*
* js模拟php的shuffle函数,用来打乱一维数组并返回随机数
* 调用方式,如:$.shuffle({count:10,min:0,max:10})
*/
(function(a) {
	a.shuffle = function(h) {
		var g = a.extend({  //合并参数
			pool: undefined,//设为空类型
			min: 1,         //最小数值
			max: 10,        //最大数值
			count: 5,       //返回随机数的个数
			padding: 0,     //填充数
			sort: false     //排序
		},
		h);
		if (g.max < g.count) {
			return []
		}
		var f;
		if (g.pool) {
			f = g.pool
		} else {
			f = [];
			for (var e = g.min; e <= g.max; e++) {
				f.push(e)
			}
		}
		var b = [];
		var e = 0;
		while (e < g.count) {
			var c = parseInt((f.length - e) * Math.random(), 10);
			if (g.padding > 0) {
				b.push(f[c].toString().leftpad(g.padding))
			} else {
				b.push(f[c])
			}
			e++;
			var d = f[c];
			f[c] = f[f.length - e];
			f[f.length - e] = d
		}
		if (g.sort) {
			b = b.sort(function(j, i) {
				return parseInt(j, 10) - parseInt(i, 10)
			})
		}
		return b
	}
})(jQuery); 
/*
* hoverIntent点击延时jquery插件
* http://cherne.net/brian/resources/jquery.hoverIntent.html
*/
(function(a) {
	a.fn.hoverIntent = function(k, j) {
		var l = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		l = a.extend(l, j ? {
			over: k,
			out: j
		}: k);
		var o, n, h, d;
		var e = function(f) {
			o = f.pageX;
			n = f.pageY
		};
		var c = function(g, f) {
			f.hoverIntent_t = clearTimeout(f.hoverIntent_t);
			if ((Math.abs(h - o) + Math.abs(d - n)) < l.sensitivity) {
				a(f).unbind("mousemove", e);
				f.hoverIntent_s = 1;
				return l.over.apply(f, [g])
			} else {
				h = o;
				d = n;
				f.hoverIntent_t = setTimeout(function() {
					c(g, f)
				},
				l.interval)
			}
		};
		var i = function(g, f) {
			f.hoverIntent_t = clearTimeout(f.hoverIntent_t);
			f.hoverIntent_s = 0;
			return l.out.apply(f, [g])
		};
		var b = function(p) {
			var g = a.extend({},
			p);
			var f = this;
			if (f.hoverIntent_t) {
				f.hoverIntent_t = clearTimeout(f.hoverIntent_t)
			}
			if (p.type == "mouseenter") {
				h = g.pageX;
				d = g.pageY;
				a(f).bind("mousemove", e);
				if (f.hoverIntent_s != 1) {
					f.hoverIntent_t = setTimeout(function() {
						c(g, f)
					},
					l.interval)
				}
			} else {
				a(f).unbind("mousemove", e);
				if (f.hoverIntent_s == 1) {
					f.hoverIntent_t = setTimeout(function() {
						i(g, f)
					},
					l.timeout)
				}
			}
		};
		return this.bind("mouseenter", b).bind("mouseleave", b)
	}
})(jQuery);
/*
* jQuery.cookie
*/
jQuery.cookie = function(b, j, n) {
	if (typeof j != "undefined") {
		n = n || {};
		if (j === null) {
			j = "";
			n.expires = -1
		}
		var e = "";
		if (n.expires && (typeof n.expires == "number" || n.expires.toUTCString)) {
			var f;
			if (typeof n.expires == "number") {
				f = new Date();
				f.setTime(f.getTime() + (n.expires * 24 * 60 * 60 * 1000))
			} else {
				f = n.expires
			}
			e = "; expires=" + f.toUTCString()
		}
		var l = n.path ? "; path=" + (n.path) : "";
		var g = n.domain ? "; domain=" + (n.domain) : "";
		var a = n.secure ? "; secure": "";
		document.cookie = [b, "=", encodeURIComponent(j), e, l, g, a].join("")
	} else {
		var d = null;
		if (document.cookie && document.cookie != "") {
			var k = document.cookie.split(";");
			for (var h = 0; h < k.length; h++) {
				var c = jQuery.trim(k[h]);
				if (c.substring(0, b.length + 1) == (b + "=")) {
					d = decodeURIComponent(c.substring(b.length + 1));
					break
				}
			}
		}
		return d
	}
}; 
/*
* 对象与数组的转换
* 使用示例如下
* var v = {
*    a: "a",
*    b: "b"
* }
* var ar = objectToArray(v);
* alert(ar[1]); //结果:b
*/
var objectToArray = function(b) {
	if (!b) {
		return []
	}
	var a = [];
	for (m in b) {
		if ( !! b[m]) {
			a.push(b[m])
		}
	}
	return a
};
/*
* 页面按钮
*/
var leheBtnIdGenertor = function() {
	return objectToArray(G.leheButtons).length + 1
};
var LeheBtn = function(a) {
	this.element = a.el;
	this.id = a.id
};
LeheBtn.prototype.enable = function() {
	this.element.removeProp("disabled");
	this.element.removeClass("disabled").addClass("normal")
};
LeheBtn.prototype.disable = function() {
	this.element.prop("disabled", true);
	this.element.removeClass("normal").addClass("disabled")
};
jQuery.fn.getLeheBtn = function() {
	var a = jQuery(this);
	var c = a[0];
	var b = jQuery.data(c, "id");
	if (!b) {
		return false
	}
	return G.leheButtons[b]
};
// 页面按钮-初始化
jQuery.fn.initLeheBtns = function() {
	this.each(function() {
		var c = jQuery(this);
		var d = c[0];
		var b = jQuery.data(d, "id");
		if (b) {
			return false
		}
		b = leheBtnIdGenertor();
		jQuery.data(d, "id", b);
		c.bindBtnEvent = function() {
			var e = jQuery(this);
			e.unbind("hover").unbind("mousedown").unbind("mouseup");
			e.hover(function() {
				e.removeClass("normal").removeClass("click").removeClass("disabled").addClass("hover")
			},
			function() {
				e.removeClass("hover").removeClass("click").removeClass("disabled").addClass("normal")
			}).mousedown(function() {
				e.removeClass("hover").removeClass("normal").removeClass("disabled").addClass("click")
			}).mouseup(function() {
				e.removeClass("hover").removeClass("click").removeClass("disabled").addClass("normal")
			})
		};
		c.bindBtnEvent();
		if (d.disabled) {
			if (!c.hasClass("disabled")) {
				c.removeClass("normal").addClass("disabled")
			}
		}
		var a = new LeheBtn({
			id: b,
			el: c
		});
		G.leheButtons[b] = a
	})
};
/*
* js日期格式化
/* http://blog.csdn.net/vbangle/article/details/5643091
/* 使用方法:
/* (new Date()).format("yyyy-MM-dd hh:mm:ss.S");
*/
Date.prototype.format = function(e) {
	var d = "";
	var c = Date.replaceChars;
	for (var b = 0; b < e.length; b++) {
		var a = e.charAt(b);
		if (b - 1 >= 0 && e.charAt(b - 1) == "\") {
			d += a
		} else {
			if (c[a]) {
				d += c[a].call(this)
			} else {
				if (a != "\") {
					d += a
				}
			}
		}
	}
	return d
};
Date.replaceChars = {
	shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
	longMonths: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
	shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
	longDays: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
	d: function() {
		return (this.getDate() < 10 ? "0": "") + this.getDate()
	},
	D: function() {
		return Date.replaceChars.shortDays[this.getDay()]
	},
	j: function() {
		return this.getDate()
	},
	l: function() {
		return Date.replaceChars.longDays[this.getDay()]
	},
	N: function() {
		return this.getDay() + 1
	},
	S: function() {
		return (this.getDate() % 10 == 1 && this.getDate() != 11 ? "st": (this.getDate() % 10 == 2 && this.getDate() != 12 ? "nd": (this.getDate() % 10 == 3 && this.getDate() != 13 ? "rd": "th")))
	},
	w: function() {
		return this.getDay()
	},
	z: function() {
		var a = new Date(this.getFullYear(), 0, 1);
		return Math.ceil((this - a) / 86400000)
	},
	W: function() {
		var a = new Date(this.getFullYear(), 0, 1);
		return Math.ceil((((this - a) / 86400000) + a.getDay() + 1) / 7)
	},
	F: function() {
		return Date.replaceChars.longMonths[this.getMonth()]
	},
	m: function() {
		return (this.getMonth() < 9 ? "0": "") + (this.getMonth() + 1)
	},
	M: function() {
		return Date.replaceChars.shortMonths[this.getMonth()]
	},
	n: function() {
		return this.getMonth() + 1
	},
	t: function() {
		var a = new Date();
		return new Date(a.getFullYear(), a.getMonth(), 0).getDate()
	},
	L: function() {
		var a = this.getFullYear();
		return (a % 400 == 0 || (a % 100 != 0 && a % 4 == 0))
	},
	o: function() {
		var a = new Date(this.valueOf());
		a.setDate(a.getDate() - ((this.getDay() + 6) % 7) + 3);
		return a.getFullYear()
	},
	Y: function() {
		return this.getFullYear()
	},
	y: function() {
		return ("" + this.getFullYear()).substr(2)
	},
	a: function() {
		return this.getHours() < 12 ? "am": "pm"
	},
	A: function() {
		return this.getHours() < 12 ? "AM": "PM"
	},
	B: function() {
		return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTCMinutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24)
	},
	g: function() {
		return this.getHours() % 12 || 12
	},
	G: function() {
		return this.getHours()
	},
	h: function() {
		return ((this.getHours() % 12 || 12) < 10 ? "0": "") + (this.getHours() % 12 || 12)
	},
	H: function() {
		return (this.getHours() < 10 ? "0": "") + this.getHours()
	},
	i: function() {
		return (this.getMinutes() < 10 ? "0": "") + this.getMinutes()
	},
	s: function() {
		return (this.getSeconds() < 10 ? "0": "") + this.getSeconds()
	},
	u: function() {
		var a = this.getMilliseconds();
		return (a < 10 ? "00": (a < 100 ? "0": "")) + a
	},
	e: function() {
		return "Not Yet Supported"
	},
	I: function() {
		return "Not Yet Supported"
	},
	O: function() {
		return ( - this.getTimezoneOffset() < 0 ? "-": "+") + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? "0": "") + (Math.abs(this.getTimezoneOffset() / 60)) + "00"
	},
	P: function() {
		return ( - this.getTimezoneOffset() < 0 ? "-": "+") + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? "0": "") + (Math.abs(this.getTimezoneOffset() / 60)) + ":00"
	},
	T: function() {
		var b = this.getMonth();
		this.setMonth(0);
		var a = this.toTimeString().replace(/^.+ (?([^)]+))?$/, "$1");
		this.setMonth(b);
		return a
	},
	Z: function() {
		return - this.getTimezoneOffset() * 60
	},
	c: function() {
		return this.format("Y-m-d\TH:i:sP")
	},
	r: function() {
		return this.toString()
	},
	U: function() {
		return this.getTime() / 1000
	}
};
/*
* 日期转换
*/
function parseDate(b) {
	if (typeof b == "string") {
		var a = b.match(/^ *(d{4})-(d{1,2})-(d{1,2}) *$/);
		if (a && a.length > 3) {
			return new Date(parseInt(a[1], 10), parseInt(a[2], 10) - 1, parseInt(a[3], 10))
		}
		a = b.match(/^ *(d{4})-(d{1,2})-(d{1,2}) +(d{1,2}):(d{1,2}):(d{1,2}) *$/);
		if (a && a.length > 6) {
			return new Date(parseInt(a[1], 10), parseInt(a[2], 10) - 1, parseInt(a[3], 10), parseInt(a[4], 10), parseInt(a[5], 10), parseInt(a[6], 10))
		}
		a = b.match(/^ *(d{4})-(d{1,2})-(d{1,2}) +(d{1,2}):(d{1,2}):(d{1,2}).(d{1,9}) *$/);
		if (a && a.length > 7) {
			return new Date(parseInt(a[1], 10), parseInt(a[2], 10) - 1, parseInt(a[3], 10), parseInt(a[4], 10), parseInt(a[5], 10), parseInt(a[6], 10), parseInt(a[7], 10))
		}
	}
	return null
}
function parseIdCard(a) {
	if (typeof(a) == "undefined") {
		return false
	}
	a = a.toLowerCase();
	if (a.length == 0) {
		return false
	}
	var f = /d{15}/;
	var c = /d{17}([0-9]{1}|x|X)/;
	var l = new Array("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31");
	var g = a.length == 15 ? f.test(a) : c.test(a);
	if (!g) {
		return false
	}
	var d = a.length == 15 ? "19" + a.substr(6, 6) : a.substr(6, 8);
	var i = d.substr(0, 4);
	var e, k;
	if (d.substr(4, 1) == "0") {
		e = d.substr(5, 1)
	} else {
		e = d.substr(4, 2)
	}
	if (d.substr(6, 1) == "0") {
		k = d.substr(7, 1)
	} else {
		k = d.substr(6, 2)
	}
	var n = parseInt(k, 10);
	var b = parseInt(e, 10);
	var h = parseInt(i, 10);
	if (b > 12 || b < 1 || n > 31 || n < 1) {
		return false
	}
	var j = false;
	if (i % 100 != 0) {
		if (i % 4 == 0) {
			j = true
		}
	} else {
		if (i % 400 == 0) {
			j = true
		}
	}
	if (j) {
		l[1] = 29
	}
	if (l[b - 1] < n) {
		return false
	}
	return {
		length: a.length,
		year: h,
		month: b,
		date: n
	}
}
//身份证验证
function validateIdCard(f) {
	var a = parseIdCard(f);
	if (a === false) {
		return false
	}
	if (a.length == 18) {
		var e = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
		var b = 0;
		var d;
		for (var c = 0; c < 17; c++) {
			b = b + f.substr(c, 1) * e[c]
		}
		b = b % 11;
		switch (b) {
		case 0:
			d = "1";
			break;
		case 1:
			d = "0";
			break;
		case 2:
			d = "x";
			break;
		case 3:
			d = "9";
			break;
		case 4:
			d = "8";
			break;
		case 5:
			d = "7";
			break;
		case 6:
			d = "6";
			break;
		case 7:
			d = "5";
			break;
		case 8:
			d = "4";
			break;
		case 9:
			d = "3";
			break;
		case 10:
			d = "2";
			break
		}
		if (f.substr(17, 1).toLowerCase() != d) {
			return false
		}
	}
	if (a.length > 18) {
		return false
	}
	return true
}
//年龄验证
function validateAge(a, g, d) {
	var i = parseIdCard(a);
	if (i === false) {
		return false
	}
	if (typeof(g) == "undefined") {
		g = 18
	} else {
		g = parseInt(g, 10);
		if (isNaN(g)) {
			return false
		}
	}
	if (typeof(d) == "undefined") {
		d = new Date()
	} else {
		if (! (d instanceof Date)) {
			return false
		}
	}
	var c = d.getDate();
	var b = d.getMonth();
	var e = d.getFullYear() - g;
	var h = new Date(e, b, c, 0, 0, 0);
	var f = new Date(i.year, i.month - 1, i.date, 0, 0, 0);
	if (h.getTime() < f.getTime()) {
		return false
	}
	return true
}
//座机验证
function validateTelphone(a) {
	if (!/^[0-9-]{12,20}$/.test(a)) {
		return false
	}
	return (/^(([0+]d{2,3}-)?(0d{2,3})-)(d{7,8})(-(d{3,}))?$/.test(a))
}
//手机验证
function validateMobile(a) {
	if (!/^[0-9]{11}$/.test(a)) {
		return false
	}
	return (/^(?:1[3458]d)-?d{5}(d{3}|*{3})$/.test(a))
}
/*
* 返回字符串字节长度
* 如:'Sn' 字节为2
* '杨' 字节为2
*/
function getRealLength(c) {
	var b = 0;
	for (var a = 0; a < c.length; a++) {
		if ((c.charCodeAt(a) >= 0) && (c.charCodeAt(a) <= 255)) {
			b++
		} else {
			b += 2
		}
	}
	return b
}
//所有 AJAX 请求设置默认
jQuery.ajaxSetup({
	dataType: "json",
	type: "POST"
});
//当 AJAX 请求开始时,显示“加载中”的指示
jQuery(document).ajaxStart(function() {
	jQuery.colorbox({
		html: '<div id="loader"><img src="' + G.baseImgUrl + '/loading.gif" alt="loading..." /><span>正在提交请求...</span></div>',
		opacity: 0.3,
		overlayClose: false,
		escKey: false,
		close: ""
	})
});
/*
* 扩展Math对象
*/
jQuery.extend(Math, {
	permute: function(d, a) {
		var b = 1;
		for (var c = 0; c < a; c++) {
			b *= (d - c)
		}
		return parseInt(b, 10)
	},
	combine: function(c, a) {
		var b = Math.permute(c, a);
		b /= Math.permute(a, a);
		return parseInt(b, 10)
	},
	fullCombination: function(j, b) {
		var d = [];
		var g = j.length;
		var e = [];
		for (var c = 0; c <= b; c++) {
			e.push(c - 1)
		}
		var h = b;
		var f = true;
		while (e[0] == -1) {
			if (f) {
				var a = [];
				for (var c = 1; c <= b; c++) {
					a.push(j[e[c]])
				}
				d.push(a);
				f = false
			}
			e[h]++;
			if (e[h] == g) {
				e[h] = 0;
				h--;
				continue
			}
			if (h < b) {
				h++;
				e[h] = e[h - 1];
				continue
			}
			if (h == b) {
				f = true
			}
		}
		return d
	},
	fullCombinationDantuo: function(f, a, j) {
		var d = 0;
		if (a) {
			d = a.length
		}
		var c = j.length;
		if (d + c < f) {
			return false
		}
		var b = f - d;
		var h = Math.fullCombination(j, b);
		for (var e = 0,
		g = h.length; e < g; e++) {
			h[e] = h[e].concat(a)
		}
		return h
	},
	countCombinationDantuo: function(c, a, b) {
		a = (typeof(a) == "undefined") ? 0 : a;
		var d = c - a;
		return Math.combine(b, d)
	},
	arrayFullCombination: function(a) {
		var d = function(g, e) {
			var n = g;
			var l = [];
			while (e.length > 0) {
				for (var j = 0; j < n.length; j++) {
					var f = [e[0]];
					for (var h = 0; h < n[j].length; h++) {
						f.push(n[j][h])
					}
					l.push(f)
				}
				e = e.slice(1, e.length)
			}
			return l
		};
		var c = Math.fullCombination(a[0], 1);
		for (var b = 1; b < a.length; b++) {
			c = d(c, a[b])
		}
		return c
	},
	arrayIsNoRepeat: function(a) {
		var b = 0,
		c = {};
		for (; b < a.length; b++) {
			if (c[a[b]] !== undefined) {
				return false
			}
			c[a[b]] = true
		}
		return true
	},
	arrayIsHasNoRepeat: function(e) {
		var h = e.length;
		var b = [];
		var f = [];
		var g = [];
		var j = [];
		var a = 1;
		for (var d = 0; d < h; d++) {
			b[d] = e[d].length;
			a = a * b[d];
			f[d] = 0
		}
		for (var d = 0; d < a; d++) {
			g[d] = []
		}
		var c = 0;
		while (true) {
			for (var d = 0; d < h; d++) {
				g[c][d] = (f[d] + 1);
				j[d] = e[d][g[c][d] - 1]
			}
			if (Math.arrayIsNoRepeat(j)) {
				return true
			}
			c++;
			for (var d = h - 1; d >= 0; d--) {
				if (f[d] == b[d] - 1) {
					f[d] = 0
				} else {
					break
				}
			}
			if (d < 0) {
				break
			}
			f[d]++
		}
		return false
	}
});
/*_______________colorbox弹出层_______________*/
//
function getPayPasswordInputText() {
	return '<br/>支付密码:<input id="txtConfirmPayPwd" style="100px;" type="password" class="text" /><a href="http://redirect.lehecai.com/help/xinxi/#ChildMenu11" style="display: none" id="aForgetPayPwd" class="forget" target="_blank">忘记密码</a><br/><label id="lPayErrorTip" class="red"> </label>'
}
/*
* 返回倒计时的字符串,使用如下
* alert(defaultCountdownTimerCallback({ d: 1, h: 1, m: 1, s: 1 })); //结果:1天1小时1分1秒
*/
function defaultCountdownTimerCallback(a) {
	if (typeof(a) != "object") {
		logger.error(a, "CountdownTimer callback error!");
		return
	}
	var b = new StringBuffer();
	if (a.d > 0) {
		b.append(a.d).append("天")
	}
	if (a.d > 0 || a.h > 0) {
		b.append(a.h).append("小时")
	}
	if (a.d > 0 || a.h > 0 || a.m > 0) {
		b.append(a.m).append("分")
	}
	b.append(a.s).append("秒");
	return b.toString()
}
// 检测是否是数字键
function numberKeyOnly(a) {
	var b = a.which;
	if (a.shiftKey) {
		if (b == 9) {
			return true
		}
		return false
	}
	if ((b <= 57 && b >= 48) || b == 37 || b == 39 || b == 8 || b == 9 || b == 46 || (b <= 105 && b >= 96) || b == 229) {
		return true
	}
	return false
}
function numberKeyAndDotOnly(a) {
	var b = a.which;
	if (numberKeyOnly(a)) {
		return true
	}
	if (b == 110 || b == 190) {
		return true
	}
	return false
}
//添加到收藏夹
function addFavorite(a, b) {
	if (G.browser.msie) {
		window.external.addFavorite(a, b);
		return false
	}
	if (G.browser.mozilla || G.browser.opera) {
		this.setAttribute("href", a);
		this.setAttribute("title", b);
		this.setAttribute("rel", "sidebar");
		this.click();
		return false
	}
	if (G.browser.webkit) {
		if (G.platform.mac) {
			jQuery.showAlert("按下<command+d>收藏本站");
			return false
		}
		if (G.platform.windows) {
			jQuery.showAlert("按下<Ctrl+d>收藏本站");
			return false
		}
	}
	return false
}
//更新页面头部的用户信息
function updateHeaderUserInfo(f) {
	UID = f.uid;
	USERNAME = f.username;
	G.userinfo = f;
	var k = jQuery("#header_simple");
	if (k.length > 0) {
		jQuery("#header_simple_username").html(f.username);
		jQuery("#header_simple_not_login").hide();
		jQuery("#header_simple_login").show();
		jQuery.triggerGlobalEvent(C.EVENT.LOGIN_SUCCESS, f);
		return
	}
	jQuery("#toptray_username").html(f.username);
	jQuery("#toptray_not_login").hide();
	jQuery("#toptray_login").show();
	if (f.counter.autofollow_records != 0 && f.counter.autofollow_records != null) {
		jQuery("#header_my_autofollow").attr("href", G.baseUrl + "/user/autofollow/message/")
	} else {
		jQuery("#header_my_autofollow").attr("href", G.baseUrl + "/user/autofollow/manage/")
	}
	jQuery("#header_notpaid_counter").html(f.counter.order_notpaid > 0 || f.counter.chase_notpaid > 0 ? '[<em class="red">' + (parseInt(f.counter.order_notpaid) + parseInt(f.counter.chase_notpaid)) + "</em>]": "");
	jQuery("#header_notupload_counter").html(f.counter.plan_notupload ? f.counter.plan_notupload: "0");
	jQuery("#header_sign").attr("class", f.counter.order_notpaid > 0 || f.counter.chase_notpaid > 0 ? "header_sign": "nosign");
	var j = jQuery("#header_user_money_hidden");
	var d = 0;
	for (var l in f.wallet) {
		var a = f.wallet[l];
		d += parseFloat(a.balance, 10)
	}
	j.val(d.toFixed(2) + "");
	var h = new StringBuffer();
	for (var c = 0,
	g = C.WALLET_ORDER.length; c < g; c++) {
		var l = C.WALLET_ORDER[c];
		var a = f.wallet[l];
		if (typeof(a) == "undefined") {
			continue
		}
		var b = parseFloat(a.balance, 10).toFixed(2);
		if (typeof(a.status) == "undefined" || a.status != "1") {
			continue
		}
		h.append("<p>").append(C.WALLET[l]).append(":").append('<strong class="red">¥').append(b).append("</strong>").append("</p>")
	}
	h.append('<p><a class="account_detail" href="' + G.baseUrl + '/user/account">账户明细>></a></p>');
	h.append('<div class="clear nospace"> </div>');
	var e = jQuery("#wallet_detail");
	e.empty().append(h.toString());
	jQuery("#header_autofollowunread_counter").text(f.counter.autofollow_records);
	jQuery("#mylottery").unbind().hover(function() {
		jQuery("#mylottery_dropdown").show()
	},
	function() {
		jQuery("#mylottery_dropdown").hide()
	});
	jQuery.triggerGlobalEvent(C.EVENT.LOGIN_SUCCESS, f)
}
//用户登录
function initAjaxLogin(e) {
	e = jQuery.extend({
		lottery_type: undefined,
		success: undefined,
		error: undefined
	},
	e);
	var d = [];
	if (typeof(e.lottery_type) != "undefined") {
		if (jQuery.isArray(e.lottery_type)) {
			for (var c = 0,
			a = e.lottery_type.length; c < a; c++) {
				d.push("lottery_type[]=" + e.lottery_type[c])
			}
		} else {
			d.push("lottery_type=" + e.lottery_type)
		}
	}
	var b = jQuery.cookie(C.COOKIE_USERINFO);
	if ( !! b && b == "1") {
		jQuery.ajax({
			url: G.baseUrl + "/user/ajax_userinfo.php",
			type: "GET",
			data: d.join("&"),
			dataType: "json",
			global: false,
			success: function(h) {
				var f = jQuery.ajaxResultHandler(h, {
					successCloseOverlay: false,
					errorCloseOverlay: false,
					ignoreRedirect: true
				});
				if (typeof(f) != "object" || !f.success || f.data.uid == 0) {
					if (typeof(e.error) == "function") {
						e.error(f)
					}
					jQuery.triggerGlobalEvent(C.EVENT.LOGIN_INIT_NOT);
					jQuery.triggerGlobalEvent(C.EVENT.LOGIN_INIT_COMPLETE);
					return false
				}
				jQuery.extend(G.tmp, {
					serverTime: f.datetime
				});
				updateHeaderUserInfo(f.data);
				var g = 1000 * 60 * 60;
				if (f.data.paypassword.status) {
					g *= 24
				}
				jQuery.cookie(C.COOKIE_USERINFO, "1", {
					expires: new Date(new Date().getTime() + g),
					path: "/"
				});
				if (typeof(e.success) == "function") {
					e.success(f)
				}
				jQuery.triggerGlobalEvent(C.EVENT.LOGIN_INIT_COMPLETE, f.data)
			}
		})
	} else {
		if (typeof(e.error) == "function") {
			e.error()
		}
		jQuery.triggerGlobalEvent(C.EVENT.LOGIN_INIT_NOT);
		jQuery.triggerGlobalEvent(C.EVENT.LOGIN_INIT_COMPLETE)
	}
}
/*
*  返回正跳转地址
*/
function executeRedirect(a) {
	a = jQuery.extend({
		url: ""
	},
	a);
	if (typeof(a.url) == "string" && jQuery.trim(a.url) != "") {
		window.location.href = a.url;
		return true
	}
	return false
}
//用户注册功能
jQuery.registerErrorTable({
	"0x3000001": "user unlogin",
	"0x3000002": "user unregister",
	"0x7020004": "not enough balance",
	"0x10010007": "login failed too many times",
	"0x10010006": "error username or password"
},
{
	"0x3000001": function(d) {
		d = jQuery.extend({
			lottery_type: undefined,
			success: undefined,
			error: undefined,
			template_url: G.baseUrl + "/user/load_float_login.php"
		},
		d);
		function c(e) {
			if ( !! e) {
				jQuery("#float_need_captcha").show();
				jQuery.captcha("float_captcha")
			} else {
				jQuery("#float_need_captcha").hide()
			}
		}
		var a = function(e) {
			c(e.require_captcha)
		};
		var b = function(e) {
			c(e)
		};
		jQuery.template(d.template_url, "float_login_tpl",
		function(e) {
			jQuery.colorbox({
				inline: true,
				href: "#" + e,
				onComplete: function() {
					try {
						var f = 1;
						var g = jQuery("#float_other_list");
						var i = jQuery("#colorbox").get(0);
						var h = jQuery("#float_other_list");
						g = g.parent();
						while (i !== g.get(0) && f < 30) {
							h = h.add(g);
							g = g.parent(); ++f
						}
						h.add(g).css("overflow", "visible")
					} catch(j) {
						logger.info(j)
					}
				},
				onLoad: function() {
					var h = G.browser.msie && (G.browser.version == 6);
					var g;
					jQuery(".float_other_box").unbind().hover(function() {
						if (h) {
							g = jQuery("select:visible").css("visibility", "hidden")
						}
						jQuery(".float_other_box").addClass("float_other_box_on");
						jQuery(".float_other_text").addClass("float_other_text_on");
						jQuery("#float_other_list").show()
					},
					function() {
						jQuery(".float_other_box").removeClass("float_other_box_on");
						jQuery(".float_other_text").removeClass("float_other_text_on");
						jQuery("#float_other_list").hide();
						if (h) {
							g.css("visibility", "visible")
						}
					});
					jQuery(".fl_right .fl_login_title_ul li").menus({
						classes: {
							on: "on",
							off: ""
						},
						default_selected_index: 0,
						hover_switch: false,
						switch_success: function(i) {
							var j = i.attr("login_name");
							jQuery(".fl_right .login_box").hide();
							jQuery("#fl_login_" + j).show()
						}
					});
					prelogin({
						callback: a,
						no_need_to_request_callback: b,
						successCloseOverlay: false
					});
					jQuery("#float_login_close_btn").unbind().click(function() {
						jQuery.colorbox.close()
					});
					var f = jQuery("#float_login_form");
					f.unbind().submit(function() {
						var j = function() {
							var n = [];
							n.push("username=" + encodeURIComponent(jQuery("#float_username").val()));
							n.push("passwd=" + encodeURIComponent(jQuery("#float_passwd").val()));
							n.push("verify=" + encodeURIComponent(jQuery("#float_verify").val()));
							if (typeof(d.lottery_type) != "undefined") {
								if (jQuery.isArray(d.lottery_type)) {
									for (var l = 0,
									k = d.lottery_type.length; l < k; l++) {
										n.push("lottery_type[]=" + d.lottery_type[l])
									}
								} else {
									n.push("lottery_type=" + d.lottery_type)
								}
							}
							jQuery.ajax({
								url: G.baseUrl + "/user/ajax_login.php",
								type: "POST",
								data: n.join("&"),
								global: false,
								success: function(q) {
									var p = jQuery.ajaxResultHandler(q, {
										ignoreRedirect: true,
										usingAlert: true,
										error: d.error
									});
									if (typeof(p) == "object" && p.success) {
										jQuery.extend(G.tmp, {
											serverTime: p.datetime
										});
										updateHeaderUserInfo(p.data);
										if (typeof(d.success) == "function") {
											d.success(p.data)
										}
										if (typeof(ajax_login_params) == "object" && typeof(ajax_login_params.success) == "function") {
											ajax_login_params.success(p)
										}
										var o = p.data.discuz;
										if (o) {
											o = encodeURIComponent(o);
											jQuery("body").append('<iframe id="uc_login_frame" name="uc_login_frame" src="/user/uc_redirect.php?discuz=' + o + '" style="display:none;"></iframe>')
										}
										f.resetForm()
									} else {
										window.require_captcha = true;
										c(window.require_captcha)
									}
								}
							})
						};
						var i = window.require_captcha;
						prelogin({
							callback: function(k) {
								if (k.require_captcha != i && k.require_captcha) {
									c(k.require_captcha)
								} else {
									j();
									if (k.require_captcha != i && !k.require_captcha) {
										c(k.require_captcha)
									}
								}
							},
							no_need_to_request_callback: function() {
								j()
							},
							successCloseOverlay: false
						});
						return false
					})
				},
				opacity: 0.5,
				close: ""
			});
			return false
		});
		jQuery.trackPageView(G.baseUrl + "/virtual/float/login")
	},
	"0x3000002": function(a) {
		a = jQuery.extend({
			validate: true,
			success: undefined,
			error: undefined,
			ignoreRedirect: true,
			successCloseOverlay: true,
			submitClass: "float_register_submit",
			loginLink: true,
			templateUrl: G.baseUrl + "/user/load_float_register.php"
		},
		a);
		jQuery.template(a.templateUrl, "float_register_tpl",
		function(b) {
			var c = function() {
				jQuery("#" + b).find("input[type=submit]").addClass(a.submitClass).end();
				jQuery("#float_register_verify").one("focus",
				function() {
					jQuery.captcha("float_register_captcha");
					jQuery("#float_register_captcha_info").hide();
					jQuery("#float_register_captcha_span").show()
				});
				if (a.loginLink) {
					jQuery("#float_register_login").show()
				} else {
					jQuery("#float_register_login").hide()
				}
				var d = jQuery("#float_register_form").validate({
					errorPlacement: function(e, f) {
						e.appendTo(f.parent("td").find("p").empty())
					},
					errorClass: "error",
					validClass: "valid",
					highlight: function(g, e, f) {},
					unhighlight: function(g, e, f) {},
					onkeyup: function(e) {},
					success: function(e) {
						e.empty().removeClass(this.errorClass).addClass(this.validClass)
					},
					submitHandler: function(f) {
						var e = jQuery(f);
						var g = [];
						g.push("username=" + encodeURIComponent(jQuery("#float_register_username").val()));
						g.push("passwd=" + encodeURIComponent(jQuery("#float_register_passwd").val()));
						g.push("conpasswd=" + encodeURIComponent(jQuery("#float_register_conpasswd").val()));
						g.push("verify=" + encodeURIComponent(jQuery("#float_register_verify").val()));
						jQuery.ajax({
							url: G.baseUrl + "/user/ajax_register.php",
							type: "POST",
							data: g.join("&"),
							global: false,
							success: function(i) {
								var h = jQuery.ajaxResultHandler(i, {
									ignoreRedirect: a.ignoreRedirect,
									successCloseOverlay: a.successCloseOverlay,
									usingAlert: true,
									error: a.error
								});
								if (typeof(h) == "object" && h.success) {
									e.resetForm();
									initAjaxLogin();
									if (typeof(a.success) == "function") {
										a.success(h)
									}
								} else {
									if (typeof(a.error) == "function") {
										a.error(h)
									}
								}
							}
						});
						return false
					},
					rules: {
						float_register_username: {
							required: true,
							validateUsername: true,
							maxRealLength: 16,
							minRealLength: 4,
							remote: {
								url: "/user/user_exist.php",
								ignoreElement: true,
								validFunction: function(f) {
									var e = jQuery.ajaxResultHandler(f, {
										successCloseOverlay: false
									});
									if (e && e.success) {
										return ! (e.data.result === true)
									}
									return false
								},
								data: {
									name: function() {
										return jQuery.trim(jQuery("#float_register_username").val())
									}
								}
							}
						},
						float_register_passwd: {
							required: true,
							validatePassword: true
						},
						float_register_conpasswd: {
							required: true,
							equalTo: "#float_register_passwd"
						},
						float_register_verify: {
							required: true,
							remote: {
								url: "/captcha_verify.php",
								validFunction: function(f) {
									var e = jQuery.ajaxResultHandler(f, {
										successCloseOverlay: false
									});
									if (e && e.success) {
										return e.data.result === true
									}
									return false
								}
							}
						}
					},
					messages: {
						float_register_username: {
							required: "请输入用户名",
							remote: "该用户名已被使用"
						},
						float_register_passwd: {
							required: "请输入密码"
						},
						float_register_conpasswd: {
							equalTo: "密码不匹配"
						},
						float_register_verify: {
							required: "请输入验证码",
							remote: "验证码输入不正确"
						}
					}
				});
				jQuery.colorbox({
					inline: true,
					href: "#" + b,
					opacity: 0.5,
					close: "",
					onComplete: function() {
						if (jQuery("#float_register_captcha").is(":visible")) {
							jQuery.captcha("float_register_captcha")
						}
					}
				})
			};
			if (a.validate && typeof(jQuery.prototype.validate) != "function") {
				jQuery.ajaxLoadScript({
					url: G.baseJsUrl + "/jquery.validate.min.js",
					global: false,
					success: c
				})
			} else {
				c()
			}
			return false
		});
		jQuery.trackPageView(G.baseUrl + "/virtual/float/register")
	},
	"0x10010007": function(a) {
		$.showError("登录失败次数过多", {
			detail: '<span class="red">' + a.message + "</span>"
		})
	},
	"0x10010006": function(a) {
		$.showError("您输入的密码不正确", {
			detail: '<span class="red">' + a.message + "</span>"
		})
	}
});
//视频兼容
jQuery.fn.extend({
	notebox: function(a) {
		a = jQuery.extend({
			opacity: 0.8,
			notebox: ".notebox",
			left: 0,
			top: 15,
			noteboxClass: "notebox"
		},
		a);
		jQuery(this).each(function() {
			var c = jQuery(this);
			c.css("position", "relative");
			var b = c.find(a.notebox);
			b.css({
				position: "absolute",
				top: a.top,
				left: a.left
			}).addClass(a.noteboxClass).hide();
			c.hover(function() {
				jQuery(this).css("zIndex", 9999);
				b.show()
			},
			function() {
				jQuery(this).css("zIndex", 0);
				b.hide()
			})
		});
		return jQuery(this)
	}
});
/*
* tooltip是当鼠标停止在某一个工具元件时,界面对用户的提示。为了做出更美观的tooltip,通常会用层模拟创建一个tooltip效果。
*/
jQuery.fn.extend({
	tooltip: function(b) {
		b = jQuery.extend({
			opacity: 0.8,
			selector: ".tooltip",
			left: 15,
			top: 15,
			container: "",
			containerId: "",
			containerClass: "tooltip_box"
		},
		b);
		if (!b.container || jQuery(b.container).length == 0) {
			jQuery("body").append('<div id="' + (b.containerId ? b.containerId: "default_tooltip_box") + '" class="' + b.containerClass + '"></div>');
			b.container = "#" + (b.containerId ? b.containerId: "default_tooltip_box")
		}
		var a = jQuery(b.container);
		jQuery(this).each(function() {
			var c = jQuery(this);
			c.hover(function(e) {
				var d = jQuery.mouseCoords(e);
				a.css({
					position: "absolute",
					left: d.x + b.left + "px",
					top: d.y + b.top + "px",
					opacity: b.opacity
				}).html(c.next(b.selector).html()).show()
			},
			function(d) {
				a.hide().empty()
			})
		});
		return jQuery(this)
	}
});
// menus 下拉菜单
jQuery.fn.extend({
	menus: function(c) {
		var b = jQuery(this);
		c = jQuery.extend({
			default_selected_index: 0,
			classes: {
				on: "on",
				off: "off"
			},
			hover_switch: false,
			switch_success: undefined
		},
		c);
		var a = function(d) {
			if (d.hasClass(c.classes.on)) {
				return false
			}
			b.removeClass(c.classes.on);
			d.addClass(c.classes.on).removeClass(c.classes.off);
			if (c.switch_success && typeof(c.switch_success) == "function") {
				c.switch_success(d)
			}
		};
		jQuery(this).each(function(d) {
			var e = jQuery(this);
			if (d == c.default_selected_index) {
				a(e)
			} else {}
			if (c.hover_switch) {
				e.hover(function() {
					a(e)
				})
			} else {
				e.click(function() {
					a(e)
				})
			}
		})
	}
});
// 自定义媒体DOM类
function getFlashMovieObject(a) {
	if (window.document[a]) {
		return window.document[a]
	}
	if (document.embeds && document.embeds[a]) {
		return document.embeds[a]
	} else {
		return document.getElementById(a)
	}
}
/*
* 其它登录
*/
function prelogin(c) {
	c = jQuery.extend({
		callback: function(d) {},
		no_need_to_request_callback: function(d) {},
		successCloseOverlay: true
	},
	c);
	var a = 60000;
	if (!window._last_request_prelogin) {
		window._last_request_prelogin = (new Date()).getTime()
	} else {
		var b = (new Date()).getTime();
		if (b - window._last_request_prelogin < a) {
			logger.info("no need to re-request prelogin in " + a + "ms");
			if (c.no_need_to_request_callback && typeof(c.no_need_to_request_callback) == "function") {
				c.no_need_to_request_callback(window.require_captcha)
			}
			return false
		}
	}
	window._last_request_prelogin = (new Date()).getTime();
	jQuery.ajax({
		url: G.baseUrl + "/user/ajax_prelogin.php",
		type: "GET",
		dataType: "json",
		global: false,
		success: function(e) {
			var d = jQuery.ajaxResultHandler(e, {
				successCloseOverlay: c.successCloseOverlay
			});
			window.require_captcha = d.data.require_captcha;
			if (c.callback && typeof(c.callback) == "function") {
				c.callback(d.data)
			}
		}
	})
}
// 获取代理的表单内容
function getAgentIdFromUrl() {
	try {
		var b = new LHC.URLParser(window.location.href);
		var a = new LHC.QueryStringParser(b.getQueryString());
		var d = parseInt(a.get("agentId"), 10);
		if (isNaN(d)) {
			return 0
		}
		return d
	} catch(c) {
		logger.error(c);
		return 0
	}
}
//调用百度广告代码。用来显示广告的。
function fillActivitySlot(c, a) {
	if (a) {
		return
	}
	try {
		BAIDU_CLB_fillSlot(c.toString())
	} catch(b) {}
}

/*
* Placeholder是HTML5新增的另一个属性,当input或者textarea设置了该属性后,该值的内容将作为灰字提示显示在文本框中,当文本框获得焦点时,提示文字消失。
* http://www.oschina.net/question/5189_22929
*/
jQuery.fn.extend({
	funPlaceholder: function(a) {
		a = jQuery.extend({
			position: "absolute",
			left: "10px",
			top: "6px",
			color: "#919191"
		},
		a);
		jQuery(this).each(function(f) {
			var c = jQuery(this);
			var e = c.attr("id");
			var d = e + "-lable";
			var j = c.attr("placeholder");
			var h = (function() {
				var i = document.createElement("input");
				return "placeholder" in i
			})();
			if (!h && j != "" && c.val() == "") {
				var b = jQuery('<span class="' + d + '">' + j + "</span>").insertBefore(c);
				var g = c.parent().find("." + d);
				g.css({
					position: a.position,
					left: a.left,
					top: a.top,
					color: a.color
				});
				c.parent().append(b);
				c.bind("click",
				function() {
					g.hide()
				}).bind("blur",
				function() {
					if (jQuery(this).value === "") {
						g.show()
					}
				});
				g.bind("click",
				function() {
					jQuery(this).hide();
					c.focus()
				})
			}
		})
	}
});
/*
*窗口初使化位置
*/
jQuery.extend({
	initLazyLoad: function(a, c) {
		c = c || 200;
		var a = a || jQuery(".js-lazy").toArray();
		if (!jQuery.isArray(a)) {
			return
		}
		var e = function() {
			return document.all ? document.getElementsByTagName("html")[0].offsetHeight: window.innerHeight
		};
		var d = function() {
			if (a.length == 0) {
				return
			}
			var g = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
			for (var l = 0; l < a.length; l++) {
				var o = a[l];
				if (!o) {
					return
				}
				var k = jQuery(o).offset();
				var h = k ? k.top: 0;
				var j = jQuery(o).prop("showed");
				var p = b + g + c;
				if (p > h && !j) {
					var n = null;
					jQuery.each(o.childNodes,
					function(i, q) {
						if (q.nodeType == 8) {
							n = q
						}
					});
					if (n) {
						var f = document.createElement("div");
						f.innerHTML = n.data;
						jQuery(o).append(jQuery(f).children()).prop("showed", true);
						a.splice(l, 1);
						l = -1;
						continue
					}
				}
			}
		};
		var b = e();
		d();
		jQuery(window).resize(function() {
			b = e()
		});
		jQuery(window).scroll(function() {
			d()
		})
	}
});

  

原文地址:https://www.cnblogs.com/sntetwt/p/3233328.html