﻿//通过Ajax访问一个链接的功能
function doHref(t, ok) {
	$.ajax({
		url: t.href,
		type: 'post',
		success: function (d) { alert2(d); },
		error: function (d) { },
		complete: function (d) { if (ok) ok(); }
	});
}
//格式化字符串，把长度不满len的str使用n在前面填充到len。
function setLength(str, n, len) {
	str = str.toString();
	while (str.length < len) str = n + str.toString();
	return str;
}
//格式化小数，并四舍五入。如：formatNum(12.345678, 4)
function formatNum(n1, n2) {
	n1 = n1.toString();
	n2 = parseInt(n2);
	var ps = n1.indexOf('.');
	if (ps == -1) {
		var k = n1 + ".";
		for (var i = 0; i < n2; ++i) k += "0";
		return k;
	}
	var vl = ps + n2 + 1;
	if (n1.length <= vl) {
		for (var i = 0; i < vl - n1.length; ++i) n1 += "0";
		return n1;
	}
	var b = n1.substring(0, vl);
	var c = n1.substring(vl, vl + 1);
	if (c == "" || parseInt(c) < 5) return b;
	return formatNum(((Math.round(parseFloat(b) * Math.pow(10, n2)) + Math.round(parseFloat(Math.pow(0.1, n2).toString().substring(0, Math.pow(0.1, n2).toString().indexOf('.') + n2 + 1)) * Math.pow(10, n2))) / Math.pow(10, n2)), n2);
}
function setCookie(key, value, day) {
	day = parseInt(day);
	if (!isNaN(day)) {
		var expireDate = new Date();
		expireDate.setTime(expireDate.getTime() + (day * 24 * 3600000));
		document.cookie = key + "=" + value + ";expires=" + expireDate.toGMTString();
	}
	else { document.cookie = key + "=" + value; }
}
function getCookie(str, _ck) {
	var reg = new RegExp("(^| )" + str + "=([^;]*)(;|$)", "gi");
	if (!_ck) _ck = document.cookie;
	var ck = reg.exec(_ck);
	try { if (ck[2] == null || typeof (ck[2]) == "undefined") return null; }
	catch (e) { return null; }
	return ck[2];
}

/**通用状态控制********************/
if (!window._5Pai) {

	var domain = "okpai.com";//5pai.com
	try { domain = document.getElementById("_5paibasic").getAttribute("domain"); } catch (e) { }
	try { document.domain = domain; } catch (e) { }

	window._5Pai = {
		domain: domain,
		ajax: jQuery.ajax,
		isDebug: function () {
			return window.location.hostname.toLowerCase() == 'local' + 'host';
		},
		is5pai: function () {
			var _h = window.location.host.toLowerCase();
			return _h == domain || _h.indexOf("." + domain) > 0;
		},
		is5pai_bid: function () {
			return this.is5paisub("bid", "www." + domain, domain);
		},
		is5paisub: function (n, d) {
			n = n.toLowerCase();
			if (!d) d = n + "." + domain;
			if (this.isDebug()) return this.getRoot() == "/" + n;
			var _h = window.location.hostname.toLowerCase();
			if (_h == d) return true;
			for (var i = 2; i < arguments.length; ++i) if (_h == arguments[i]) return true;
			return false;
		},
		getRoot: function () {
			if (this.is5pai() || !this.isDebug()) return "";
			var n_s = window.location.pathname;
			var _i = n_s.indexOf("/", 1);
			if (_i < 0) return n_s;
			return n_s.substring(0, _i);
		},
		isLogin: function () {
			if (getCookie("userinfo")) return true;
			return false;
		},
		static_login_callbacks: {},
		set_login_callback: function (f) {
			window.login_callback = function () {
				var _sfs = _5Pai.static_login_callbacks;
				for (var k in _sfs) {
					if (_sfs[k]) _sfs[k]();
				}
				if (f) f();
			};
		},
		static_bided_callbacks: { _remain_callback: {}, _usage_callback: {} },
		getUser: function () {
			var n_u = getCookie("userinfo");
			if (!n_u) return null;
			n_u = n_u.split("&");
			var _user = {};
			for (var _k in n_u) {
				var _v = n_u[_k].split("=");
				_user[_v[0]] = _v[1];
			}
			return _user;
		},
        alert_proto: window.alert,
        alert: function (w) {
            try { this.alert_proto(w); }
            catch(exp) { this.alert_proto.apply(window, arguments); }
        }
	};
	//window.proxyPath = _5Pai.getRoot() + "/Proxy.axd";
	//if (_5Pai.is5pai_bid()) window.isBidSite = _5Pai.getRoot();


	//客户端代理
	window.ClientProxy = $.extend(function (_r) {
	    var ifrm = $('<iframe style="display:none; " src="' + _r + '"></iframe>');
	    this.iframe = ifrm[0];
	    var _this = this;
	    this.isproxy = true;
	    var timer = null;
	    var insertAction = function () {
	        try {
	            if (document.body.childNodes.length > 0) ifrm.insertBefore(document.body.childNodes[0]);
	            else document.body.appendChild(_this.iframe);
	            if (timer) clearInterval(timer);
	            return true;
	        }
	        catch (e) { return false; }
	    };
	    if (insertAction() == false) timer = setInterval(insertAction, 50);
	}, {
	    list: {},
	    getHost: function (url) {
	        return this.getHostA(url).host;
	    },
	    getHostA: function (url) {
	        var n_u = url.toLowerCase();
	        var _i = n_u.indexOf("://");
	        if (_i < 0) {
	            n_u = location.href.toLowerCase();
	            _i = n_u.indexOf("://");
	            if (_i < 0) return false;
	        }
	        var _i2 = n_u.indexOf("/", _i + 3);
	        if (_i2 < 0) _i2 = n_u.length;
	        return {
	            host: n_u.substring(_i + 3, _i2),
	            root: n_u.substring(0, _i2)
	        };
	    },
	    ajax: function (s, fun) {
	        var _h = this.getHostA(s.url);
	        this.preLoad(_h);
	        return { r: this.list[_h.host].ajax(s, fun), h: _h };
	    },
	    preLoad: function (_h) {
	        if (!this.list[_h.host]) this.list[_h.host] = new ClientProxy(this.getProxyUrl(_h));
	    },
	    getProxyUrl: function (_h) {
	        var url = "/ClientProxy.axd";
	        if (_h.host == "static." + domain) url = "/proxy.htm?" + domain;
	        return _h.root + url;
	    }
	});
	$.extend(ClientProxy.prototype, {
	    ajax: function (s, fun) {
	        if (!this.complite) {
	            if (!this.list) this.list = new Array();
	            var n_t = this;
	            var len = n_t.list.length;
	            var w = {
	                n_s: s,
	                n_f: function (r) {
	                    w.xhr = r;
	                    if (fun) fun(r);
	                },
	                abort: function () {
	                    if (w.xhr) w.xhr.abort();
	                    else n_t.list.reverse(len, 1);
	                }
	            };
	            n_t.list.push(w);
	            return w;
	        }
	        else {
	            return this.ajaxA(s, fun);
	        }
	    },
	    ajaxA: function (s, fun) {
	        var _this = this;
	        var r = null;
	        s.crossDomain = false;
	        s.xhr = function () {
	            r = _this.iframe.contentWindow.createXMLHttpRequest();
	            return r;
	        };
	        var r2 = _5Pai.ajax(s);
	        if (fun != null) fun(r2 || r);
	        return r2 || r;
	    },
	    docomplite: function () {
	        this.complite = true;
	        if (this.list) {
	            for (var i = 0; i < this.list.length; ++i) this.ajaxA(this.list[i].n_s, this.list[i].n_f);
	            this.list = undefined;
	        }
	    }
	});

//	function doAjaxSuccess(d, s, r, v) {
//		if (r) {
//			var order = r.getResponseHeader("_5Pai-Ajax-Order");
//			if (order == '1') {
//				if (window.alertAjax) {
//					_5Pai.set_login_callback(function () { return $.ajax(s); });
//					alertAjax("您还没有登录。正在加载登录界面…", "http://user." + domain + "/login/ajaxlogin.aspx");
//				}
//				else window.location = "http://user." + domain + "/login/login.aspx?__redirect=" + window.location.href;
//			}
//			else if (order == '2') {
//				alert2(d);
//			}
//			else if (order == "3") {
//				try {
//					new Function(d)();
//				}
//				catch (e2) {
//					if (s.error) s.error.call(this, r, "error", e2);
//				}
//			}
//			else if (order == "4") {
//				location = d;
//			}
//			else if (s.success) {
//				s.success.call(this, d, v, r);
//			}
//		}
//		else {
//			if (s.success) s.success.call(this, d, v, r);
//		}
//	};
//	function createAjaxProxy(n_s, _scs) {
//	    if (_5Pai.is5pai()) {
//	        document.domain = domain;
//	        var _d, _v, _sok = false;
//	        var _h = null, r = null;
//	        n_s.success = function (d, v) {
//	            if (_h && parent.ClientProxy.list[_h].isReplaceDomain && d) d = d.replace(/{Domain}/g, domain);
//	            if (r) _scs.call(this, d, v, r);
//	            else {
//	                _sok = true;
//	                _d = d;
//	                _v = v;
//	            }
//	        }
//	        var xx = ClientProxy.ajax(n_s, function (_sr) {
//	            r = _sr;
//	            if (_sok) _scs.call(n_s, _d, _v, _sr);
//	        });
//	        _h = xx.h.host;
//	        return xx.r;
//	    }
//	    else {
//	        n_s.url = proxyPath + "?url=" + encodeURIComponent(n_s.url);
//	        return _5Pai.ajax(n_s);
//	    }
//    }
	//重写ajax函数，执行一些必要的拦截
//    jQuery.ajax = function (s) {
//        if (!s || s.dataType == "script") return _5Pai.ajax(s);
//        var r = null;
//        var n_s = $.extend({}, s);
//        if (n_s.context) throw new Error("不支持context选项。");
//        var _scs = function (d, v, r2) {
//            doAjaxSuccess.call(this, d, s, r2 || r, v);
//        };
//        n_s.success = _scs;
//        var _url_h = ClientProxy.getHost(n_s.url);
//        if (_url_h && _url_h != location.host.toLowerCase()) {
//            return createAjaxProxy(n_s, _scs);
//        }
//        else {
//            try { r = _5Pai.ajax(n_s); }
//            catch (exp) { return createAjaxProxy(n_s, _scs); }
//        }
//        return r;
//    }

	jQuery.prototype.dialog = function (s) {
	    if (!this.length) return;
	    var x = this[0]._5pai_dialog;
	    if (s == "close" && x) x.b();
	    else if (s == "open" && x) x.a();
	    if (typeof s == "string") return x ? x.t : undefined;
	    if (!x) {
	        var t = $(jQuery.prototype.dialog.template);
	        t.find(".tc_pmt_wel_txt").append(this);
	        var d = t.find(".tc_pmt_btns");
	        var title = this.find(".ui-state-default").attr("title") || s.title || "提示";
	        t.find(".syspmt").html(title);
	        var makecall = function (f, caller) {
	            return function () { f.call(caller); };
	        }
	        x = { s: s, t: t,
	            a: function () {
	                this.t._5pai_alert(!this.s.modal);
	            },
	            b: function () {
	                if (this.s.beforeclose) this.s.beforeclose();
	                var cs = _5pai_alert.posLayer.children();
	                if (cs.length && cs[0] == this.t[0]) _5pai_alert.close();
	                if (x.c) $(document).unbind("keypress", x.c);
	            }
	        };
	        t.find(".tc_close").find("img")[0].onclick = function () {
	            x.b();
	            return false;
	        };
	        if (!s || !s.buttons) d.remove();
	        else {
	            for (var i in s.buttons) {
	                var b = $("<div class='tc_pmt_btn'>" + i + "</div>");
	                b[0].onclick = makecall(s.buttons[i], this);
	                if (!x.c) x.c = b[0].onclick;
	                //b[0].onmouseover = function () { this.className = 'tc_pmt_btnh'; }
	                //b[0].onmouseout = function () { this.className = 'tc_pmt_btn'; }
	                d.append(b);
	            }
	            if (x.c) {
	                var _xc = x.c;
	                x.c = function (e) { if (e.keyCode == 13) _xc(); };
	                $(document).bind("keypress", x.c);
	            }
	        }
	    }
	    if (s.autoOpen) x.a();
	    this[0]._5pai_dialog = x;
	    return this;
	}
//	jQuery.prototype.dialog.template =              //弹出模板
//		'<div class="tc_pmt_wrap clearfix">' + 
//			'<div class="tc_pmt_con">' +
//				'<div class="tc_pmt_wel">' +
//					'<div class="clearfix"><span class="syspmt">' +
//					'</span>' +
//					'<div class="tc_close">' +
//						'<a href="#"><img src="http://www.okpai.com/images/close_btn_normal.jpg" /></a>' +
//					'</div></div>' +
//					'<div class="tc_pmt_wel_txt">' +
//					'</div>' +
//				'</div>' +
//				'<div class="tc_pmt_btns clearfix">' + 
//				'</div>' +
//			'</div>' +
//		'</div>';

		
  jQuery.prototype.dialog.template=
     '<div class="tc_pmt_wrap clearfix">'+
         '<div class="tc_pmt_wel">'+
          '<div class="clearfix"><span class="syspmt"></span>'+
           '<span class="tc_close"><img src="http://www.okpai.com/images/close_btn_normal.jpg" /></span>'+
      '<div style="clear:left;"></div>'+
    '</div>'+
    '<div class="tc_pmt_wel_txt"></div>'+
    '<div style="clear:left;"></div>'+
  '</div>'+
  '<div class="tc_pmt_btns clearfix">'+
    
  '</div>'+
'</div>';

	window.alert = function (msg, _btn) {
		msg = msg + "";
		var _dialog = $('<div></div>');
		if (msg) msg = $.trim(msg);
		if (msg && msg.length > 0 && msg.charAt(0) != "<") msg = msg.replace(/\r\n/g, "<br />");
		_dialog.html(msg);
		var div, _r;
		if (!_btn) {
			_btn = {
				autoOpen: false,
				modal: true,
				buttons: {
					"确定": function () {
						$(this).dialog('close');
					}
				}
			};
		}
		else {
			var _btn_b = _btn.beforeclose;
			_btn.beforeclose = function () {
				if (div) div.remove();
				if (_r) _r.remove();
				if (_btn_b) _btn_b.apply(this, arguments);
			}
		}
		_r = _dialog.dialog(_btn);
		_dialog.dialog('open');
		return _r;
	};
	
	window.alert2 = function (d, t) {
		var _ttimer1 = null;
		var _dia = alert(d, {
			autoOpen: true,
			modal: false,
			buttons: {
				"我知道啦": function () {
					$(this).dialog('close');
				}
			},
			beforeclose: function () {
				try { clearTimeout(_ttimer1); }
				catch (_e) { }
			}
		});
		var _fra = _dia[0]._5pai_dialog;
		if (_fra) _fra = _fra.t;
		else _fra = _dia.parent();
		//_fra.css("border", "2px solid #333");
		_ttimer1 = setTimeout(function () {
			try { _fra.fadeOut(function () { _dia.dialog('close'); }); }
			catch (_e) { _dia.dialog('close'); }
		}, t || 3000);
    };
    
      window.alert1 = function (d, t) {
		//var _ttimer1 = null;
		var _dia = alert(d, {
			autoOpen: true,
			modal: false,
			buttons: {
			   "付款完成":function (){location="http://www.okpai.com/Personal_Account.aspx";//$(this).dialog('close');
			   },
			   "继续购买":function(){location="http://www.okpai.com/Buy_shoot_point.aspx";}
			},
			beforeclose: function () {
				try { //clearTimeout(_ttimer1);
				$("#showID").hide();
				 }
				catch (_e) { }
			}
		});
		var _fra = _dia[0]._5pai_dialog;
		if (_fra) _fra = _fra.t;
		else _fra = _dia.parent();
		_fra.css("border", "2px solid #333");
//		_ttimer1 = setTimeout(function () {
//			try { _fra.fadeOut(function () { _dia.dialog('close'); }); }
//			catch (_e) { _dia.dialog('close'); }
//		}, t || 3000);
    };
    
   
    
	jQuery.prototype._5pai_alert = function (_o) {
		_5pai_alert.call(this, _o);
	};

	window._5pai_alert = $.extend(function (_o) {
	    var _t = _5pai_alert;
	    if (_o == "close") _t.close();
	    else _t.show(this, _o);
	}, {
	    modelLayer: $('<div style="z-index: 2001; position:absolute;left:0px;top:0px;width:100%;bottom:0px;background:#000;opacity:.60;filter:Alpha(Opacity=60);"></div>'),
	    posLayer: $('<div style="z-index: 2002; position:absolute;left:0px;width:100%;"></div>'),
	    show: function (msg, _o) {
	        this.posLayer.css("visibility", "hidden");
	        this.posLayer.children().remove();
	        this.posLayer.append(msg);
	        if (_o == true) this.hideMode();
	        else {
	            $(document.body).append(this.modelLayer);
	            $("select").hide();
	            $("object").each(function (i, a) { a.style.display = "none"; });
	            $("embed").each(function (i, a) { a.style.display = "none"; });
	        }
	        $(document.body).append(this.posLayer);
	        this.showA();
	        this.posLayer.css("visibility", "visible");
	    },
	    showA: function () {
	        //this.modelLayer.width(document.documentElement.scrollWidth);
	        this.modelLayer.height(document.documentElement.scrollHeight);
	        this.posLayer.css("top", Math.max(0, (((window.innerHeight || document.documentElement.offsetHeight || document.body.offsetHeight) - this.posLayer.height()) / 2
				+ (document.documentElement.scrollTop || document.body.scrollTop))) + "px");
	        this.posLayer.children().css("margin", "0px auto");
	    },
	    hideMode: function () {
	        $("select").show();
	        $("object").each(function (i, a) { a.style.display = "block"; });
	        $("embed").each(function (i, a) { a.style.display = "block"; });
	        this.modelLayer.remove();
	    },
	    close: function () {
	        this.hideMode();
	        this.posLayer.remove();
	    }
	});
	String.prototype._5pai_alert = function (f) {
		var _l = $("<div style='width:300px;background:#ff9;padding:3px 10px;padding-right:15px;position:relative;'><div>"
			+ this + "<div><a style='color:red;display:block;right:5px;top:3px;position:absolute;' href='#'>X</a></div>");
		_l.find("a").bind("click", function () {
			_5pai_alert.close();
			if (f) f();
		});
		_l._5pai_alert();
    };
	window.changeTongue = function (tongueDiv, tongue1, tongueMain) {
		var action = tongueMain.attr("action");
		if (action == "0") {
			tongue1.css("visibility", "hidden");
			tongueDiv.removeClass("close_tongue").addClass("close_tongueopen");
			tongueMain.effect("slide", { direction: "right", mode: "show" }, 450, function () {
				tongue1.css("visibility", "visible");
				tongue1.show();
				tongueMain.attr("action", "1");
			});
		} else {
			tongue1.css("visibility", "hidden");
			tongueMain.effect("slide", { direction: "right", mode: "hide" }, 450, function () {
				tongue1.css("visibility", "visible");
				tongue1.show();
				tongueDiv.removeClass("close_tongueopen").addClass("close_tongue");
				tongueMain.attr("action", "0");
			});
		}
	};
	window.tongueAjax = function (ajax_url, complete) {
		if (tongueAjax.tongueDiv) tongueAjax.tongueDiv.remove();
		var tongueDiv = $('<div class="close_tongue clearfix">');
		tongueAjax.tongueDiv = tongueDiv;
		var tongue1 = $('<a class="close_tongue1"><span class="close_tongue_bg"></span></a>');
		var tongueMain = $('<div class="close_tonguem"action="0" ><div class="close_tonguembg"></div>');
		var tongueMain2 = $('<div class="close_tonguembd"></div>');
		var tongue2 = $('<div class="close_tongue2"><span class="close_tongue_bg"></span></div>');
		tongueMain.append(tongueMain2);
		tongueDiv.append(tongue1);
		tongueDiv.append(tongueMain);
		tongueDiv.append(tongue2);
		tongue1.click(function () { changeTongue(tongueDiv, tongue1, tongueMain); });
		tongue2.click(function () { changeTongue(tongueDiv, tongue1, tongueMain); });
		$(document.body).append(tongueDiv);
		tongueDiv.fadeIn();
		$.ajax({
			url: ajax_url,
			type: "post",
			success: function (d) {
				tongueMain2.html(d);
				changeTongue(tongueDiv, tongue1, tongueMain);
				if (complete) complete("success", d);
			},
			error: function (d) {
				alert(d.responseText);
				if (complete) complete("error");
			},
			complete: function () {
				if (complete) complete("complete");
			}
		});
	};
	window.alertAjax = function (loading, ajax_url, complete) {
		var r = null;
		var abort = false;
		if (loading) loading._5pai_alert(function () { abort = true; if (r) r.abort(); });

		r = $.ajax({
			url: ajax_url,
			type: "post",
			success: function (d) {
				if (abort) return;
				"已加载…"._5pai_alert();
				_5pai_alert.posLayer.css("visibility", "hidden");
				_5pai_alert.posLayer.html(d);
				_5pai_alert.showA();
				_5pai_alert.posLayer.css("visibility", "visible");
				if (complete) complete("success", d);
			},
			error: function (d) {
				if (abort) return;
				_5pai_alert.close();
				alert(d.responseText);
				if (complete) complete("error");
			},
			complete: function () {
				if (abort) return;
				if (complete) complete("complete");
			}
		});
	};

}

///以下是应用级别的通用

//用户登录
//$(function () {
//	if ($(".n_user").length) {
//		_5Pai.static_login_callbacks._top_user_info = function () {
//			if (!_5Pai.isLogin()) return;
//			$.ajax({
//			    url: "http://www." + _5Pai.domain + "/Part_Default/TopUserBox.aspx",
//				type: 'post',
//				success: function (d) {
//					$(".n_user").html(d);
//				}
//			});
//		}
//	}
//});

//加载广告
function loadAds(id) {
//	document.write('<div id="__ads_' + id + '"></div>');
//	$.ajax({
//		url: "http://info." + _5Pai.domain + "/ads/item.aspx?id=" + id,
//		success: function (d) { $("#__ads_" + id).html(d); }
//	});
}

//滚动效果

function n_rollsA(r, a, b, i, c, f) {
	clearTimeout(r[0].r_timer);
	r[0].scrollTop = b + (a - b) * i / c;
	if (i >= c) {
		if (f) f();
	}
	else {
		r[0].r_timer = setTimeout(function () {
			n_rollsA(r, a, b, i + 1, c, f);
		}, 45);
	}
}
function n_rollsB(r, s, m, t) {
	if (r.attr("n_rools") == "pause") {
		n_rollsC(r, s, m, t);
	}
	else {
		clearTimeout(r[0].s_timer);
		var r1 = r.find(s);
		if (r1.length < 2) return;
		n_rollsA(r, r.height(), 0, 0, m, function () {
			$(r1[0]).remove();
			r.append(r1[0]);
			r[0].scrollTop = 0;
			r[0].s_timer = setTimeout(function () {
				n_rollsB(r, s, m, t);
			}, t);
		});
	}
}
function n_rollsC(r, s, m, t) {
	clearTimeout(r[0].n_timer);
	r[0].n_timer = setTimeout(function () {
		n_rollsB(r, s, m, t);
	}, t);
}
function n_rolls(r, s, m, t) {
	r.bind("mouseover", function () { r.attr("n_rools", "pause"); });
	r.bind("mouseout", function () { r.attr("n_rools", ""); });
	n_rollsC(r, s, m, t);
}

//提示信息
function n_hint_a(a) {
	if (!a || !a.length) return;
	var h = $('<span class="n_hint_a" style="display:none;"><span class="n_hint_ab"></span><span class="n_hint_at"></span><span class="n_hint_ac"></span></span>');
	h.find(".n_hint_at").html(a[0].title);
	h.css("top", a.height() + 2 + "px");
	h.css("left", a.width() / 2 - 159 + "px");
	a.css("position", "relative");
	a.css("z-index", "501");
	a.append(h);
	h.fadeIn("fast");
	var timer = setTimeout(function () { h.fadeOut("fast", function () { h.remove(); delete h; }); }, 6000);
	h.find(".n_hint_ac").click(function () { clearTimeout(timer); timer = 0; h.remove(); delete h; });
	h.bind("mouseover", function () { clearTimeout(timer); timer = 0; });
	h.bind("mouseout", function () { timer = setTimeout(function () { h.fadeOut("fast", function () { h.remove(); delete h; }); }, 1000); });
}

//输入框内容提示
function inputClick(v, oid, str) {
	var _n = $("#" + oid);
	if (v) {
		if (!_n._5pai_init) {
			_n._5pai_init = true;
			if (_n.val() != "" && _n.val() == str) {
				_n.val("");
			}
			_n.removeClass("unchecked");
		}
	}
	else if (_n.val() == "") {
		if (_n._5pai_init) return;
		_n.val(str);
		_n.addClass("unchecked");
	}
	else if (_n.val() == str) {
		_n.val(str);
		_n.addClass("unchecked");
	}
}

function inputOnblur(oid, str) {
	var _n = $("#" + oid);
	if (_n.val() == "") {
		_n._5pai_init = false;
		inputClick(false, oid, str)
	}
}

function changInputVal_do(oid, str) {
	var _n = $("#" + oid);
	_n.focus(function () {
		if (_n.val() == str) {
			inputClick(true, oid, str);
		}
    });
    _n.click(function () {
        if (_n.val() == str) {
            inputClick(true, oid, str);
        }
    });
	_n.blur(function () {
		inputOnblur(oid, str);
	});
}


//加载分享
function loadShares(parent, title, content, img, url1) {
//	$.ajax({
//		url: "http://static." + _5Pai.domain + "/com/share.htm",
//		cache: false,
//		success: function (d) {
//			var url1 = url1 || window.location.href;
//			var content = content || $("meta[name=description]").attr("content") || document.title;
//			var title = title || document.title;
//			var img = img || "http://static." + _5Pai.domain + "/new/logo.png";
//			parent.append(
//				d.replace(/\{url\}/g, encodeURIComponent(url1))
//				.replace(/\{title\}/g, encodeURIComponent(title))
//				.replace(/\{content\}/g, encodeURIComponent(content))
//				.replace(/\{image\}/g, encodeURIComponent(img))
//				.replace(/\{url0\}/g, url1));
//		}
//	});
}
//function replaceDomainA(a, p) { if (a[p].indexOf("5pai.com") >= 0) a[p] = a[p].replace(/5pai.com/g, _5Pai.domain); }
//function replaceDomain(o, p) { o.each(function (i, a) { replaceDomainA(a, p); }); }
//function replaceDomainX() {
//    if (_5Pai.domain != "5pai.com") {
//        replaceDomain($("a"), "href");
//        var imgs = $("img");
//        replaceDomain(imgs, "src");
//        replaceDomain($("iframe"), "src");
//        imgs.bind("error", function () { replaceDomainA(this, "src"); });
//    }
//    document.write.unworking = true;
//}


//$(replaceDomainX);

//_5Pai._ducment_write = document.write;
//document.write = function (e) {
//    if (document.write.unworking) return;
//    //document.write.unworking会被其他地方用到，如果之后不用百度了，请删除下面一句就可以了
//    if (e.indexOf("baidu.com") > 0 && e.indexOf("script") > 0) document.write.unworking = true;
//    try { _5Pai._ducment_write(e); }
//    catch (exp) { _5Pai._ducment_write.apply(this, arguments); }
//}
