var master={api:new ec.api("search"),init:function(pageId,isEn,language,route){L.isEn=isEn;window._design_pageId=pageId;this.isDesign=ke.parm("design")==1;ke.ui.render();L.language=language;L.route=route;master.search.init();master.history.init();if($(".spider-validate").length){$(document).scroll(function(){var top=$(window).scrollTop();$(".spider-validate").toggleClass("spider-validate-fixed",top>10)})}},nav:{cfg:{animate:"none",productClassAlign:"left"},show:function(obj,url){master.nav.clear();var el=$(obj);var layers=el.find(".layers").eq(0);if(url=="$ProductClass"){layers=master.nav.showProductLayer(el)}if(!layers.is(":visible")){master.nav._hide();if(master.nav.cfg.animate=="slideDown")layers.slideDown("fast");else layers.show()}el.addClass("active")},showProductLayer:function(el){var layers=$(".nav-productclass");var left=el.offset().left;var top=el.offset().top+el._height();if(this.cfg.productClassAlign=="center"){left=left-(layers.width()-el.width())/2}layers.css({left:left,top:top});return layers},showLayer:function(obj){while(!$(obj).hasClass("info")&&!$(obj).hasClass("item")){obj=obj.parentElement}master.nav.clear();var el=$(obj);var layers=el.find(".layers").eq(0);el.parent().find(".layers").each(function(i,dom){if(dom!=layers[0]){$(dom).hide();$(dom).parent().find("i").removeClass("ico16-minus")}});if(!layers.is(":visible")){if(master.nav.cfg.animate=="slideDown")layers.slideDown("fast");else layers.show();if(ec.iswap)layers.parent().find("i").eq(0).addClass("ico16-minus")}else if(ec.iswap){layers.slideUp("fast");layers.parent().find("i").eq(0).removeClass("ico16-minus")}},showLang:function(){this.showLayer($(".sitelang"))},_hide:function(){master.nav.clear();$(".navheader .layers").hide();$(".sitelang .layers").hide();$(".nav-productclass").hide();$(".nav-productclass .layers").hide();$(".navheader .item").removeClass("active")},hide:function(){window._navHideEvent=setTimeout("master.nav._hide();",500)},clear:function(){clearTimeout(window._navHideEvent)}},wap:{toggleMenu:function(obj,selector){var menu=$(selector||".navheader");if(!menu.is(":visible")){menu.slideDown("fast");$("#navheader_mask").show();ec.maskScroll(true)}else{menu.slideUp("fast");$("#navheader_mask").hide();ec.maskScroll(false)}$("#sitelang_layers").hide();$(obj).find("i").toggleClass("ico20-cross")},toggleLang:function(){$("#sitelang_layers").slideToggle("fast");if(!ec.wap._initToggleLang){ec.wap._initToggleLang=true;$(window).click(function(e){var x=e.originalEvent.x||e.originalEvent.layerX||0;var y=e.originalEvent.y||e.originalEvent.layerY||0;if(!$(".sitelang")._containsXY(x,y)&&!$("#sitelang_layers")._containsXY(x,y)){$("#sitelang_layers").slideUp("fast")}})}}},search:{input:null,init:function(){this.input=$("#searchWd");this.input.focus(function(){master.history.show()});this.input.blur(function(){master.history.hide()});if(this.input.length>0)this.wd(ke.parm("q"));this.input.bind("keypress",function(event){var theEvent=window.event||e;var code=theEvent.keyCode||theEvent.which||theEvent.charCode;if(code==13){master.search.go()}})},wd:function(wd){if(wd){master.search.input.val(wd.trim())}return master.search.input.val().trim().substr(0,100)},go:function(type){var wd=this.wd();if(wd){master.history.save(wd);var url=L.route+"/product?q="+escape(wd);if(type!=null)url+="&type="+type;ec.redirect(url)}else window.location.reload()},hot:function(wd){this.input.val(wd);this.go()},toggle:function(isShow){$("#search").toggle(isShow)}},history:{items:[],init:function(){try{this.items=JSON.parse(localStorage.getItem("search-history")||"[]")}catch(e){this.items=[]}},show:function(){var layer=$("#search_history");layer.find("iframe").show();layer.show()},hide:function(){setTimeout("$('#search_history').hide();",200)},setHeight:function(h){$("#search_history").height(h||150)},save:function(wd){if(wd){this.items.remove(wd);this.items.splice(0,0,wd);if(this.items.length>6)this.items.splice(6,this.items.length)}localStorage.setItem("search-history",JSON.stringify(this.items))}},cart:{layer:null,show:function(obj){$(".layers").hide();this.clear();if(!this.layer){var cfg={width:378,clickHide:true,modal:false,horizontal:"rr",id:"cart_simple_layer",url:L.route+"/cartSimple"};this.layer=ec.showLayer("",cfg,true);this.layer.$body.append("
")}this.layer.showAt($(obj));this.layer.hover(master.cart.clear,master.cart.hide)},reset:function(){if(this.layer){this.layer.hide();ke.ui.destroy("cart_simple_layer");this.layer=nul}},hide:function(){window._hideCartEvent=setTimeout("window.cart_simple_layer.hide();",400)},setHeight:function(h){if(h<150)h=150;else h+=10;this.layer.find(".loading").hide();this.layer.changeSize(null,h)},clear:function(){clearTimeout(window._hideCartEvent)}},userPanel:{show:function(){clearTimeout(window._hideUserEvent);$(".user .login").show();$(".layer").hide()},hide:function(){window._hideUserEvent=setTimeout("$('.user .login').hide();",400)}},support:{layer:null,show:function(mask){if(mask)ke.mask();this.layer=$("#support_layer");$(".support").animate({right:300},"fast");this.layer.show();this.layer.animate({right:0},"fast")},hide:function(mask){if(mask)ke.unMask();$(".support").animate({right:0},"fast");this.layer.animate({right:-300},"fast")},loadCompete:function(h){this.layer=$("#support_layer");this.layer.find("iframe").height(h)},wapToggle:function(el){$(".support .content").slideToggle(200);$(el).find(".icow6").toggleClass("ico-fourdiamond2")}},openFeedback:function(){ec.openWindow(null,L.route+"/feedback",598,478)},exit:function(){new ec.api("login").put("exit",null,function(){$.removeCookie("token",{path:"/"});window.location.reload()})}};