window.addEvent("domready",function(){$$(".GoodsSearchWrap .buy-select").each(function(a){new QMenu(a,$E(".buy-select-list",a),{lazyload:!0})});var g=new Cookie("S[GFAV]",{duration:365}),h={"star-on":"off","star-off":"on",off:"Del",on:"Add",off_:"erase",on_:"include"},j=function(a,c,b){if("on"==c){a.className="star-on";for(a=a.children[0];3!=a.nodeType;)a=a.firstChild;a.nodeValue="\u5df2\u52a0\u5165\u6536\u85cf"}else{a.className="star-off";for(a=a.children[0];3!=a.nodeType;)a=a.firstChild;a.nodeValue=
"\u6536\u85cf\u6b64\u5546\u54c1"}b&&(g.write($splat((g.read("S[GFAV]")||"").split(","))[h[c+"_"]](b).clean().join(",")),(new Request({method:"post",evalScripts:!0,url:"index.php?member-"+b+"-ajax"+h[c]+"Fav.html"})).send())},k=$splat((g.read("S[GFAV]")||"").split(","));$$("li[star]").each(function(a){var c=a.get("star");k.contains(c)&&j(a,"on");a.addEvent("click",function(b){b.stop();j(a,h[a.className],c)})});var d=$("goods-compare")||(new Element("div")).set("html",["<div class='FormWrap goods-compare' id='goods-compare' style='display:none'>\n<div class='title'><h3>\u5546\u54c1\u5bf9\u6bd4<span class='close-gc' onclick='gcompare.hide()'>[\u5173\u95ed]</span></h3></div>",
"<form action='"+Shop.url.diff+"' method='post' target='_compare_goods'>","<input type='hidden' name='t' value="+$time()+">","<ul class='compare-box'>\n<li class='division clearfix tpl'>\n<div class='span-3'>\n<a href='#' gid='{gid}' title='{gname}'>{gname}</a>\n</div>\n<span class='floatRight lnk' onclick='gcompare.erase(\"{gid}\",this);'>\u5220\u9664</span>\n</li>\n</ul>\n<div class='compare-bar'>\n<input type='button' name='comareing' onclick='gcompare.submit()' class='btn-compare' value='\u5bf9\u6bd4'>\n<input type='button' class='btn-compare' onclick='gcompare.empty()' value='\u6e05\u7a7a'>\n</div>\n</form>\n</div>"].join("\n")).getFirst().inject(document.body),
f=d.getElement(".compare-box"),l=d.getElement(".compare-box .tpl").get("html"),i=function(){"none"!=d.style.display&&d.setStyle("top",window.getScrollTop())};window.addEvents({resize:i,scroll:i});var e=new Cookie("S[GCOMPARE]");gcompare={init:function(){var a=$splat((e.read("S[GCOMPARE]")||"").split("|")).erase("").clean();a.length&&a.each(function(a){this.add(JSON.decode(a),!0)}.bind(this))},hide:function(){d.hide()},show:function(){d.show();i()},add:function(a,c){this.show();if(!c){var b=$splat((e.read("S[GCOMPARE]")||
"").split("|")).erase("").clean();if(b.length&&b.some(function(b){return JSON.decode(b).gtype+"_"!=a.gtype+"_"}))return MessageBox.error("\u53ea\u80fd\u5bf9\u6bd4\u540c\u7c7b\u7684\u5546\u54c1.");if(4<b.length)return MessageBox.error("\u6700\u591a\u53ea\u80fd\u5bf9\u6bd45\u4e2a\u5546\u54c1.");e.write(b.include(JSON.encode(a)).join("|"))}f.getElement('a[gid="'+a.gid+'"]')||(b=(new Element("li",{"class":"division clearfix"})).set("html",l.substitute(a)),b.getElement("a").set("href","?product-"+a.gid+
".html"),f.adopt(b))},erase:function(a,c){var b=$splat((e.read("S[GCOMPARE]")||"").split("|")).erase("").clean(),d;b.each(function(b,c){a==JSON.decode(b).gid&&(d=c)});b.splice(d,1);e.write(b.join("|"));$(c).getParent("li").remove()},empty:function(){e.dispose();f.getElements("li").each(function(a){if(!a.hasClass("tpl"))return a.remove()})},submit:function(){Browser.Engine.webkit&&(f.getParent("form").action=Shop.url.diff);f.getParent("form").submit()}};gcompare.init()});