
var TB = TB || {};
TB.Header = function () {
	var f = function (v) {
		return typeof (v) != "string" ? v : document.getElementById(v);
	};
	var s = navigator.userAgent.toLowerCase();
	var n = /msie/.test(s) && !/opera/.test(s);
	var k = n && !/msie 7/.test(s) && !/msie 8/.test(s);
	var g = {getCookie:function (w) {
		var v = document.cookie.match("(?:^|;)\\s*" + w + "=([^;]*)");
		return (v && v[1]) ? decodeURIComponent(v[1]) : "";
	}, parseQueryParams:function (B) {
		var y = {};
		var w = B.split("&");
		for (var z = 0, A = w.length; z < A; ++z) {
			var x = w[z], C = x.search("=");
			var D = x.substring(0, C);
			var v = x.substring(C + 1, x.length);
			y[decodeURIComponent(D)] = decodeURIComponent(v);
		}
		return y;
	}, trim:function (v) {
		return v.replace(/^\s+|\s+$/g, "");
	}, hasClass:function (w, v) {
		w = f(w);
		if (!w || !v || !w.className) {
			return false;
		}
		return (" " + w.className + " ").indexOf(" " + v + " ") > -1;
	}, addClass:function (w, v) {
		w = f(w);
		if (!w || !v) {
			return;
		}
		if (this.hasClass(w, v)) {
			return;
		}
		w.className += " " + v;
	}, removeClass:function (w, v) {
		w = f(w);
		if (!this.hasClass(w, v)) {
			return;
		}
		w.className = w.className.replace(new RegExp(v, "g"), "");
		if (!this.trim(w.className)) {
			w.removeAttribute(n ? "className" : "class");
		}
	}, addEvent:function (x, w, v) {
		x = f(x);
		if (!x || !w || typeof (v) != "function") {
			return;
		}
		if (x.addEventListener) {
			x.addEventListener(w, v, false);
		} else {
			if (x.attachEvent) {
				x.attachEvent("on" + w, v);
			}
		}
	}, stopEvent:function (v) {
		if (v.stopPropagation) {
			v.stopPropagation();
		} else {
			v.cancelBubble = true;
		}
		if (v.preventDefault) {
			v.preventDefault();
		} else {
			v.returnValue = false;
		}
	}, escapeHTML:function (w) {
		var x = document.createElement("div");
		var v = document.createTextNode(w);
		x.appendChild(v);
		return x.innerHTML;
	}};
	var t = g.getCookie("_nk_");
	var i = g.getCookie("uc1");
	var d = g.parseQueryParams(i);
	var p = g.getCookie("_l_g_") && t;
	var o = parseInt(d._msg_) || 0;
	var j = new Date().getTime();
	var c = document.getElementsByTagName("script");
	var q = c[c.length - 1].getAttribute("version") == "co";
	var r = (document.location.href.indexOf("https://") === 0);
	function a(x) {
		x = f(x);
		if (!x) {
			return;
		}
		var w = x.children[1];
		if (!w) {
			return;
		}
		if (!r) {
			var v = document.createElement("iframe");
			v.src = "about: blank";
			v.className = "menu-list";
			v.style.border = "none";
			x.insertBefore(v, w);
			x.iframe = v;
		}
		x.menulist = w;
		x.onmouseenter = function () {
			g.addClass(this, g.hasClass(this, "forum-v2") ? "forum-hover" : "hover");
			if (r) {
				return;
			}
			this.iframe.style.height = (parseInt(this.menulist.offsetHeight) - 12) + "px";
			this.iframe.style.width = this.menulist.offsetWidth;
		};
		x.onmouseleave = function () {
			g.removeClass(this, g.hasClass(this, "forum-v2") ? "forum-hover" : "hover");
		};
	}
	function m(y, x, v) {
		var w = document.createElement("option");
		w.innerHTML = y;
		w.value = x;
		w.className = v || "";
		return w;
	}
	function e(z) {
		var x = f(z);
		if (!x) {
			return;
		}
		var y = x.q;
		if (!y) {
			return;
		}
		var w = x.elements.search_type;
		var v = x.elements.cat;
		v.appendChild(m("&nbsp;\u6570\u5b57\u7535\u5f71/\u7535\u89c6\u5267/\u7efc\u827a", "special0", "S"));
		v.appendChild(m("&nbsp;\u7535\u5b50\u6742\u5fd7/\u65f6\u5c1a\u751f\u6d3b/\u5a31\u4e50\u524d\u6cbf", "special1", "S"));
		g.addEvent(w, "change", function () {
			if (w.value == "dating") {
				g.addClass(v, "hidden");
			} else {
				g.removeClass(v, "hidden");
			}
		});
		g.addEvent(x, "submit", function (G) {
			var C = w.value;
			if (C == "item" && y.value == "" && v.value == "") {
				x.action = "http://list.taobao.com/browse/cat-0.htm";
			} else {
				if (v.value.indexOf("special") > -1) {
					x.method = "post";
					x.action = ["http://video.taobao.com/searchlist.php", "http://zazhi.taobao.com/search"][v.value.replace("special", "")] + "?q=" + x.q.value;
				} else {
					if (C == "mall") {
						x.action = "http://list.mall.taobao.com/search_dispatcher.htm";
					} else {
						if (C == "shop") {
							var E = "";
							if (x.elements.page_type) {
								E = x.elements.page_type.value;
							}
							var F = 3;
							if (E === "FP") {
								F = 1;
							} else {
								if (E === "SRP") {
									F = 2;
								}
							}
							if (!x.elements.stat) {
								if (n) {
									var B = document.createElement("<input name=\"stat\" >");
								} else {
									var B = document.createElement("input");
									B.name = "stat";
								}
								B.type = "hidden";
								x.appendChild(B);
							}
							x.elements.stat.value = F;
							if (!x.elements.catName) {
								if (n) {
									var D = document.createElement("<input name=\"catName\" >");
								} else {
									var D = document.createElement("input");
									D.name = "catName";
								}
								D.type = "hidden";
								x.appendChild(D);
							}
							x.elements.catName.value = v[v.selectedIndex].innerHTML.replace("&nbsp;", "");
							x.action = "http://shopsearch.taobao.com/browse/shop_search.htm";
						} else {
							if (C == "dating") {
								if (y.value == "") {
									x.action = "http://dating.taobao.com";
								} else {
									x.action = "http://dating.taobao.com/search_question.htm";
								}
							} else {
								if (C == "global") {
									x.promote.value = "2097152";
								} else {
									if (C == "auction") {
										x.atype.value = "a";
										x.isnew.value = "1,3";
									}
								}
							}
						}
					}
				}
			}
			var H = v.options[v.selectedIndex];
			if (!H || !H.className) {
				return;
			}
			var A = H.className.split("^");
			if (!A || A.length < 2) {
				return;
			}
			x.elements.prop.value = A[0];
			x.elements.ppath.value = A[1];
		});
	}
	function b(C) {
		var z = f(C);
		if (!z) {
			return;
		}
		var A = z.q;
		if (!A) {
			return;
		}
		if (!(window.TB && TB.Suggest)) {
			return;
		}
		var w = new TB.Suggest(A, "http://suggest.taobao.com/sug", {resultFormat:""});
		var B = z.ssid;
		if (B) {
			setTimeout(function () {
				B.value = "s5-e";
			}, 0);
			B.setAttribute("autocomplete", "off");
			w.subscribe("onItemSelect", function () {
				if (B.value.indexOf("-p1") == -1) {
					B.value += "-p1";
				}
				if (z.cat && z.cat.value === "50017708" || z.cat.value === "50016871" || z.cat.value === "99" || z.cat.value === "40") {
					return;
				}
				if (z.viewIndex) {
					z.viewIndex.value = "7";
				} else {
					if (n) {
						var D = document.createElement("<input name=\"viewIndex\" >");
					} else {
						var D = document.createElement("input");
						D.name = "viewIndex";
					}
					D.type = "hidden";
					D.value = "7";
					z.appendChild(D);
				}
				if (z.sort) {
					z.sort.value = "coefp";
				} else {
					if (n) {
						var E = document.createElement("<input name=\"sort\" >");
					} else {
						var E = document.createElement("input");
						E.name = "sort";
					}
					E.type = "hidden";
					E.value = "coefp";
					z.appendChild(E);
				}
			});
		}
		var x = z.elements.search_type;
		var v = function () {
			return x.value;
		};
		var y = w._needUpdate;
		w._needUpdate = function () {
			var D = v();
			return (D === "item" || D === "mall") && y.call(w);
		};
	}
	function u(v) {
		v = f(v);
		if (v && v.href) {
			v.href += (v.href.indexOf("?") != -1 ? "&" : "?") + "nekot=" + j;
		}
	}
	function h(w) {
		if (d._msg_v != "false") {
			var x = document.createElement("embed");
			x.src = "http://www.taobao.com/sounds/newpm.swf";
			x.setAttribute("loop", "false");
			x.setAttribute("hidden", "true");
			x.setAttribute("position", "absolute");
			x.setAttribute("volume", "50");
			x.setAttribute("autostart", "true");
			x.setAttribute("mastersound", "mastersound");
			x.style.width = "0";
			x.style.height = "0";
			x.style.display = "none";
			var v = f(w);
			if (v) {
				v.appendChild(x);
			}
		}
	}
	function l(v) {
		var w = f(v);
		if (!w) {
			return;
		}
		g.addEvent(w, "click", function (y) {
			g.stopEvent(y);
			var x = w.href;
			new Image().src = "//taobao.alipay.com/user/logout.htm";
			setTimeout(function () {
				location.href = x;
			}, 20);
		});
	}
	return {init:function () {
		if (k) {
			a("J_MyTaoBao");
			a("J_ForumInHeader");
			a("J_MoreService");
		}
		setTimeout(function v() {
			if (typeof v.count == "undefined") {
				v.count = 0;
			}
			v.count++;
			if (!(f("search") && f("q") && window.TB && TB.Suggest)) {
				if (v.count > 100) {
					return;
				}
				setTimeout(arguments.callee, 200);
			} else {
				e("search");
				b("search");
			}
		}, 200);
		u("J_NavCart");
		u("J_NavFavorite");
		u("J_MyTaobao");
		l("J_Logout");
	}, writeLoginInfo:function (z) {
		z = z || {};
		var A = z.memberServer || "http://member1.taobao.com";
		var x = z.loginServer || A;
		var D = z.loginUrl || x + "/member/login.jhtml?f=top";
		var w = location.href;
		var F = /^http.*(\/member\/login\.jhtml)$/i;
		if (F.test(w)) {
			w = "";
		}
		var v = z.redirectUrl || w;
		if (v) {
			D += "&redirectURL=" + encodeURIComponent(v);
		}
		var C = z.logoutUrl || x + "/member/logout.jhtml?f=top";
		var B = A + "/member/newbie.htm";
		var E = A + "/message/list_private_msg.htm?t=" + j;
		var G = "http://jianghu.taobao.com/admin/home.htm?t=" + j;
		var y = "";
		if (p) {
			y = "\u60a8\u597d\uff0c<a class=\"user-nick\" href=\"" + G + "\" target=\"_top\">" + g.escapeHTML(unescape(t.replace(/\\u/g, "%u"))) + "</a>\uff01";
			y += "<a id=\"J_Logout\" href=\"" + C + "\" target=\"_top\">[\u9000\u51fa]</a>";
			y += "<a href=\"" + E + "\" target=\"_top\">\u7ad9\u5185\u4fe1";
			if (o) {
				y += "(" + o + ")";
			}
			y += "</a>";
		} else {
			y = "\u60a8\u597d\uff0c\u6b22\u8fce\u6765\u6dd8\u5b9d\uff01<a href=\"" + D + "\" target=\"_top\">[\u8bf7\u767b\u5f55]</a>";
			y += "<a href=\"" + B + "\" target=\"_top\">[\u514d\u8d39\u6ce8\u518c]</a>";
		}
		document.write(y);
	}};
}();
(function () {
	if (document.location.href.indexOf("https://") === 0) {
		return;
	}
	var a = document, c = a.getElementsByTagName("head")[0], b = a.createElement("script");
	b.src = "http://a.tbcdn.cn/app/search/monitor.js?t=20091221.js";
	c.appendChild(b);
})();


