var validator=new Abstract({validation:{required:["本项必填",function(A){return A!=null&&A!=""}],number:["请录入数值",function(A){return A==null||A==""||!isNaN(A)&&!/^\s+$/.test(A)}],digits:["请录入数字",function(A){return A==null||A==""||!/[^\d]/.test(A)}],alpha:["请录入英文字母",function(A){return A==null||A==""||/^[a-zA-Z]+$/.test(A)}],alphanum:["请录入英文字母、中文及数字",function(A){return A==null||A==""||!/\W/.test(A)||/^[\u4e00-\u9fa5a-zA-Z0-9]+$/.test(A)}],date:["请录入日期格式yyyy-mm-dd",function(A){return A==null||A==""||/^(19|20)[0-9]{2}-([1-9]|0[1-9]|1[012])-([1-9]|0[1-9]|[12][0-9]|3[01])+$/.test(A)}],email:["请录入正确的Email地址",function(A){return A==null||A==""||/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(A)}],text:["",function(A){return true}],select:["",function(A){return true}],radio:["",function(A){return true}],checkbox:["",function(A){return true}],url:["请录入正确的网址",function(A){return A==null||A==""||/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*)(:(\d+))?\/?/i.test(A)}]},test:function(G,H){var J=[];var I=H.getAttribute("required");var D=H.getAttribute("vtype");var C=G.getAttribute("extra");if(I=="true"){J.push("required")}if(D){J.push(D)}for(var F=0;F<J.length;F++){var E=this.validation[J[F]];if(E){var B=E[0];var A=E[1];this.bingValidator(G,H);if(!A(H.value)){msgbox=H.getNext();if(!msgbox||msgbox.getAttribute("name")!="validationMsgBox"){this.msgbox(B).injectAfter(H)}return false}}}if(C&&extra_validator){if(vobj=extra_validator[C]){var E=vobj[D];if(E){var B=E[0];var A=E[1];if(!A(G,H.value)){msgbox=H.getNext();if(!msgbox||msgbox.getAttribute("name")!="validationMsgBox"){this.msgbox(B).injectAfter(H)}return false}}}}return true},msgbox:function(A){var B=new Element("div",{"class":"valierror",name:"validationMsgBox"}).setHTML(A);return B},bingValidator:function(B,A){A.removeEvents("blur");A.addEvent("blur",function(D){D=new Event(D);D=D.target;var C=D.getNext();if(C&&C.getProperty("name")=="validationMsgBox"){C.remove()}validator.test(B,D)})}});$ES("form").each(function(B,A){if($chk(B.action)){B.addEvent("submit",function(F){F=new Event(F);var C=true;var E=[];var D=$ES("._x_ipt",B);D.each(function(H,G){vv=validator.test(B,H);if(!vv){E.push(G)}C&=vv});if(!C){F.preventDefault();D[E[0]].focus();return false}})}});if($("goodsselect")){$("goodsselect").addEvent("click",function(B){B=new Event(B);var C=$ES("INPUT","goodsbody");for(var A=0;A<C.length;A++){C[A].checked=$("goodsselect").checked}})}if($("pkgselect")){$("pkgselect").addEvent("click",function(B){B=new Event(B);var C=$ES("INPUT","pkgbody");for(var A=0;A<C.length;A++){C[A].checked=$("pkgselect").checked}})}if($("giftselect")){$("giftselect").addEvent("click",function(B){B=new Event(B);var C=$ES("INPUT","giftbody");for(var A=0;A<C.length;A++){C[A].checked=$("giftselect").checked}})}var MooCal=new Class({initialize:function(A,C){this.setOptions({base:1,x:0,y:0,calendarClass:"calendar",todayClass:"today",selectedClass:"selected",minYear:1900,maxYear:new Date().getFullYear(),defaultYear:new Date().getFullYear(),defaultMonth:new Date().getMonth(),defaultDay:new Date().getDate(),dayNames:["日","一","二","三","四","五","六","日"],monthNames:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],monthNumber:["01","02","03","04","05","06","07","08","09","10","11","12"]},C);this.calendarID=null;this.visible=false;this.minYear=this.options.minYear;this.maxYear=this.options.maxYear;this.elementID=A;this.yearElement=$(A+"-year");this.monthElement=$(A+"-month");this.dayElement=$(A+"-day");this.chosenDate=new Date();if(this.yearElement){this.year=this.yearElement.getValue();if(this.yearElement.getTag()=="select"){var E=this.yearElement.length-1;if(E>0){var B=this.yearElement.options[0].value;var D=this.yearElement.options[E].value;if(B<D){this.minYear=B;this.maxYear=D}else{this.minYear=D;this.maxYear=B}}}}else{this.year=this.options.defaultYear}this.chosenDate.setYear(this.year);if(this.monthElement){this.month=this.monthElement.getValue()-this.options.base}else{this.month=this.options.defaultMonth}this.chosenDate.setMonth(this.month);if(this.dayElement){this.day=this.dayElement.getValue()}else{this.day=this.options.defaultDay}this.chosenDate.setDate(this.day);this.currentDate=this.chosenDate;this.monthAndYear=null},show:function(A,B){if(!this.visible&&this.calendarID==null){this.calendarID="calendar_"+Date.parse(new Date());this.draw($pick(A,this.options.x),$pick(B,this.options.y));if(window.ie6){this.keepUpInIE($(this.calendarID),1)}}else{this.redraw();$(this.calendarID).setStyles({display:"block",left:$pick(A,this.options.x),top:$pick(B,this.options.y)});if(window.ie6){this.keepUpInIE($(this.calendarID),1)}}this.visible=true},keepUpInIE:function(C,A){var B=($("calKeep_Iframe")||new Element("iframe",{id:"calKeep_Iframe",styles:{border:0,position:"absolute",opacity:0}}).inject(document.body));B.setStyles(C.getCis()).setStyle("zIndex",C.getStyle("zIndex").toInt()-1);A?B.setOpacity(1):B.setOpacity(0)},hide:function(){if(this.visible){$(this.calendarID).setStyle("display","none");this.visible=false}if(window.ie6){this.keepUpInIE($(this.calendarID),0)}},selectDate:function(D,E){new Event(D).stop();if($type(E)!="number"){return }this.currentDate.setDate(E);this.chosenDate=this.currentDate;if(this.yearElement){this.yearElement.setProperty("value",this.currentDate.getFullYear())}if(this.monthElement){this.monthElement.setProperty("value",this.currentDate.getMonth()+this.options.base)}if(this.dayElement){this.dayElement.setProperty("value",this.currentDate.getDate())}if(!this.dayElement&&!this.monthElement&&!this.yearElement&&$(this.elementID).getTag()=="input"){var B=this.currentDate.getFullYear();var C=this.options.monthNumber[this.currentDate.getMonth()];var A=this.currentDate.getDate();if(A<10){A="0"+A}$(this.elementID).setProperty("value",B+"-"+C+"-"+A)}$(this.elementID).fireEvent("change",{type:"change",target:$(this.elementID)});this.hide();if($(this.elementID).onchange){$(this.elementID).onchange()}},setDates:function(){this.lastMonth=new Date(this.currentDate).setMonth(this.currentDate.getMonth()-1);this.nextMonth=new Date(this.currentDate).setMonth(this.currentDate.getMonth()+1);this.lastYear=new Date(this.currentDate).setFullYear(this.currentDate.getFullYear()-1);this.nextYear=new Date(this.currentDate).setFullYear(this.currentDate.getFullYear()+1);this.today=new Date()},repaint:function(B,C){new Event(B).stop();this.rpt=true;var A=new Date(C);if(A.getFullYear()<this.minYear||A.getFullYear()>this.maxYear){return this.rpt=true}this.currentDate=A;this.setDates();this.redraw()},draw:function(F,E){var G,H,C,B,I,A,D;G=new Element("div",{"class":this.options.calendarClass,id:this.calendarID}).setStyles({position:"absolute",zIndex:65535,left:F,top:E});H=new Element("table",{id:this.calendarID+"-table","class":this.calendarID+"-table"});C=new Element("thead").injectInside(H);I=new Element("tr").injectInside(C);new Element("a",{href:"#",events:{click:(function(J){this.repaint(J,this.lastYear)}).bindWithEvent(this)}}).setHTML("&laquo;").injectInside(new Element("th",{"class":this.options.calendarClass+"-yearswitch"}).injectInside(I));new Element("a",{href:"#",events:{click:(function(J){this.repaint(J,this.lastMonth)}).bindWithEvent(this)}}).setHTML("&#139;").injectInside(new Element("th",{"class":this.options.calendarClass+"-monthswitch"}).injectInside(I));this.monthAndYear=new Element("th",{colSpan:3,"class":this.options.calendarClass+"-monthandyear"}).appendText(this.options.monthNames[this.currentDate.getMonth()]+" "+this.currentDate.getFullYear()).injectInside(I);new Element("a",{href:"#",events:{click:(function(J){this.repaint(J,this.nextMonth)}).bindWithEvent(this)}}).setHTML("&#155;").injectInside(new Element("th",{"class":this.options.calendarClass+"-monthswitch"}).injectInside(I));new Element("a",{href:"#",events:{click:(function(J){this.repaint(J,this.nextYear)}).bindWithEvent(this)}}).setHTML("&raquo;").injectInside(new Element("th",{"class":this.options.calendarClass+"-yearswitch"}).injectInside(I));I=new Element("tr").injectInside(C);for(i=0;i<7;i++){new Element("th").appendText(this.options.dayNames[i]).injectInside(I)}B=new Element("tbody").injectInside(H);for(r=0;r<6;r++){I=new Element("tr").injectInside(B);for(c=0;c<7;c++){A=new Element("td").injectInside(I);new Element("a",{href:"#"}).setHTML("&nbsp;").injectInside(A)}}H.injectInside(G);D=new Element("a",{"class":"closeCalBtn",href:"#",events:{click:function(J){new Event(J).stop();this.hide()}.bind(this)}}).setText("关闭").inject(G);G.injectInside(document.body);this.redraw()},redraw:function(){this.setDates();this.monthAndYear.setText(this.options.monthNames[this.currentDate.getMonth()]+" "+this.currentDate.getFullYear());var E=$ES("tbody a",$(this.calendarID));var C=new Date(this.currentDate);C.setDate(1);if(C.getDay()>0){C.setDate(-C.getDay()+1)}var D=new Date(C);var B=new Date();for(i=0;i<E.length;i++){var A="&nbsp;";if(D.getMonth()==this.currentDate.getMonth()){A=D.getDate()}$(E[i]).removeClass(this.options.todayClass);$(E[i]).removeClass(this.options.selectedClass);$(E[i]).removeEvents();$(E[i]).addEvent("click",(function(G,F){this.selectDate(G,F)}).bindWithEvent(this,A));$(E[i]).setHTML(A);if(D.getDate()==B.getDate()&&D.getMonth()==B.getMonth()&&D.getFullYear()==B.getFullYear()){$(E[i]).addClass(this.options.todayClass)}if(this.currentDate.getMonth()==this.chosenDate.getMonth()&&D.getDate()==this.chosenDate.getDate()&&D.getMonth()==this.chosenDate.getMonth()&&D.getFullYear()==this.chosenDate.getFullYear()){$(E[i]).addClass(this.options.selectedClass)}D.setDate(D.getDate()+1)}}});MooCal.implement(new Options);Element.extend({makeCalable:function(A){if(!$chk(this.getProperty("id"))){this.setProperty("id","cal"+$time())}if(!this.mc){this.mc=new MooCal(this,$merge({maxYear:"2050"},A))}else{this.mc.setOptions(A)}this.addEvents({click:function(H){var B=new Event(H).stop();var J=this.getPosition().x;var I=this.getPosition().y+this.getSize().size.y;if(this.mc&&this.mc.visible){return this.mc.show(J,I)}this.mc.elementID=this;var E=new Date();try{var K=this.value.split("-");var G=(K[0])?K[0]:new Date().getFullYear();var F=(K[1])?K[1]-1:new Date().getFullMonth();var C=(K[2])?K[2]:new Date().getDate();E=new Date(G,F,C)}catch(D){}this.mc.currentDate=E;this.mc.chosenDate=E;this.mc.show(J,I);this.mc.redraw();document.body.addListener("click",function(L){L=new Event(L);if(L.target!=this){this.mc.hide.call(this.mc)}document.body.removeListener("click",arguments.callee)}.bind(this))}});return this}});var mc=null;Asset.extend({javascript:function(C,B){B=$merge({onload:Class.empty},B);if(!window.ie){return new Element("script",{id:B.id,src:C}).addEvents({load:B.onload,readystatechange:function(){if(this.readyState=="complete"){this.fireEvent("load")}}}).inject(document.head)}var A=new Element("script",{id:B.id,src:C}).addEvents({load:B.onload}).inject(document.head);A.onreadystatechange=function(){if(A.readyState=="complete"||A.readyState=="loaded"){this.fireEvent("load");A.onreadystatechange=null}}}});Element.extend({amongTo:function(F,E){var C=this;var A=C.getSize(),D=F.getSize();var B={width:2,height:2};if(E){B=$merge(B,E)}C.setStyles({position:"absolute",top:((D.size.y/B.height).toInt())-((A.size.y/B.height).toInt())+F.getPosition().y+D.scroll.y,left:((D.size.x/B.width).toInt())-((A.size.x/B.width).toInt())+F.getPosition().x+D.scroll.x});return this},getValues:function(){var A={};this.getFormElements().each(function(C){var B=C.name;var D=C.getValue();if(D===false||!B||C.disabled){return }A[C.name]=D});return A},getAttrs:function(){var B=this.attributes;var A={};for(var C=B.length-1;C>-1;C--){A[B[C].nodeName]=B[C].nodeValue}return A},getPositionAs:function(B){var A=this,D=0,C=0;do{D+=A.offsetLeft||0;C+=A.offsetTop||0;A=A.offsetParent}while(A==B);return{x:D,y:C}},getFillBy:function(F){var C=this;var B=(C.getStyle("margin-left").toInt()+C.getStyle("margin-right").toInt());var G=(C.getStyle("padding-left").toInt()+C.getStyle("padding-right").toInt());var A=(C.getStyle("margin-top").toInt()+C.getStyle("margin-bottom").toInt());var E=(C.getStyle("padding-top").toInt()+C.getStyle("padding-bottom").toInt());if(!F){F=$(this.getParent())}var D=F.getSize().size;return{width:F.clientWidth-(B+G),height:F.clientHeight-(A+E)-C.getPositionAs(F).y,x:F.clientWidth,y:F.clientHeight}},getPadding:function(){return{x:this.getStyle("padding-left").toInt()+this.getStyle("padding-right").toInt(),y:this.getStyle("padding-top").toInt()+this.getStyle("padding-bottom").toInt()}},getMargin:function(){return{x:this.getStyle("margin-left").toInt()+this.getStyle("margin-right").toInt(),y:this.getStyle("margin-top").toInt()+this.getStyle("margin-bottom").toInt()}},getBorderWidth:function(){return{left:this.getStyle("border-left-width").toInt(),right:this.getStyle("border-right-width").toInt(),top:this.getStyle("border-top-width").toInt(),bottom:this.getStyle("border-bottom-width").toInt(),x:this.getStyle("border-left-width").toInt()+this.getStyle("border-right-width").toInt(),y:this.getStyle("border-top-width").toInt()+this.getStyle("border-bottom-width").toInt()}},copyWidth:function(A){try{this.setStyle("width",A.getSize().size.x-(A.getPadding().x+A.getMargin().x)-(A.getBorderWidth().left+A.getBorderWidth().right))}catch(B){this.setStyle("width",200)}},copyHeight:function(A){try{this.setStyle("height",A.getSize().size.y-(A.getPadding().y+A.getMargin().y)-(A.getBorderWidth().left+A.getBorderWidth().right))}catch(B){this.setStyle("height",200)}},getTrueWidth:function(){return this.getSize().size.x-(this.getMargin().x+this.getPadding().x+this.getBorderWidth().left+this.getBorderWidth().right)},getTrueHeight:function(){return this.getSize().size.y-(this.getMargin().y+this.getPadding().y+this.getBorderWidth().top+this.getBorderWidth().bottom)},getCis:function(){return this.getCoordinates()},remove:function(){if(this.getParent()){return this.getParent().removeChild(this)}},getContainer:function(){try{var A=$(this);do{A=A.getParent()}while(!A.getProperty("container")&&A);return A}catch(B){return false}},load:function(B,A){return new Ajax(B,$merge(A,{update:this})).request()},makeHtmlEditor:function(D,A){var C=this;var B=new FCKeditor(A.name,A.width,A.height,A.toolBar,D).Create();C.setHTML(B).show();return this},bindSelect:function(A,C,E){var D=new Select(A,$merge(C,{onHide:function(G,F){this.setProperty("value",G.text)}.bind(this),onShow:function(F){F.setStyles({left:this.getCis().left,top:this.getCis().bottom,width:(this.getCis().width+D.selectBtn.getCis().width)-(this.getPadding().x+this.getMargin().x)})}.bind(this)}));this.setProperty("value",D.curSelect.text);this.addClass("").addEvent("click",function(){E(D.curSelect.value,D.curSelect.text,D.curSelect.index+1)});var B=new Element("span",{"class":"SelectActionArea"}).injectBefore(this);this.inject(B);D.selectBtn.inject(B)},bindValidator:function(A,B){return $ES("."+B,this).every(function(C){return new validator().test(A,C)})},show:function(){return $chk(this)?this.setStyle("display",""):this},hide:function(){return $chk(this)?this.setStyle("display","none"):this},toggleDisplay:function(){return $chk(this)&&this.getStyle("display")=="none"?this.setStyle("display",""):this.setStyle("display","none")},getFormElementsPlus:function(){var B=[];var A=$$(this.getElementsByTagName("input"),this.getElementsByTagName("select"),this.getElementsByTagName("textarea"));A.each(function(E){var C=E.name;var G=E.getValue();var D=E.getProperty("disabled");var F=E.getProperty("checked");if(!C||G===false||D||!!!F){return }if(window.ie){if(E.getProperty("type")=="checkbox"||E.getProperty("type")=="radio"){return B.include($(E).toHiddenInput())}}B.include(E)});return $$(B)},toHiddenInput:function(){return new Element("input",{type:"hidden",name:this.name,value:this.value})},getParentWithScroll:function(){var A=this;do{A=A.getParent()}while((A.getSize().size.y>=A.getSize().scrollSize.y)&&A.id!="main");return A},getParentMatch:function(A){if(!A){return this.getParent()}var B=this;do{B=B.getParent()}while(B.getTag()!="body"&&!!A(B));return B}});String.extend({format:function(){if(arguments.length==0){return this}var D=/{(\d+)?}/g;var C=arguments;var B=this;var A=this.replace(D,function(F,E){return C[E.toInt()]});return A}});var SortablesWithScroll=Sortables.extend({start:function(C,B){this.active=B;this.coordinates=this.list.getCoordinates();this.listScroll_Y=this.list.getSize().scroll.y;if(this.options.ghost){var A=B.getPosition();this.offset=(C.page.y+this.listScroll_Y)-A.y;this.trash=new Element("div").inject(document.body);this.ghost=B.clone().inject(this.trash).setStyles({position:"absolute",left:A.x,top:C.page.y-this.offset});document.addListener("mousemove",this.bound.moveGhost);this.fireEvent("onDragStart",[B,this.ghost])}document.addListener("mousemove",this.bound.move);document.addListener("mouseup",this.bound.end);this.fireEvent("onStart",B);C.stop()},move:function(E){var B=E.page.y+this.listScroll_Y;this.previous=this.previous||B;var A=((this.previous-B)>0);var D=this.active.getPrevious();var C=this.active.getNext();if(D&&A&&B<D.getCoordinates().bottom){this.active.injectBefore(D)}if(C&&!A&&B>C.getCoordinates().top){this.active.injectAfter(C)}this.previous=B}});var ItemAgg=new Class({options:{onActive:Class.empty,onBackground:Class.empty,show:0,eventName:"click"},initialize:function(C,A,B){this.setOptions(B);this.tabs=$$(C);this.items=$$(A);this.items.setStyle("display","none");this.tempCurIndex=this.options.show||0;this.tabs[this.tempCurIndex].addClass("cur");this.items[this.tempCurIndex].show();this.tabs.each(function(E,D){E.addEvent(this.options.eventName,function(F){F=new Event(F).stop();this.tabs[D].blur();if(this.tempCurIndex!=D){this.show(D);this.hide(this.tempCurIndex);this.tempCurIndex=D}}.bind(this))},this)},show:function(A){this.items[A].show();this.tabs[A].addClass("cur");this.fireEvent("onActive",[this.tabs[A],this.items[A]])},hide:function(A){this.items[A].hide();this.tabs[A].removeClass("cur");this.fireEvent("onBackground",[this.tabs[A],this.items[A]])}});ItemAgg.implement(new Events,new Options);function $cleanNull(){var A=arguments[0];for(p in A){if(!A[p]){delete (A[p])}}return A}var dialogTemplate=function(){return new Element("div",{id:"dialog","class":"dialog"}).setHTML("<div class='head'>","<div class='title'>正在加载...</div>","<div class='close-btn'>X</div>","<div class='headContent'></div>","</div>","<div class='body' id='dialogContent' container='true'>","正在加载... ","</div>","<div class='foot'>","&nbsp;","<div class='resize-btn'>&nbsp;</div>","<div class='footContent'>&nbsp;</div>","</div>").inject(document.body)};var Dialog=new Class({options:{onShow:Class.empty,onHide:Class.empty,onClose:Class.empty,width:500,height:400,title:" ",dragable:true,resizeable:true,ajaksable:false,singlon:true,modal:true,ajaxoptions:{update:false,evalScripts:true,method:"get",autoCancel:true}},initialize:function(B,A){if(B.tagName){this.el=B}else{this.url=B}this.dialog=($("dialog")||dialogTemplate()).setStyle("zIndex",65535);if(this.dialog.hasClass("singlon")){return }this.setOptions(A);if(this.options.singlon){this.dialog.addClass("singlon")}else{this.dialog=this.dialog.clone().setProperty("id","dialog"+$time()).inject(document.body)}this.dialog_head=$E(".head",this.dialog);this.dialog_body=$E(".body",this.dialog);this.dialog_foot=$E(".foot",this.dialog);if($E(".headContent",this.dialog_head)){$E(".headContent",this.dialog_head).empty()}$E(".title",this.dialog_head).setText(this.options.title);$E(".close-btn",this.dialog_head).addEvent("click",function(C){C=new Event(C).stop();this.close()}.bind(this));if(this.options.dragable){this.dragDialog()}if(this.options.resizeable){this.dialog_body.makeResizable({handle:$E(".resize-btn",this.dialog_foot),limit:{x:[this.options.width,800],y:[100,800]},onDrag:function(){this.setDialogWidth();if(window.ie6){this.keepOut()}}.bind(this),onComplete:function(){if(this.dialog.getPosition().y<0){this.dialog.setStyle("top",0)}}.bind(this)})}else{$E(".resize-btn",this.dialog_foot).setStyle("display","none")}this.setDialog_bodySize();$extend(this.options.ajaxoptions,{update:this.dialog_body,elMap:{".mainHead":$E(".headContent",this.dialog_head),".mainFoot":$E(".footContent",this.dialog_foot)},onComplete:function(C){this.setDialog_bodySize();if("keepOut" in this){this.keepOut()}if("onComplete" in this.options){this.options.onComplete(C)}}.bind(this)});this.show()},show:function(){if(this.options.modal){this.modal=new Element("div",{styles:document.body.getCis(),id:"dialog_showModal"}).setStyles({zIndex:65532,background:"#f1f1f1",position:"absolute"}).inject(document.body);this.modal.setOpacity(0.3);(function(){this.dialog.amongTo(window,!this.options.height?{height:3}:{}).setOpacity(1)}).delay(150,this)}else{this.dialog.amongTo(window,!this.options.height?{height:3}:{}).setOpacity(1)}if(window.ie6){this.koframe=$("dialogKeepoutIframe")||new Element("iframe",{id:"dialogKeepoutIframe",styles:{position:"absolute"}}).inject(document.body);this.keepOut=function(){return this.koframe.setStyles($merge(this.dialog.getCis(),{zIndex:this.dialog.getStyle("zIndex").toInt()-1}))};this.keepOut();$("dialogKeepoutIframe").amongTo(window).setOpacity(1)}this.initContent();this.fireEvent("onShow",{type:"onShow",target:this});this.dialog_body.setOpacity(1)},close:function(){this.fireEvent("onClose");this.dialog_body.empty().setOpacity(0);if(this.options.ajaxoptions.elMap){$each(this.options.ajaxoptions.elMap,function(B,A){$(B).empty()})}if(this.options.singlon){this.dialog.setOpacity(0).setStyle("top",-2000);this.modal?this.modal.remove():"";this.dialog.removeClass("singlon")}else{this.dialog.remove();this.modal?this.modal.remove():""}if(window.ie6){if(this.koframe){this.koframe.setOpacity(0).setStyle("top",-2000)}}},hide:function(){this.fireEvent("onHide");this.close.call(this)},setDialog_bodySize:function(){this.dialog_body.setStyles({height:this.options.height-(this.dialog_head.getSize().size.y+this.dialog_foot.getSize().size.y),width:this.options.width});this.setDialogWidth()},setDialogWidth:function(){this.dialog.setStyle("width",this.dialog_body.getSize().size.x)},dragDialog:function(){var A=this.dialog;if(this.options.dragable){$E(".title",this.dialog_head).addEvent("mousedown",function(B){B=new Event(B);var C=$("dialogdragghost")||new Element("div",{id:"dialogdragghost",styles:A.getCis()}).setStyles({position:"absolute",border:"2px #333 dashed",cursor:"move",background:"#66CCFF",zIndex:65535}).inject(document.body);C.setStyles(A.getCis()).setOpacity(0.3);C.makeDraggable({container:document.body,onComplete:function(){A.setStyles({top:C.getPosition().y,left:C.getPosition().x});if(window.ie6){this.keepOut()}C.setOpacity(0)}.bind(this)}).start(B)}.bind(this))}},initContent:function(){try{if(this.el){this.el.inject(this.dialog_body.empty())}else{if(this.options.ajaksable){W.page(this.url,this.options.ajaxoptions)}else{new Ajax(this.url,this.options.ajaxoptions).request()}}}catch(A){this.dialog_body.setHTML('<h3>加载内容失败</h3><hr/>目标地址:<a href="'+this.url+'">'+this.url+"</a>")}}});Dialog.implement(new Options,new Events);var ad={createArea:function(A){area=Builder.node("div");document.body.appendChild(area);area.style.width=A.width+"px";area.style.height=A.height+"px";area.style.position=A.position;area.style.zIndex=99;frame='			<table width="'+A.width+'" height="'+A.height+'" cellspacing="0" cellpadding="0" border="0" style="border: 1px solid #000;background-color:#fff">			<tbody>			<tr height="1" bgcolor="#d6e3eb"><td><td/></tr>			<tr height="25" bgcolor="#6795b4">			<td>			<table width="100%" cellspacing="0" cellpadding="0" border="0" >			<tbody>			<tr>			<td width="6"/>			<td style="font-size: 12px; font-weight: bold;" onmousedown="ad.move(event, this);">广告</td>			<td width="1" valign="middle" align="right" onclick="ad.close(this);" style="cursor:pointer">X</td>			<td width="6"/>			</tr>			</tbody>			</table>			</td>			</tr>			<tr>			<td>			<table cellspacing="0" cellpadding="0" border="0">			<tbody>			<tr ><td colspan="2"/></tr>			<tr><td/>{%%%}<td/></tr>			</tbody>			</table>			</td>			</tr>			</tbody>			</table>';area.innerHTML=frame.replace("{%%%}",A.html);return area},move:function(B,C){for(C=C.parentNode;C.tagName!="DIV";C=C.parentNode){}C.style.cursor="move";C.style.zIndex=100;C.onmousemove=A;document.documentElement.onmouseup=D;oEvent=window.event?window.event:B;drag={x:oEvent.clientX,y:oEvent.clientY};back={x:parseInt(C.style.top),y:parseInt(C.style.left)};function A(F){var E=window.event?window.event:F;if(C.offsetLeft<=0||C.offsetTop<=document.documentElement.scrollTop||C.offsetLeft+C.clientWidth>=document.documentElement.clientWidth||C.offsetTop+C.clientHeight>=document.documentElement.clientHeight+document.documentElement.scrollTop){pad=7;if(C.offsetLeft<=0){C.style.left=parseInt(C.style.left)+pad+"px"}if(C.offsetTop<=document.documentElement.scrollTop){C.style.top=parseInt(C.style.top)+pad+"px"}if(C.offsetLeft+C.clientWidth>=document.documentElement.clientWidth){C.style.left=parseInt(C.style.left)-pad+"px"}if(C.offsetTop+C.clientHeight>=document.documentElement.clientHeight+document.documentElement.scrollTop){C.style.top=parseInt(C.style.top)-pad+"px"}}else{C.style.left=E.clientX-drag.x+parseInt(C.style.left)+"px";C.style.top=E.clientY-drag.y+parseInt(C.style.top)+"px";drag={x:E.clientX,y:E.clientY}}}function D(E){C.style.cursor="";C.style.zIndex=99;oEvent=window.event?window.event:E;C.onmousemove=null;C.onmouseup=null}},close:function(A){for(A=A.parentNode;A.tagName!="DIV";A=A.parentNode){}A.style.display="none"},showFloat:function(C){fDiv=ad.createArea({width:C.width,height:C.height,html:C.html,position:"absolute"});fDiv.onmouseover=A;fDiv.onmouseout=D;step=1;goX=goY=true;x=y=0;t=setInterval(B,13);function A(){clearInterval(t)}function D(){t=setInterval(B,19)}function B(){divOffsetWidth=fDiv.offsetWidth;divOffsetHeight=fDiv.offsetHeight;clientWidth=document.documentElement.clientWidth;clientHeight=document.documentElement.clientHeight;fDiv.style.left=document.documentElement.scrollLeft+x+"px";fDiv.style.top=document.documentElement.scrollTop+y+"px";if(goX){x+=step}else{x-=step}if(x<0){goX=true;x=0}else{if(x>(clientWidth-divOffsetWidth)){goX=false;x=clientWidth-divOffsetWidth}}if(goY){y+=step}else{y-=step}if(y<0){goY=true;y=0}else{if(y>(clientHeight-divOffsetHeight)){goY=false;y=clientHeight-divOffsetHeight}}}},showPop:function(A){sDiv=ad.createArea({width:A.width,height:A.height,html:A.html,position:"absolute"});sDiv.style.left=(document.documentElement.clientWidth/2)-(sDiv.offsetWidth/2)+"px";sDiv.style.top=(document.documentElement.clientHeight/2+document.documentElement.scrollTop)-(sDiv.offsetHeight/2)+"px"},showCouplet:function(B){divLeft=ad.createArea({width:B.width,height:B.height,html:'<img src="'+B.left+'" width='+B.width+" height="+B.height+">",position:"absolute"});divRight=ad.createArea({width:B.width,height:B.height,html:'<img src="'+B.right+'" width='+B.width+" height="+B.height+">",position:"absolute"});setTop=150;divLeft.style.position=divRight.style.position="absolute";divLeft.style.top=divRight.style.top=setTop+"px";divLeft.style.left="1px";divRight.style.left=document.documentElement.clientWidth-B.width-1+"px";window.onscroll=A;function A(){divLeft.style.top=divRight.style.top=document.documentElement.scrollTop+setTop+"px"}}};var Cart={bindView:function(A){var B=A.getParent().getParent();new QMenu(A,new Element("div",{"class":"fmenu",style:"text-align:left;top:20;right:0;width:100px;display:none;height:100px;"}).inject(B)).addEvent("firstshow",function(C){new Ajax(Shop.url.viewcart,{update:C.target,onSuccess:function(){this.setStyles({width:null,height:null})}.bind(C.target)}).request()}.bind(this))},_update:function(F,E){try{var B=Cookie.get("S[CART]");if(B){var H=B.split("-");var D=false;for(var C=0;C<H.length;C++){var A=H[C].split("_");if(A[0]==F){if(!A[1]){A[1]=1}H[C]=F+"_"+(Number(A[1])+1);D=true;break}}if(!D){H.push(F)}}else{var H=[F]}Cookie.set("S[CART]",H.join("-"));shopEffect.updateCart(F,E)}catch(G){throw G}},update:function(B){var A=B.getAttribute("href");$("form-cart").action=A;$("form-cart").submit()},load:function(){Cart.els=$E(".CartInfoWrap");if(Cart.els.length>0){if(Cookie.get("S[CART]")&&Cookie.get("S[CART]").length>0){var A=new Ajax(Shop.url.viewcart,{method:"get"});A.addEvent("onComplete",Cart.updateView);A.request()}else{for(var B=0;B<Cart.els.length;B++){Cart.els[B].style.visibility=""}}}},add:function(C){new Event(C).stop().target;var B=this.getAttribute("buy");if(B){var D=Cart.els.length>0?Cart.els[0]:$E(".s-menu-cart");if(D){new Event(C).stop();var A=new Ajax(Shop.url.addcart,{method:"post",data:"gid="+B});if(Cart.els){A.addEvent("onComplete",Cart.updateView)}A.request();for(var E=this.parentNode;!E.getAttribute("product");E=E.parentNode){if(!E.parentNode.getAttribute){E=false;break}}if(E){shopEffect.addCart(E,D,E.tagName=="TR")}}}},updateView:function(B){for(var A=0;A<Cart.els.length;A++){Cart.els[A].innerHTML=B;Cart.els[A].style.visibility=""}},selectbuy:function(A){new Ajax(A,{method:"post"}).request();alert("加入购物车成功！")},shipping_id:0,d_pay:0,is_protect:"false",payment:0,checkout:{shipping:function(A){if(A&&A.value){new Ajax(Shop.url.shipping,{method:"post",update:"shipping",data:"area="+A.value}).request()}},setShipping:function(F,C){if(F.id){var D=F.id,B;B=D.split("_");var E=$("shipping").getElementsByTagName("INPUT");for(var A=0;A<E.length;A++){if(B[0]=="shipping"){if(E[A].id!="protect_"+B[1]&&E[A].id!=D){E[A].checked=false}}else{if(F.checked){if(E[A].id!="protect_"+B[1]){E[A].checked=false}if(E[A].id=="shipping_"+B[1]){E[A].checked=true;Cart.shipping_id=E[A].value}}}}}if(C==1){if(F.checked==true){Cart.is_protect="true"}else{Cart.is_protect="false"}}else{Cart.shipping_id=F.value}if($("shipping_"+Cart.shipping_id).getAttribute("has_cod")==1){$("_pay_cod").style.display="";Cart.d_pay=1}else{$("_pay_cod").style.display="none";Cart.d_pay=0}Cart.checkout.total();return },setCurrency:function(A){if(A.value){new Ajax(Shop.url.payment,{method:"post",onComplete:function(){if($("shipping_"+Cart.shipping_id).getAttribute("has_cod")==1){$("_pay_cod").style.display=""}},update:"payment",data:"cur="+A.options[A.selectedIndex].value+"&d_pay="+Cart.d_pay+"&payment="+Cart.payment,onComplete:function(C,B,D){$ES("input.x-payMethod","payment").addEvent("click",Cart.checkout.setPayment)}.bind(this)}).request()}Cart.payment=0;return },setPayment:function(B,A){Cart.payment=new Event(B).target.value;Cart.checkout.total()},total:function(){if($("is_tax")&&$("is_tax").checked==true){var B="true"}else{var B="false"}var A="shipping_id="+Cart.shipping_id+"&is_protect="+Cart.is_protect+"&payment="+Cart.payment+"&cur="+$("payment-cur").getValue()+"&is_tax="+B;if($("shipping-area")){A+="&area="+$("shipping-area").getValue()}new Ajax(Shop.url.total,{method:"post",update:"amountInfo",data:A}).request()}},dlgHandler:{},getReceiverList:function(A){A=new Event(A).stop();Cart.dlgHandler=new Dialog(A.target.href,{title:"选取收获地址"})},checkAddr:function(D){D=new Event(D).stop();var E=$("addrList").getElementsByTagName("INPUT");for(var B=0;B<E.length;B++){if(E[B].checked){break}}if(!!!E[B]){return alert("请选择收获地址!")}var A=E[B].parentNode.parentNode;var C=A.getElementsByTagName("TD");for(var B=0;B<C.length;B++){if(C[B].className){if($(C[B].className)){$(C[B].className).value=C[B].innerHTML}}}Cart.dlgHandler.close()}};Order={url:{},updateTotal:function(){new Ajax(Shop.url.ordertotal,{method:"post",update:"order-total",data:$("order-create")}).request()},applyCoupon:function(A){shopEffect.loadMask($("order-main"));A=A?"coupon="+A:"";new Ajax(Shop.url.applycoupon,{method:"post",update:"order-main",data:A}).request()}};if($("anonymityBuy")){$("anonymityBuy").addEvent("click",function(A){Cookie.set("S[ST_ShopEx-Anonymity-Buy]","true")})}$$(".cal").makeCalable();var compare_goods=new Class({showad:true,Toppx:0,PageWidth:window.getWidth()-130,MinScreenW:window.screen.height,initialize:function(){var A='<div class="title"><a class="close" onClick="show_compare.hidead();return false;" href="#">关闭</a><h3>商品对比</h3></div>';var E="";var B=this.vreturn(Cookie.get("S[c_product]"));var D=this.vreturn(Cookie.get("S[c_name]"));var F=this.vreturn(Cookie.get("S[c_pic]"));var C=this.vreturn(Cookie.get("S[c_id]"));for(i=0;i<B.length;i++){E+="<div class='item' id='goods_"+C[i]+"'><a href='#' onClick='show_compare.del_compare("+C[i]+");return false;' class='remove'>删除[x]</a><h6 title='"+D[i]+"'><a href='?product-"+C[i]+".html'>"+D[i]+"</a></h6></div>"}document.write('<div id="goods_compare" style="position: absolute;top:-1000px;display:none"><form id="-form-diff" action="'+Shop.url.product_diff+'" method="post" target="_compare_goods">'+A+'<div id="compare_goods">'+E+'</div><div class="cmpbar"><input type="submit" name="comareing" class="btn_compare" value="对比"><input type="button" name="clearn_compare" class="btn_compare" onClick="show_compare.clean_compare()" value="清空"></div></form></div>');window.addEvents({scroll:this.scall.bind(this),resize:this.scall.bind(this),load:this.scall.bind(this)})},vreturn:function(A){if(A){return A.split(",")}else{return A}},scall:function(){this.PageWidth=window.getWidth()-130;if(this.showad==false){return }document.getElementById("goods_compare").style.top=document.documentElement.scrollTop+this.Toppx+"px";document.getElementById("goods_compare").style.left=this.PageWidth+"px"},hidead:function(){document.getElementById("goods_compare").style.display="none"},del_compare:function(A){document.getElementById("goods_compare").style.display="";var C=Cookie.get("S[c_product]");var B=C.split(",");var E="";if(B.length==1){Cookie.remove("S[c_product]");Cookie.remove("S[c_type]");Cookie.remove("S[c_name]");Cookie.remove("S[c_pic]");Cookie.remove("S[c_id]");$("compare_goods").innerHTML=""}else{for(var D=0;D<B.length;D++){if(B[D]!=A){E+=B[D]+","}}E=E.substr(0,E.length-1);Cookie.set("S[c_product]",E);$("goods_"+A).parentNode.removeChild($("goods_"+A))}},clean_compare:function(){Cookie.remove("S[c_product]");Cookie.remove("S[c_type]");Cookie.remove("S[c_name]");Cookie.remove("S[c_pic]");Cookie.remove("S[c_id]");$("compare_goods").innerHTML=""},add_comare_goods:function(B,F,A,G){document.getElementById("goods_compare").style.display="";var D=Cookie.get("S[c_product]");var H=Cookie.get("S[c_type]");var C=Cookie.get("S[c_name]");var J=Cookie.get("S[c_pic]");var K=Cookie.get("S[c_id]");if(H){if(H!=G){alert("只能对比同一类型的产品");return }}else{H=G;Cookie.set("S[c_type]",H)}if(D){var I=D.split(",");for(var E=0;E<I.length;E++){if(I[E]==B){return }}C=C+","+A;D=D+","+B;J=J+","+F;K=K+","+B}else{D=B;C=A;J=F;K=B}Cookie.set("S[c_product]",D);Cookie.set("S[c_name]",C);Cookie.set("S[c_pic]",J);Cookie.set("S[c_id]",K);$("compare_goods").innerHTML+="<div class='item' id='goods_"+B+"'><a href='#' onClick='show_compare.del_compare("+B+");return false;' class='remove'>删除[x]</a><h6 title='"+A+"'><a href='?product-"+B+".html'>"+A+"</a></h6></div>"}});var show_compare=new compare_goods;var foobar=function(){this.el=$("foobar_"+this.id);var A=Cookie.get("S[UNAME]");if(A){$("uname_"+this.id).setText("，"+A)}if(Cookie.get("S[MEMBER]")){$("loginBar_"+this.id).setStyle("display","none");$("memberBar_"+this.id).setStyle("display","")}this.curEl=$("Cur_sel_"+this.id);if(this.curEl){this.curList=new Element("div",{"class":"fmenu"}).setStyle("display","none").inject(this.el);new QMenu(this.curEl,this.curList).addEvent("show",function(){this.curList.setStyles({display:"",left:this.curEl.offsetLeft,top:20})}.bind(this));var D=Cookie.get("S[CUR]");for(var B=0;B<this.cur.length;B++){if(D==this.cur[B].cur_code){$E("strong",this.curEl).setText(this.cur[B].cur_sign+" "+this.cur[B].cur_name)}new Element("div",{"class":"item",style:"text-align:left"}).setText(this.cur[B].cur_sign+" "+this.cur[B].cur_name).inject(this.curList).addEvent("click",function(E){Cookie.set("S[CUR]",this.cur_code);window.location.reload()}.bind(this.cur[B]))}}this.cartEl=$("Cart_"+this.id);if(this.cartEl){Cart.bindView(this.cartEl)}if(this.stick){var C=this.el.getPosition().y+10;window.addEvent("scroll",function(){if(window.getScrollTop()>C){if(!this.inFloat){var F=this.getPosition();this.setStyles({left:F.x,top:F.y,"z-index":65500});this.inFloat=true;if(window.ie){this.setStyle("position","absolute")}else{this.setStyle("position","fixed")}if(!this.mask){var E=this.getSize();this.mask=new Element("span",{style:"height:20px"}).inject(this.getParent())}else{this.mask.setStyle("display","")}}if(window.ie6){this.setStyle("top",window.getScrollTop())}}else{if(this.inFloat){this.inFloat=false;this.setStyles({position:"relative",left:null,top:null,"z-index":null});if(this.mask){this.mask.setStyle("display","none")}if(window.ie6){}}}}.bind(this.el))}};var AdjunctRecord=new Class({initialize:function(B,A){this.el=$(A);this.infoSection=$E("span",this.el.getParent().getPrevious());this.adjName=this.infoSection.getProperty("adj");this.rows=[];this.ready=false;this.inited=false;this.setOptions({key:A.getProperty("adjkey"),name:A.getProperty("adjname"),min:parseInt(A.getProperty("min_num")),max:parseInt(A.getProperty("max_num"))});this.addEvent("error",function(){if(this.inited){this.infoSection.addClass("error");this.infoSection.setHTML("请按正确数量选择"+this.adjName)}});this.addEvent("ready",function(C){this.infoSection.removeClass("error").empty()});$ES("tr",A).each(function(D){var E=$E('input[type="checkbox"]',D).addEvent("click",this.recheck.bind(this));var F=$E('input[name="buynum"]',D);var C=parseFloat(D.getProperty("price"));F.addEvent("mousewheel",function(H){var G=parseFloat(this.el.value)+new Event(H).stop().wheel;G=(G<0)?0:G;this.el.value=G;(function(I){if(this.value==parseFloat(this.el.value)){this.el.fireEvent("change")}}).delay(300,{el:this.el,value:G})}.bind({base:this,el:F}));F.addEvent("change",function(){var G=parseFloat(this.ipt.value);if(isNaN(G)){G=0}this.ipt.value=G;this.totalPrice.setText(B.moneyFormat.bind(B)(G*this.price));if(this.sel.checked){this.base.recheck.bind(this.base)()}}.bind({price:C,ipt:F,sel:E,base:this,totalPrice:$E(".adj-total-price",D)}));this.rows.push({sel:E,num:F,id:E.value,name:$E("label",D).getText(),price:C})}.bind(this));this.check()},recheck:function(){this.statCache=false;this.check();this.fireEvent("change",{target:this})},check:function(){if(!this.statCache){var D=0;var C=0;var A=[];this.rows.each(function(F){if(F.sel.checked){var E=parseInt(F.num.value);if(E>0){D+=E;C+=F.price.toFloat()*E.toFloat();A.push({id:F.id,num:E,name:F.name})}}});if(D<this.options.min){this.fireEvent("error",{target:this});var B=false}else{if(this.options.max>0&&this.options.max<D){this.fireEvent("error",{target:this});var B=false}else{this.price=C;this.items=A;var B=true;this.fireEvent("ready",{target:this})}}this.statCache=true;this.ready=B;this.inited=true}else{return this.ready}}});AdjunctRecord.implement(new Events,new Options);var ProductViewer=new Class({products:{},adjuncts:[],initialize:function(B,A){this.setOptions(A);if(A.product){this.productStatus=1}this.el=$(B);this.form=$E("form.goods-action",B).addEvent("submit",this.onSubmit.bind(this));this.viewPort={};this.inited=false;this.form.productText=$E(".g-product",this.form);this.form.adjunctText=$E(".g-adjunct",this.form);this.form.price=$E(".g-total-price",this.form);this.goodsinteract=$("goods-interact");this.dynamic=$("goodsdynamic");this.viewPort.msg=$E(".g-msg",this.dynamic);this.viewPort.price=$E(".g-total-price",this.dynamic);this.addEvent("error",function(C){this.viewPort.msg.innerHTML=C+"！"});this.form.btnBuy=$E(".btn-buy",this.form).addEvent("click",function(){this.form.action=this.url}.bind({url:this.form.action,form:this.form}));this.form.btnNotify=$E(".btn-notify",this.form).addEvent("click",function(){this.form.action=this.url}.bind({url:this.form.getProperty("gnotify"),form:this.form}));this.specCtls=$ES('select[name="spec"]',B);if(this.specCtls.length>0){this.pdtView=$E("table.goods-products");if($E("span.view-all-product",B)){$E("span.view-all-product",B).addEvent("click",this.pdtView.show.bind(this.pdtView))}if(this.pdtView){$ES("tbody tr",this.pdtView.content).each(function(C){var D=C.getProperty("info");if(D){this.products[D]=C}}.bind(this))}this.specCtls.addEvent("change",this.checkProduct.bind(this))}$ES("tbody.goods-adjunct-row",B).each(function(C){this.adjuncts.push(new AdjunctRecord(this,C).addEvent("change",this.rePrice.bind(this)))}.bind(this));this.checkProduct.bind(this)();this.form.setStyle("visibility","visible")},moneyFormat:function(A){A=A.toFloat();A=A.round(this.options.money_format.decimals)+"";var B=A.indexOf(".");if(B<0){B=A.length;part=""}else{part=A.substr(B+1)}while(part.length<this.options.money_format.decimals){part+="0"}var C=[];while(B>0){if(B>2){C.unshift(A.substr(B-=3,3))}else{C.unshift(A.substr(0,B));break}}return this.options.money_format.sign+C.join(this.options.money_format.thousands_sep)+this.options.money_format.dec_point+part},checkProduct:function(){if(this.specCtls.length>0){var C=[];var B=[];var A=[];this.specCtls.each(function(D){if(D.value=="_"){B.push(D)}else{A.push(D.value);C.push(D.getProperty("spec")+":"+D.value)}});if(B.length>0){this.productStatus=0}else{if(this.products[C.join("-")]&&!this.products[C.join("-")].getProperty("nostore")){this.productStatus=1}else{this.productStatus=-1}this.setOptions({nostore:this.products[C.join("-")].getProperty("nostore"),productId:this.products[C.join("-")].getProperty("product"),productName:this.options.name+":"+A.join(","),basePrice:parseFloat($E("td.price",this.products[C.join("-")]).getProperty("price"))});this.form.productText.innerHTML=this.options.productName+'<input type="hidden" name="goods[product_id]" value="'+this.options.productId+'" />'}}else{if(this.options.nostore&&this.options.nostore!="0"){this.productStatus=1}else{this.productStatus=-1}this.form.productText.innerHTML=this.options.name}this.rePrice.bind(this)()},onSubmit:function(D){var C=$E(".x-adjuncts",this.form).empty();for(var B=0;B<this.adjuncts.length;B++){for(var A=0;A<this.adjuncts[B].items.length;A++){new Element("input",{type:"hidden",name:"goods[adjunct]["+this.adjuncts[B].options.key+"]["+this.adjuncts[B].items[A].id+"]",value:this.adjuncts[B].items[A].num}).inject(C)}}},disable:function(A){A.removeEvents("click");A.addEvents({click:function(B){B=new Event(B).stop()},mouseenter:this.notice.bind(this)});A.setStyle("cursor","not-allowed");if(this.inited){this.notice()}this.btnDisabled=true},enable:function(A,B){this.removeNotice();A.removeEvents("click");A.removeEvents("mouseenter");A.addEvent("click",function(){this.form.action=this.url}.bind({url:this.form.action,form:this.form}));A.setStyle("cursor","pointer");this.btnDisabled=false},rePrice:function(){var B=[];var D=[];var A=this.options.basePrice.toFloat();this.adjuncts.each(function(F){if(!F.check.bind(F)()){B.push(F)}else{var E=[];A+=F.price.toFloat();F.items.each(function(G){E.push(G.name+"x"+G.num+'<input type="hidden" name="goods[adjunct]['+F.options.key+"]["+G.id+']" value="'+G.num+'" />')});if(E.length>0){D.push(F.options.name+":"+E.join(","))}}});this.form.adjunctText.innerHTML=D.join(" ");if(B.length>0){this.disable(this.form.btnBuy);var C=[];B.each(function(E){C.push(E.adjName)});C="请选择"+C.join();this.fireEvent("error",[C])}else{this.enable(this.form.btnBuy);if(this.viewPort.msg){this.viewPort.msg.empty()}}if(this.productStatus==1){this.form.price.setText(this.moneyFormat.bind(this)(A));this.viewPort.price.setText(this.moneyFormat.bind(this)(A));this.form.btnBuy.setStyle("display","");this.form.btnNotify.setStyle("display","none")}else{if(this.productStatus==0){$E(".g-total-price").innerHTML=this.moneyFormat.bind(this)(A);this.form.productText.innerHTML="请先选择商品规格";this.form.btnBuy.setStyle("display","");this.disable(this.form.btnBuy);this.fireEvent("error",["请先选择商品规格"]);this.form.btnNotify.setStyle("display","none")}else{if(this.productStatus==-1){this.form.price.setText(this.moneyFormat.bind(this)(A));this.viewPort.price.setText(this.moneyFormat.bind(this)(A));this.form.productText.innerHTML="缺货中";if(this.viewPort.msg){this.viewPort.msg.innerHTML="缺货中"}this.form.btnBuy.setStyle("display","none");this.form.btnNotify.setStyle("display","")}}}},notice:function(){if(this.goodsinteract){this.goodsinteract.addClass("error")}this.inited=true},removeNotice:function(){if(this.goodsinteract){this.goodsinteract.removeClass("error")}}});ProductViewer.implement(new Events,new Options);ProductTabViewer=new Class({initialize:function(){this.goodstabs=[];this.goodstabbodys=["all"];this.show=0;this.tabContainer=$E(".goods-detail-tab","goods-viewer");if($chk(this.tabContainer)){var A=this.mkTpl("商品详细信息").inject(this.tabContainer);A.addClass("showall").addClass("active");A.addEvent("click",this.showGoodsTab.bindAsEventListener(this,[A,true]))}$$(".pdtdetail").each(function(C){if(!C.getProperty("tab")){return }if(C.getProperty("tab")=="详细介绍"){this.goodsIntro=C;return }if(C.getProperty("visible")=="hide"){this.specIndex=this.goodstabbodys.length}var B=this.mkTpl(C.getProperty("tab"));B.addEvent("click",this.showGoodsTab.bindAsEventListener(this,[B])).injectInside(this.tabContainer);this.goodstabbodys.push(C)},this)},mkTpl:function(B){var A=new Element("div",{"class":"goodsDetailTab"}).setHTML("<span>"+B+"</span>");this.goodstabs.push(A);return A},showGoodsTab:function(F,E,D){F=new Event(F).stop();var B=this.goodstabs.indexOf(E);if(B==this.show){return }else{if(B===0){for(var C=1,A=this.goodstabbodys.length;C<A;C++){if(this.specIndex==C){this.goodstabbodys[C].setStyle("display","none");continue}this.goodstabbodys[C].setStyle("display","")}if(this.goodsIntro){this.goodsIntro.setStyle("display","")}}else{for(var C=1,A=this.goodstabbodys.length;C<A;C++){if(C===B){this.goodstabbodys[C].setStyle("display","")}else{this.goodstabbodys[C].setStyle("display","none")}}if(this.goodsIntro){this.goodsIntro.setStyle("display","none")}}}this.goodstabs[this.show].removeClass("active");this.goodstabs[B].addClass("active");this.show=B}});var gStore={_d:{},data:function(C){if(!gStore._d[C]){var A=Cookie.get("S[ST_"+C+"]");A=A.length>0?A.split("_"):[];for(var B=0;B<A.length;B++){A[B]=A[B].replace("^&","_").split(".");A[B][0].replace("^#",".")}gStore._d[C]=A}return gStore._d[C]},add:function(C,B,E,A){if(!A){A=10}var D=gStore.data(C);if(B&&E){gStore._d[C]=D.filter(function(F){return F[1]!=E});gStore._d[C].unshift([B.clean(),E])}if(gStore._d[C].length==(A+1)){gStore._d[C].pop()}gStore.save(C)},save:function(B){var A=[];gStore.data(B).each(function(C){A.push((C[0].replace(".","^#")+"."+C[1]).replace("_","^%"))});Cookie.set("S[ST_"+B+"]",A.join("_"))},display:function(B,A,C){gStore.data(B).each(function(E){var D=A.replace(/\%GNAME\%/g,E[0]).replace(/\%GID\%/g,E[1]);if(C){C.innerHTML+=D}else{document.write(D)}})},clear:function(A){Cookie.get("S[ST_"+A+"]","")},remove:function(A,B){gStore._d[A]=gStore.data(A).filter(function(C){return C[1]!=B});gStore.save(A)},toggle:function(C,B,E,A){var D=true;gStore._d[C]=gStore.data(C).filter(function(F){if(F[1]==E){D=false;return false}else{return true}});if(D){gStore.add(C,B,E,A)}else{gStore.save(C)}return D}};var GoodsPic=new Class({initialize:function(){this.container=$E(".goods-detail-pic-thumbnail");this.imgs=$ES("img",this.container);this.imgEl=$E(".goods-detail-pic").getElement("img");if(!this.container||!this.imgs){return }this.srcs=[];this.detailImgs=[];this.current=0;this.maxHeight=80;this.maxWidth=80;this.imgs.each(function(A,B){this.detailImgs.push(new Element("img",{src:this.setImgSrc(A.getAttribute("src"))}));A.addEvent("mouseenter",this.changeImg.bind(this,[B]))}.bind(this));$ES("a",this.container.getParent()).each(function(A){A.addEvent("click",function(E){E=new Event(E).stop();var B=A.getProperty("href");var C=window.screen.height*0.8;var D=window.screen.width*0.8;window.open(B,"newwindow","height="+C+", width="+D+", top=100, left=100,status=no, resizable=no, location=no, scrollbars=no")})})},setImgSrc:function(D){var C=D.slice(D.lastIndexOf("/")+1);var A=C.slice(0,C.indexOf("_"));if(A=="gpic"){var B=D.slice(0,D.lastIndexOf("/")+1)+C.replace(/thumbnail/,"small");return B}else{return D}},changeImg:function(A){this.current=A;this.imgEl=this.imgEl.replaceWith(this.detailImgs[this.current]);DrawImage(this.imgEl,this.maxWidth,this.maxHeight)},DrawImage:function(A,B){if(B&&A){this.maxHeight=B;this.maxWidth=A}}});var goodsStar={els:[],init:function(){goodsStar.els=$ES(".favViewer");var D=gStore.data("FAV");var B=$ES("li[star]");if(D.length==0){for(var A=0;A<B.length;A++){B[A].className="star-off";B[A].addEvent("click",goodsStar.change)}}else{var C={};D.each(function(E){C[E[1]]=1});for(var A=0;A<B.length;A++){B[A].className=C[B[A].getAttribute("star")]?"star-on":"star-off";B[A].addEvent("click",goodsStar.change)}}goodsStar.page()},change:function(){var B=this.getAttribute("star");if(this.className=="star-on"){$E("a",this).setText("加入收藏");var A="star-off";new Ajax("?member-"+B+"-ajaxDelFav.html",{method:"post",update:"",data:"t="+new Date().getTime()}).request()}else{$E("a",this).setText("已加入收藏");new Ajax("?member-"+B+"-ajaxAddFav.html",{method:"post",update:"",data:"t="+new Date().getTime()}).request()}var A=gStore.toggle("FAV",this.getAttribute("title"),B,11)?"star-on":"star-off";$ES("li[star="+B+"]").each(function(C){C.className=A});goodsStar.page()},page:function(){var A="";gStore.data("FAV").each(function(B){A+='<li><input type="checkbox" name="goods[]" value="'+B[1]+'" />'+B[0]+"</li>"});A+="";goodsStar.els.each(function(B){$E("ul",B).innerHTML=A;B.style.visibility=""})}};window.addEvent("domready",goodsStar.init);window.addEvent("domready",function(){$ES(".buy-select").each(function(A){new QMenu(A,$E(".buy-select-list",A))});this.number=$E(".cart-number");if(this.number){this.number.setText(Cookie.get("S[CART_COUNT]")?Cookie.get("S[CART_COUNT]"):0);if(Shop.set.buytarget==3){this.cartEl=$E(".cart-container");this.stick=this.cartEl.getAttribute("stick");this.number=$E(".cart-number",this.cartEl);if(this.cartEl){$ES("a[buy]").addEvent("click",function(G){var B=$(new Event(G).stop().target);for(var F=B.getParent();!F.getAttribute("product");F=F.getParent()){}var E={type:B.getAttribute("type"),gid:B.getAttribute("buy"),pid:B.getAttribute("product")};new Ajax(Shop.url.addcart,{method:"post",data:E,onSuccess:function(){this.number.setText(Cookie.get("S[CART_COUNT]"))}.bind(this)}).request();var A=new Element("div",{style:"border:1px solid #000;position: absolute;z-index:65530"}).setStyles(F.getCoordinates()).inject(document.body);var D=A.effects({duration:600,transition:Fx.Transitions.Quart.easeOut});var C=this.cartEl.getCoordinates();if(this.stick&&!window.ie6){C.top+=window.getScrollTop()}D.start(C).chain(function(){A.remove()})}.bind(this))}}}}.bind({}));var QMenu=new Class({options:{overshow:true,delay:500},initialize:function(B,C,A){this.setOptions(A);this.base=$(B);this.menu=$(C);if(this.options.overshow){this.base.addEvent("mouseover",this.show.bind(this))}else{this.base.addEvent("click",this.show.bind(this))}},show:function(A){if(!this.showing){this.showing=true;if(!this.moreOnce){this.moreOnce=true;this.fireEvent("firstshow",{target:this.menu,type:"first"});if(this.options.overshow){this.menu.addEvents({mouseover:function(){this.overmenu=true}.bind(this),mouseout:function(){this.overmenu=false;this.hide.delay(this.options.delay,this)}.bind(this)});this.base.addEvent("mouseout",function(){this.overbase=false;this.hide.delay(this.options.delay,this)}.bind(this))}}this.menu.setStyle("display","");this.fireEvent("show",{target:this.menu,type:"show"})}if(this.options.overshow){this.overbase=true}},hide:function(){if(this.showing){if(this.options.overshow&&(this.overbase||this.overmenu)){return }this.showing=false;this.menu.setStyle("display","none");this.fireEvent("hide",{target:this.menu,type:"hide"})}}});QMenu.implement(new Events,new Options);var shopEffect={loadMask:function(A){A.innerHTML="loading..."},message:function(A){alert(A)},addCart:function(E,D){var E=$(E);var D=$(D);var C=E.clone().setStyles(E.getCoordinates()).setStyles({opacity:0.7,position:"absolute",background:"#fff",border:"2px solid #000","z-index":999,overflow:"hidden"});C.innerHTML="";C.removeEvent("click");var B=C.effects({duration:1000,transition:Fx.Transitions.Quart.easeOut});var A=D.getCoordinates();C.inject(document.body);B.start(A).chain(function(){C.remove()})}};var shopWidgets={init:function(){var A="";$ES("div[shopget]").each(function(C){var B=C.getAttribute("shopget");A+="w[]="+B;shopWidgets.w[B]=C});if(A!=""){new Element("script",{type:"text/javascript",src:"http://widgets.shopex.cn/get.php?"+A}).injectInside(document.body)}},w:{},render:function(A){for(i in A){shopWidgets.w[i].innerHTML=A[i]}}};window.addEvent("domready",shopWidgets.init);