﻿function sug(ww) {
(function (){
	var H = navigator.userAgent.indexOf("MSIE") != -1 && !window.opera,
	K = (document.compatMode == "BackCompat");
	function F($) {
		return document.createElement($)
	}
	function G(_, A, $) {
		if (H) _.attachEvent("on" + A, (function(_) {
			return function() {
				$.call(_)
			}
		})(_));
		else _.addEventListener(A, $, false)
	}
	function A($) {
		if (H) $.returnValue = false;
		else $.preventDefault()
	}
	function I(D, _) {
		try {
			var B = document.styleSheets;
			if (!B || B.length <= 0) {
				var A = document.createElement("STYLE");
				A.type = "text/css";
				var C = document.getElementsByTagName("HEAD")[0];
				C.appendChild(A)
			}
			B = document.styleSheets;
			B = B[B.length - 1];
			if (H) B.addRule(D, _);
			else B.insertRule(D + " { " + _ + " }", B.cssRules.length)
		} catch($) {
			function E($) {
				var _;
				if (document.createStyleSheet) {
					_ = document.createStyleSheet();
					_.cssText = $
				} else {
					_ = document.createElement("style");
					_.type = "text/css";
					_.appendChild(document.createTextNode($));
					document.getElementsByTagName("head")[0].appendChild(_)
				}
			}
			E(D + " { " + _ + " }")
		}
	}
	var L = (function() {
		function _($) {
			var A = this.__MSG_QS__;
			if (!A[$]) A[$] = [];
			for (var B = 1, C = arguments.length, _; B < C; B++) A[$].push(arguments[B])
		}
		function $($) {
			var A = this.__MSG_QS__[$.type];
			if (A == null) return;
			for (var _ = 0, B = A.length; _ < B; _++) A[_].receiveMessage($)
		}
		return {
			initialize: function(A) {
				A.__MSG_QS__ = {};
				A.addMessageReceiver = _;
				A.dispatchMessage = $;
				return A
			}
		}
	})(),
	J = (function() {
		var $ = ww,
		_,
		F = 0,
		S = 0,
		N = "",
		R = "",
		Q,
		H = false,
		C = true;
		function E() {
			if (C) {
				J.dispatchMessage({
					type: "start"
				});
				C = false
			}
		}
		function B(B) {
			if (C) {
				J.dispatchMessage({
					type: "start"
				});
				C = false
			}
			B = B || window.event;
			if (B.keyCode == 9 || B.keyCode == 27) J.dispatchMessage({
				type: "hide_div"
			});
			if (B.keyCode == 13) {
				A(B);
				J.dispatchMessage({
					type: "key_enter"
				})
			}
			if (_.style.display != "none") {
				if (B.keyCode == 38) {
					A(B);
					J.dispatchMessage({
						type: "key_up"
					})
				}
				if (B.keyCode == 40) J.dispatchMessage({
					type: "key_down"
				})
			} else if (B.keyCode == 38 || B.keyCode == 40) J.dispatchMessage({
				type: "need_data",
				wd: $.value
			})
		}
		function I() {
			var _ = $.value;
			if (_ == N && _ != "" && _ != R && _ != Q) {
				if (S == 0) S = setTimeout(function() {
					J.dispatchMessage({
						type: "need_data",
						wd: _
					})
				},
				100)
			} else {
				clearTimeout(S);
				S = 0;
				N = _;
				if (_ == "") J.dispatchMessage({
					type: "hide_div"
				});
				if (R != $.value) R = ""
			}
		}
		function D() {
			F = setInterval(I, 10)
		}
		function P() {
			clearInterval(F)
		}
		function O() {
			if (H) {
				window.event.cancelBubble = true;
				window.event.returnValue = false;
				H = false
			}
		}
		function K(_) {
			$.blur();
			$.setAttribute("autocomplete", _);
			$.focus()
		}
		$.setAttribute("autocomplete", "off");
		G($, "keydown", B);
		G($, "mousedown", E);
		G($, "beforedeactivate", O);
		return L.initialize({
			receiveMessage: function(A) {
				switch (A.type) {
				case "div_ready":
					_ = A.sdiv;
					R = $.value;
					D();
					break;
				case "clk_submit":
					$.value = A.wd;
					break;
				case "ent_submit":
					J.dispatchMessage({
						type:
						"hide_div"
					});
					break;
				case "key_select":
					Q = A.selected;
					break;
				case "close":
					P();
					K("on");
					break;
				case "mousedown_tr":
					H = true;
					break
				}
			}
		})
	})(),
	D = (function() {
		var $, C = ww,
		S,
		I = -1,
		O,
		R,
		Z;
		function Y() {
			var $ = S.rows;
			for (var _ = 0; _ < $.length; _++) $[_].className = "mp3l"
		}
		function d() {
			if (typeof(S) != "undefined" && S != null && $.style.display != "none") {
				var _ = S.rows;
				for (var A = 0; A < _.length; A++) if (_[A].className == "mo") return [A, _[A].cells[0].innerHTML]
			}
			return [ - 1, ""]
		}
		function T() {
			if (H) Z.style.display = "none";
			$.style.display = "none"
		}
		function a() {
			Y();
			this.className = "mo"
		}
		function P($) {
			D.dispatchMessage({
				type: "mousedown_tr"
			});
			if (!H) {
				$.stopPropagation();
				$.preventDefault();
				return false
			}
		}
		function _($) {
			var _ = $;
			return function() {
				var $ = O[_];
				T();
				D.dispatchMessage({
					type: "clk_submit",
					oq: ww.value,
					wd: $,
					rsp: _
				})
			}
		}
		function N($) {
			$ = $ || window.event;
			A($);
			D.dispatchMessage({
				type: "close"
			});
			T();
			B();
			var _ = window["cl_" + (new Date()).getTime()] = new Image();
			_.src = "http://mp3.baidu.com/su.gif?m=off&t=" + new Date().getTime()
		}
		var U = F("div");
		C.parentNode.appendChild(U);
		var V = 0;
		function B() {
			/*var $=U;$.innerHTML="&nbsp;\u63d0\u793a\u529f\u80fd\u5df2\u5173\u95ed,\u60a8\u53ef\u4ee5\u5728\u9ad8\u7ea7\u641c\u7d22\u4e2d\u518d\u6b21\u542f\u7528";$.style.cssText="display:none;position:absolute;left:0;background:#FBF2B0;height:22px;line-height:22px;-moz-user-select:none";$.style.width=C.offsetWidth+"px";$.style.top=(K?C.offsetHeight+3:C.offsetHeight+2)+"px";$.style.display="block";V=setTimeout(W,3000)*/
		}
		function W() {
			U.style.display = "none";
			clearTimeout(V)
		}
		G(document, "mousedown", b);
		function b($) {
			$ = $ || window.event;
			var _ = $.target || $.srcElement;
			if (_ != U) W()
		}
		function J() {
			var _ = [C.offsetWidth, C.offsetHeight];
			$.style.width = ((H && K) ? _[0] : _[0] - 2) + "px";
			$.style.top = ((H && K) ? _[1] : _[1] - 1) + "px";
			$.style.display = "block"
		}
		function E() {
			S = F("TABLE");
			S.id = "st";
			S.cellSpacing = 0;
			S.cellPadding = 2;
			var E = F("tbody");
			S.appendChild(E);
			for (var L = 0, A = O.length; L < A; L++) {
				var I = E.insertRow( - 1);
				G(I, "mouseover", a);
				G(I, "mouseout", Y);
				G(I, "mousedown", P);
				G(I, "click", _(L));
				var B = I.insertCell( - 1);
				B.innerHTML = O[L].replace(/&/g, "&amp;")
			}
			var K = E.insertRow( - 1);
			G(K, "mousedown", P);
			B = K.insertCell( - 1);
			B.style.textAlign = "right";
			var D = F("A");
			D.href = "javascript:void(0)";
			D.innerHTML = "\u5173\u95ed";
			D.style.fontSize = "12px";
			G(D, "click", N);
			B.appendChild(D);
			$.innerHTML = "";
			$.appendChild(S);
			J();
			if (H) {
				Z.style.display = "block";
				Z.style.left = 0 + "px";
				Z.style.top = C.offsetHeight + "px";
				Z.style.width = C.offsetWidth + "px";
				Z.style.height = $.offsetHeight - 10 + "px"
			}
		}
		function X() {
			I = d()[0];
			if (I == -1) D.dispatchMessage({
				type: "submit"
			});
			else D.dispatchMessage({
				type: "ent_submit",
				"oq": R,
				wd: d()[1],
				rsp: I
			})
		}
		function c() {
			I = d()[0];
			Y();
			if (I == 0) {
				D.dispatchMessage({
					type: "key_select",
					selected: ""
				});
				ww.value = R;
				I--
			} else {
				if (I == -1) I = O.length;
				I--;
				var $ = S.rows[I];
				$.className = "mo";
				D.dispatchMessage({
					type: "key_select",
					selected: O[I]
				});
				ww.value = O[I]
			}
		}
		function Q() {
			I = d()[0];
			Y();
			if (I == O.length - 1) {
				D.dispatchMessage({
					type: "key_select",
					selected: ""
				});
				ww.value = R;
				I = -1
			} else {
				I++;
				var $ = S.rows[I];
				$.className = "mo";
				D.dispatchMessage({
					type: "key_select",
					selected: O[I]
				});
				ww.value = O[I]
			}
		}
		return L.initialize({
			receiveMessage: function(_) {
				switch (_.type) {
				case "div_ready":
					$ = _.sdiv;
					Z = _.frm;
					break;
				case "give_data":
					R = _.data.q;
					O = _.data.s;
					if (O.length != 0) E();
					else T();
					break;
				case "key_enter":
					X();
					break;
				case "key_up":
					c();
					break;
				case "key_down":
					Q();
					break;
				case "hide_div":
					T();
					break;
				case "mousedown_other":
					T();
					break;
				case "window_blur":
					T();
					break;
				case "need_resize":
					J();
					break
				}
			}
		})
	})(),
	C = (function() {
		var C = document.f1;
		function B() {
			/*if(syn(C))C.submit()*/
		}
		function $(_, $) {
			A(_, $);
			B()
		}
		function _($, A) {
			var _ = F("INPUT");
			_.type = "hidden";
			_.name = $;
			_.value = A;
			return _
		}
		function A(A, $) {
			/*if(typeof C.oq=="undefined")C.appendChild(_("oq",A));else C.oq.value=A;if(typeof C.f=="undefined")C.appendChild(_("f",3));else C.f.value=3;if(typeof C.rsp=="undefined")C.appendChild(_("rsp",$));else C.rsp.value=$*/
		}
		return L.initialize({
			receiveMessage: function(_) {
				switch (_.type) {
				case "clk_submit":
				case "ent_submit":
					$(_.oq, _.rsp);
					break;
				case "submit":
					B();
					break
				}
			}
		})
	})(),
	B = (function() {
		var _ = {};
		function A($) {
			if (typeof _[$] == "undefined") B.dispatchMessage({
				type: "request_data",
				wd: $
			});
			else B.dispatchMessage({
				type: "give_data",
				data: _[$]
			})
		}
		function $($) {
			_[$.q] = $;
			B.dispatchMessage({
				type: "give_data",
				data: _[$.q]
			})
		}
		return L.initialize({
			receiveMessage: function(_) {
				switch (_.type) {
				case "response_data":
					$(_.data);
					break;
				case "need_data":
					A(_.wd);
					break
				}
			}
		})
	})(),
	_ = (function() {
		var $, A;
		function B(A) {
			_.dispatchMessage({
				type: "need_cookie"
			});
			if ($) document.body.removeChild($);
			$ = F("SCRIPT");
			$.src = "http://nssug.baidu.com/su?wd=" + encodeURIComponent(A) + "&prod=mp3&t=" + (new Date()).getTime();
			$.charset = "gb2312";
			document.body.appendChild($)
		}
		return L.initialize({
			receiveMessage: function($) {
				switch ($.type) {
				case "request_data":
					B($.wd);
					break;
				case "give_cookie":
					A = $.sug;
					break
				}
			}
		})
	})();
	if (typeof window.baidu != "object" || window.baidu == null) window.baidu = {};
	baidu.sug = function($) {
		baidu.dispatchMessage({
			type: "response_data",
			data: $
		})
	};
	baidu.initSug = function() {
		baidu.dispatchMessage({
			type: "init"
		})
	};
	L.initialize(baidu);
	var E = (function() {
		function $() {
			if (navigator.cookieEnabled) document.cookie = "sug=0; expires=Thu, 08 Jul 2038 10:05:14 GMT; path=/"
		}
		function _() {
			var $ = (navigator.cookieEnabled && /sug=(\d)/.test(document.cookie) ? RegExp.$1: 3);
			E.dispatchMessage({
				type: "give_cookie",
				sug: $
			})
		}
		return L.initialize({
			receiveMessage: function(A) {
				switch (A.type) {
				case "close":
					$();
					break;
				case "need_cookie":
					_();
					break
				}
			}
		})
	})(),
	$ = (function() {
		var A = ww,
		B,
		C = document.f1,
		E;
		function D() {
			if (B.offsetWidth != 0 && A.offsetWidth != B.offsetWidth) $.dispatchMessage({
				type: "need_resize"
			})
		}
		function _() {
			B = F("DIV");
			B.id = "sd_" + new Date().getTime();
			B.style.display = "none";
			A.parentNode.appendChild(B);
			if (H) {
				E = F("IFRAME");
				E.style.display = "none";
				E.style.position = "absolute";
				/*B.parentNode.insertBefore(E,B)*/
			}
		}
		function N(_) {
			_ = _ || window.event;
			var C = _.target || _.srcElement;
			if (C == A) return;
			while (C = C.parentNode) if (C == B) return;
			$.dispatchMessage({
				type: "mousedown_other"
			})
		}
		function J() {
			$.dispatchMessage({
				type: "window_blur"
			})
		}
		function K() {
			$.dispatchMessage({
				type: "div_ready",
				sdiv: B,
				frm: E
			});
			setInterval(D, 100);
			G(document, "mousedown", N);
			G(window, "blur", J);
			var nug = navigator.userAgent.toLowerCase();
			if (nug.indexOf("applewebkit") != -1) {
				var leftstr = "left:0px;";
			} else {
				var leftstr = "left:0px;";
			}
			I("#" + B.id, "border:1px solid #817F82;position:absolute;z-index:9999;top:30px;" + leftstr + "*left:0px!important;text-align:left;");
			I("#" + B.id + " table", "width:100%;background:#fff;cursor:default");
			I("#" + B.id + " td", "font:14px verdana;height:22px;line-height:22px;");
			I("tr.mo", "background-color:#36c;color:#fff;overflow:hidden;");
			I("tr.mo td", "color:#fff");
			I("tr.mp3l", "background-color:#fff;color:#000;overflow:hidden;")
		}
		return L.initialize({
			receiveMessage: function($) {
				switch ($.type) {
				case "start":
					K();
					break;
				case "init":
					_();
					break
				}
			}
		})
	})();
	J.addMessageReceiver("need_data", B);
	J.addMessageReceiver("close_div", D);
	J.addMessageReceiver("key_enter", D);
	J.addMessageReceiver("key_up", D);
	J.addMessageReceiver("key_down", D);
	J.addMessageReceiver("hide_div", D);
	J.addMessageReceiver("start", $);
	B.addMessageReceiver("request_data", _);
	B.addMessageReceiver("give_data", D);
	baidu.addMessageReceiver("response_data", B);
	baidu.addMessageReceiver("init", $);
	D.addMessageReceiver("clk_submit", J, C);
	D.addMessageReceiver("ent_submit", J, C);
	D.addMessageReceiver("submit", C);
	D.addMessageReceiver("key_select", J);
	D.addMessageReceiver("close", J, E);
	D.addMessageReceiver("mousedown_tr", J);
	$.addMessageReceiver("mousedown_other", D);
	$.addMessageReceiver("need_resize", D);
	$.addMessageReceiver("div_ready", J, D);
	$.addMessageReceiver("window_blur", D);
	_.addMessageReceiver("need_cookie", E);
	E.addMessageReceiver("give_cookie", _);
	window.baidu.initSug()
})();
}
