jQuery.fn.extend({
	addInputSuggest: function(A) {
		return this.each(function() {
			var L = this.getAttribute("ajaxurl");
			var J = A.configRenderData || Q;
			var B = A.defaultFocus || "";
			var D = A.setULId || "";
			var E = this.value;
			var F = this;
			var I = $(this);
			var P = $("#search_form")[0];
			$(P).append('<input  class= "j-type" type="hidden" name="t" value="" />');
			P.onsubmit = function() {
				if (F.value.replace(/^\s+|\s+$/g, "") == "" || F.value == E) {
					return false
				}
			};
			var K = A.suggestUlClass || "suggestUlClass";
			var M = "";
			$("body").prepend("<ul id='" + D + "' style='display:none' class='" + K + " '>init...</ul>");
			var C = document.getElementById(D);
			var N = $(C);
			N.get(0).style.left = (parseInt(I.offset().left)) + "px";
			N.get(0).style.top = parseInt(I.offset().top + F.offsetHeight) + "px";
			C.style.visibility = "hidden";
			C.style.display = "block";
			$(window).resize(function() {
				N.get(0).style.left = (parseInt(I.offset().left)) + "px";
				N.get(0).style.top = parseInt(I.offset().top + F.offsetHeight) + "px"
			});
			function Q(R) {
				var U = R.r;
				var S = [];
				for (var T = 0; T < (U.length > 10 ? 10 : (U.length)); T++) {
					S.push('<li class="clearfix" searchkey="' + U[T].item + '">' + U[T].item + "</li>")
				}
				return S.join("")
			}
			var G = function(R) {
				return function(T) {
					var S = J(T);
					R.innerHTML = S;
					S.length == 0 ? R.style.visibility = "hidden": R.style.visibility = "visible"
				}
			} (C);
			function H() {
				this.value == E ? this.value = "": "";
				this.value == "" && (C.style.visibility = "hidden");
				if (L && this.value != "") {
					$.ajax({
						url: L + encodeURIComponent(F.value),
						dataType: "jsonp",
						scriptCharset: "utf-8",
						success: G
					})
				}
			}
			I.keyup(function(R) {
				if (R.keyCode != 38 && R.keyCode != 40 && F.value.replace(/^\s+|\s+$/g, "") != "") {
					H()
				} else {
					if (F.value.replace(/^\s+|\s+$/g, "") == "") {
						C.style.visibility = "hidden"
					}
				}
				this.value == E ? I.addClass("color-grey") : I.removeClass("color-grey")
			});
			function O(T) {
				if (M == "") {
					M = C.getElementsByTagName("LI")[0]
				} else {
					var R = M;
					$(R).removeClass("selected");
					if (T == "up") {
						M = $(M).prev()[0];
						if (!M) {
							M = $(C).find("li:last").get(0)
						}
					} else {
						M = $(R).next()[0];
						if (!M) {
							M = C.getElementsByTagName("LI")[0]
						}
					}
				}
				F.value = M.getAttribute("searchkey");
				var S = $(P).find(".j-type")[0];
				S.value = 1;
				$(M).addClass("selected")
			}
			I.keydown(function(R) {
				var S = R.keyCode;
				if (C.style.display == "block") {
					switch (S) {
					case 38:
						O("up");
						break;
					case 40:
						O("down");
						break
					}
				} else {
					M = "";
					var T = $(P).find(".j-type")[0];
					T = ""
				}
			});
			$(C).mouseover(function(R) {
				if (R.target.tagName == "LI") {
					M && $(M).removeClass("selected");
					M = R.target;
					$(M).addClass("selected")
				} else {
					if (R.target.parentNode.tagName == "LI") {
						M && $(M).removeClass("selected");
						M = R.target.parentNode;
						$(M).addClass("selected")
					}
				}
			});
			$(C).mouseout(function(R) {
				if (R.target.tagName == "LI") {
					M && $(M).removeClass("selected");
					M = ""
				}
			});
			$(C).click(function(R) {
				var S = R.target.tagName == "LI" ? R.target: R.target.parentNode;
				F.value = S.getAttribute("searchkey");
				var T = $(P).find(".j-type")[0];
				T.value = 1;
				P.submit();
				T.value = 0;
				C.style.visibility = "hidden"
			});
			I.focus(function() {
				if (F.value.replace(/^\s+|\s+$/g, "") == E) {
					this.value = "";
					I.removeClass("color-grey")
				}
			});
			I.blur(function() {
				$(this).addClass("color-black");
				if (F.value.replace(/^\s+|\s+$/g, "") == "") {
					I.addClass("color-grey");
					this.value = E
				}
			});
			$("body").bind("click",
			function() {
				C.style.visibility = "hidden";
				M = ""
			});
			I.addClass("color-grey")
		})
	}
});
$(function() {
	$("#search_form .ipt").addInputSuggest({
		suggestUlClass: "suggest",
		defaultFocus: true,
		setULId: "sugUl",
		configRenderData: function(I) {
			var H = I.result;
			var G = [];
			$.each(H,
			function() {
				G.push('<li class="cf" searchkey="' + this[0] + '"><span class="fl">' + this[0] + '</span><span class="fr">\u7ea6 ' + this[1] + " \u4e2a\u5b9d\u8d1d</span></li>")
			});
			return G.join("")
		}
	});
	var C = 0;
	A();
	function E(G) {
		$(".slide_imgs").animate({
			marginLeft: -G * 490
		},
		500);
		clearTimeout(C);
		A()
	}
	function A() {
		C = setTimeout(function() {
			if ($(".slide_pages:visible").size()) {
				var G = $(".slide_pages .cur")
			} else {
				var G = $(".slide_pages_ie .cur")
			}
			if (G.next().size()) {
				var H = G.next()
			} else {
				var H = G.parent().children(":first")
			}
			H.mouseover()
		},
		7000)
	}
	$(".slide_pages li").mouseover(function() {
		$(".slide_pages li").removeClass("cur");
		if ($(".slide_imgs").filter(":animated").size()) {
			$(".slide_imgs").stop()
		}
		E($(this).addClass("cur").text() - 1)
	});
	$(".slide_pages_ie li").mouseover(function() {
		$(".slide_pages_ie li").removeClass("cur").find(".sp_fill").attr({
			color: "#fff",
			opacity: 0.7
		});
		$(this).addClass("cur").find(".sp_fill").attr({
			color: "#F58141",
			opacity: 1
		});
		if ($(".slide_imgs").filter(":animated").size()) {
			$(".slide_imgs").stop()
		}
		E($(this).text() - 1)
	});
	function F(H) {
		var J = $("#pop_doing");
		if (H.hasClass(".doing_ico")) {
			var G = H.parent().attr("href")
		} else {
			var G = H.attr("href")
		}
		J.find("a").attr("href", G).find("img").attr("alt", "\u5f39\u51fa\u6298\u6263").attr("src", H.attr("data-img")).show();
		var I = calcPos(J, H, 17);
		J.css({
			top: I.tto,
			left: I.lto
		}).show()
	}
	$(".cg_show_doing,.doing_ico").click(function() {
		F($(this));
		return false
	});
	$(".sb_get_code").click(function() {
		var H = $("#pop_get_code");
		var G = calcPos(H, $(this), 17);
		H.css({
			top: G.tto,
			left: G.lto
		}).show();
		return false
	});
	$("#pop_get_code").click(function(G) {
		G.stopPropagation()
	});
	window.calcPos = function(H, S, M) {
		var J = $(S).offset(),
		P = $(window),
		L = J.top - P.scrollTop(),
		Q = J.left - P.scrollLeft(),
		G = P.height(),
		N = P.width(),
		R = "",
		O = "",
		K = 0,
		I = 0;
		if (N / 1.5 > Q) {
			K = J.left - 40;
			I = 34 + ($(S).width() / 2);
			R = "left"
		} else {
			K = J.left - H.width() + $(S).width() + 40;
			I = 34 + ($(S).width() / 2);
			R = "right"
		}
		if (G / 1.7 > L) {
			tto = J.top + M;
			O = "top"
		} else {
			tto = J.top - H.height();
			O = "bottom"
		}
		$(".arr_wrap", H).attr("class", "arr_wrap arr_" + O + "_" + R).find(".arr_bg,.arr").css({
			left: "auto",
			right: "auto"
		}).css(R, I);
		return {
			lto: K,
			tto: tto
		}
	};
	$(".header_right_switch li").click(function() {
		$(this).addClass("cur").siblings().removeClass("cur");
		$("#search_form").attr("flag", $(this).html()).attr("action", $(this).attr("data-act")).find(".ipt").focus()
	});
	$(".cg_cnt li").hover(function() {
		$(this).addClass("cg_hover")
	},
	function() {
		$(this).removeClass("cg_hover")
	});
});
$(function() {
	if ($(".cg_cnt").length != 0 || $(".cg_discount").length != 0) {
		$('<a class="" id="back_top"></a>').appendTo("body");
		var D = $("#back_top");
		var C = $(".cg_cnt").length != 0 ? $(".cg_cnt") : $(".cg_discount");
		var F = !!window.ActiveXObject;
		var H = F && !window.XMLHttpRequest;
		if (H) {
			D.get(0).style.position = "absolute"
		}
		var B = C.offset();
		var G = document.documentElement;
		var E = document.body;
		G.scrollTop == 0 && E.scrollTop == 0 ? D.hide() : D.show();
		function A() {
			setTimeout(function() {
				D.css({
					top: G.clientHeight + G.scrollTop - 208,
					left: C.offset().left + C.width() + 3
				})
			},
			0)
		}
		A();
		$(window).resize(function() {
			A()
		});
		$(window).scroll(function() {
			var J = G.scrollTop == 0 ? E.scrollTop == 0 ? 0 : E.scrollTop: G.scrollTop;
			var I = G.clientHeight == 0 ? E.clientHeight: G.clientHeight;
			if (H) {
				D.css({
					top: I + J - 208
				})
			}
			G.scrollTop == 0 && E.scrollTop == 0 ? D.fadeOut(300) : D.fadeIn(300)
		});
		D.click(function() {
			$("html,body").animate({
				scrollTop: "0px"
			},
			500);
			return false
		})
	}
});
$(".like").live({
  mouseover: function() {
    $(this).addClass("hov");$(this).find(".num").fadeIn();
  },
  mouseout: function() {
    $(this).removeClass("hov");$(this).find(".num").fadeOut();
  },
  click: function() {
    var id =$(this).attr("id");
	var _this=$(this);
	$.ajax({
		type: "POST",
		url: "/index.php?m=ajax&g=like&d=up&_t="+Math.random(),
		data:'id='+id,
		dataType: "JSON",
		success: function(msg){
			if(msg.status==1){
				$("#like_"+id).text(msg.like);
			}else{
				_this.find(".num").text("+0");
			}
			_this.find(".num").animate({"font-size":"30px",top:'15px',left:"-20px"},300).fadeOut().animate({"font-size":"11px",top:0,left:"12px"});
		}
	});
	return false;
  }
});
function addFavorite(sURL, sTitle) {
	try{
		window.external.addFavorite(sURL, sTitle);
	}catch(e){
		try{
			window.sidebar.addPanel(sTitle, sURL, "");
		}catch(e){
			alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
}
function setHome(obj, vrl) {
  try {
    obj.style.behavior = 'url(#default#homepage)';
    obj.setHomePage(vrl);
  } catch(e) {
    if (window.netscape) {
      try {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
      } catch(e) {
        alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
      }
      var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
      prefs.setCharPref('browser.startup.homepage', vrl);
    }
  }
}