www.gusucode.com > ShopEx481 & PHPWind 整合版码程序 > statics/foot.js

    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==""||/^.+@.+$/.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(H,I){var M=[];var J=I.getAttribute("required");var F=I.getAttribute("vtype");var D=H.getAttribute("extra");var A;if(J=="true"){M.push("required")}if(F){M.push(F)}for(var G=0,K=M.length;G<K;G++){var E=this.validation[M[G]];if(E){var C=E[0];var B=E[1];this.bingValidator(H,I);if(!B(I.value)){A=I.getNext();if(!A||A.getAttribute("name")!="validationMsgBox"){this.msgbox(C).injectAfter(I)}return false}}}if(D&&extra_validator){if(vobj=extra_validator[D]){var E=vobj[F];if(E){var C=E[0];var B=E[1];if(!B(H,I.value)){A=I.getNext();if(!A||A.getAttribute("name")!="validationMsgBox"){this.msgbox(C).injectAfter(I)}return false}}}}return true},msgbox:function(A){return new Element("div",{"class":"valierror",name:"validationMsgBox"}).setHTML(A)},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){var I=validator.test(B,H);if(!I){E.push(G)}C&=I});if(!C){F.preventDefault();try{D[E[0]].focus()}catch(F){}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.scope=document.body;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))}else{this.redraw();$(this.calendarID).setStyles({display:"block",left:$pick(A,this.options.x),top:$pick(B,this.options.y)})}if(window.ie6){$fixSelectOpacity(0,$(this.calendarID))}this.visible=true},hide:function(){if(this.visible){$(this.calendarID).setStyle("display","none");this.visible=false}if(window.ie6){$fixSelectOpacity(1,$(this.calendarID))}},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);new Element("span",{"class":"closeCalBtn",events:{click:function(J){new Event(J).stop();this.hide()}.bind(this)}}).setText("× close").inject(G);G.inject(this.scope);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(this.mc){return }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()}});return this}});(function(){function E(){return new Swiff(Shop.set.path+"statics/sop.swf",{id:"shareObjectsStorage",container:$("shareObjectsStorage_panel"),width:1,height:1})}E();ViewState=new Class({initialize:function(I){this.storage=F();return this},set:function(I,K,M){var J=this;try{if(!I||!this.storage){return false}this.storage.getStorage(I,function(N){N=$splat(H(N));N.include(K);J.storage.setStorage(I,G(N),M)})}catch(L){return false}},get:function(I,K){try{if(!I||!this.storage){return false}return this.storage.getStorage(I,function(L){K($splat(H(L)))})}catch(J){return false}},remove:function(I,K){try{if(!I||!this.storage){return false}return this.storage.removeStorage(I,K)}catch(J){return false}},clear:function(J){try{if(!this.storage){return false}return this.storage.clearStorage(J)}catch(I){return false}}});function H(I){return I?Json.evaluate("("+I+")"):null}function G(I){return I?Json.toString(I):null}function F(){if(!!window.sessionStorage){return C.init()}if(window.ie){return D.init()}if(!!window.openDatabase){return A.init()}if(Browser.Plugins.Flash.version>=6){return B.init()}return false}var C={init:function(){this.Master="firefox2+ Ie8";if(!window.globalStorage){E();return B.init()}this._storage=globalStorage[location.hostname];return this},setStorage:function(I,J,K){this._storage.setItem(I,J);K();return true},getStorage:function(I,L){var J=this._storage.getItem(I);var K=J?J.value:null;L(K);return true},removeStorage:function(I,J){this._storage.removeItem(I);J();return true},clearStorage:function(I){if(this._storage.clear){this._storage.clear()}else{for(i in this._storage){if(this._storage[i].value){this.remove(i)}}}I();return true}};var D={init:function(){this.Master="ie6+";if(!window.ie){return false}this._storage=new Element("span").setStyles({display:"none",behavior:"url('#default#userData')"}).inject(document.body);return this},setStorage:function(I,J,K){this._storage.setAttribute(I,J);this._storage.save("shopEX_VS");K();return true},getStorage:function(I,J){this._storage.load("shopEX_VS");J(this._storage.getAttribute(I));return true},removeStorage:function(I,J){this._storage.removeAttribute(I);this._storage.save("shopEX_VS");J();return true},clearStorage:function(J){var I=new Date();I.setMinutes(I.getMinutes()-1);this._storage.expires=I.toUTCString();this._storage.save("shopEX_VS");this._storage.load("shopEX_VS");J();return true}};var B={init:function(){this.Master="All user agents with flash plugin >= 6";this._storage=$("shareObjectsStorage");return this},setStorage:function(I,J,K){this._storage.setStorage(J,I);K();return true},getStorage:function(I,J){J(this._storage.getStorage(I));return true},removeStorage:function(I,J){this._storage.removeStorage(I);J();return true},clearStorage:function(I){this._storage.cleanStorage();I();return true}};var A={init:function(){this.Master="Safari (Version >= 3.1) openDatabase";if(!window.openDatabase){return false}this._storage=openDatabase("viewState","1.0","ShopEX48 ViewState Storage",200000);this._createTable();return this},setStorage:function(I,J,K){this._storage.transaction(function(L){L.executeSql("SELECT v FROM SessionStorage WHERE k = ?",[I],function(N,M){if(M.rows.length>0){N.executeSql("UPDATE SessionStorage SET v = ?  WHERE k = ?",[J,I],K)}else{N.executeSql("INSERT INTO SessionStorage (k, v) VALUES (?, ?)",[I,J],K)}})});return true},getStorage:function(I,J){this._storage.transaction(function(K){K.executeSql("SELECT v FROM SessionStorage WHERE k = ?",[I],function(M,L){if(L.rows.length>0){return J(L.rows.item(0).v)}J()})});return true},removeStorage:function(I,J){this._storage.transaction(function(K){K.executeSql("DELETE FROM SessionStorage WHERE k = ?",[I])});J();return true},clearStorage:function(I){this._storage.transaction(function(J){J.executeSql("DROP TABLE SessionStorage",[],I)});return true},_createTable:function(){this._storage.transaction(function(I){I.executeSql("SELECT COUNT(*) FROM SessionStorage",[],$empty,function(J,K){J.executeSql("CREATE TABLE SessionStorage (k TEXT, v TEXT)",[],$empty)})})}}})();(function(){var A;window.addEvent("domready",function(){A=["<div class='head'>","<div class='title'>正在加载...</div>","<div class='closeBtn'>关闭</div>","</div>","<div class='headContent'></div>","<div class='body dialogContent'  container='true'>","正在加载... ","</div>","<div class='footContent'></div>","<div class='foot'>","<div class='resizeBtn'>┛</div>","</div>"].join("\n");MODALPANEL=$("MODALPANEL")||new Element("div",{id:"MODALPANEL"}).set({styles:{position:"absolute",background:"#333333",width:window.getSize().size.x,height:window.getSize().size.y,top:0,left:0,display:"none",zIndex:65534,opacity:0.4}}).inject(document.body);new Element("div",{id:"loadMask"}).setStyles({position:"absolute",border:"2px solid #ff9900",background:"#fff",padding:10,zIndex:65535,display:"none"}).setText("Loading...").inject(document.body)});Dialog=new Class({Implements:[Options,Events],options:{onShow:Class.empty,onHide:Class.empty,onClose:Class.empty,onLoad:Class.empty,width:500,height:400,title:" ",dragable:true,resizeable:true,ajaksable:false,singlon:false,modal:false,ajaxoptions:{update:false,evalScripts:true,method:"get",autoCancel:true}},initialize:function(C,B){if($ES(".dialog").some(function(E,D){if(E.retrieve("serial")==C.toString().trim()){E.inject(document.body);return true}})){return }this.setOptions(B);B=this.options;this.UID=(Native.UID)++;if(!A){A=$("dialogProtoType").innerHTML;$("dialogProtoType").empty()}this.dialog=new Element("div",{id:"dialog_"+this.UID,"class":"dialog",styles:{visibility:"hidden",zoom:1,opacity:0,zIndex:65534}}).setHTML(A).inject(document.body).store("serial",C.toString().trim());this.dialog_head=$E(".head",this.dialog).addEvent("click",function(D){if(this.getNext()){this.inject(document.body)}}.bind(this.dialog));this.dialog_body=$E(".body",this.dialog);$E(".title",this.dialog_head).setText(B.title||"Dialog");$E(".closeBtn",this.dialog_head).addEvent("click",function(D){if(D){D=new Event(D).stop()}this.close()}.bind(this));if(B.dragable){this.dragDialog()}if(B.resizeable){this.dialog_body.makeResizable({handle:$E(".resizeBtn",this.dialog),limit:{x:[B.width,800],y:[100,800]},onDrag:function(){this.setDialogWidth()}.bind(this)});this.dialog_body.setStyle("overflow","scroll")}else{$E(".resizeBtn",this.dialog).hide();this.dialog_body.setStyle("overflow","hidden")}this.dialogShowEffect=this.dialog.effect("opacity");$extend(B.ajaxoptions,{update:this.dialog_body,elMap:{".mainHead":$E(".headContent",this.dialog).hide(),".mainFoot":$E(".footContent",this.dialog).hide()},onRequest:function(){this.setDialog_bodySize()}.bind(this),onFailure:function(){this.close();alert("加载弹出内容失败!")}.bind(this),onComplete:function(D){if("onComplete" in B){B.onComplete(D)}this.onLoad.call(this)}.bind(this)});this.popup(C,B)},onLoad:function(C){var B=$E("*[isCloseDialogBtn=true]",this.dialog);if(B){B.addEvent("click",this.close.bind(this))}this.show()},initContent:function(C,B){B=B||this.options;if($type(C)=="string"){if(B.ajaksable){W.page(C,B.ajaxoptions)}else{new Ajax(C,B.ajaxoptions).request()}}else{try{this.dialog_body.empty().adopt(C)}catch(D){this.dialog_body.setHTML("内容加载失败.!")}this.onLoad.call(this)}},popup:function(C,B){if(B.modal||B.singlon){MODALPANEL.show()}$("loadMask").amongTo(window).show();this.fireEvent("onShow",this);this.initContent(C,B)},show:function(){this.setDialog_bodySize();$("loadMask").hide();this.dialog.amongTo(window);$fixSelectOpacity(0,this.dialog);this.fireEvent("onLoad",this)},close:function(){this.fireEvent("onClose",this.dialog);this.dialog.empty().remove();$("dialogdragghost_"+this.UID)?$("dialogdragghost_"+this.UID).remove():"";if(!$E(".dialog")){MODALPANEL.hide();$fixSelectOpacity(1,this.dialog)}},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,width:this.options.width});this.setDialogWidth()},setDialogWidth:function(){this.dialog.setStyle("width",this.dialog_body.getSize().size.x)},dragDialog:function(){var B=this.dialog;var C=new Element("div",{id:"dialogdragghost_"+this.UID});C.setStyles({position:"absolute",border:"2px #333333 dashed",cursor:"move",background:"#66CCFF",display:"none",opacity:0.3,zIndex:65535}).inject(document.body);this.addEvent("load",function(D){C.setStyles(B.getCis())});new Drag(C,{handle:this.dialog_head,limit:{x:[0,window.getSize().x],y:[0,window.getSize().y]},onStart:function(){C.setStyles(B.getCis());C.show()},onComplete:function(){var D=C.getPosition();B.setStyles({top:D.y,left:D.x});C.hide()}})}})})();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 updateTime=0;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}},countItem:function(A,B){if(A.getAttribute("price")){$E(".itemTotal",B).innerHTML=Cart.moneyFormat(A.getAttribute("price").toFloat()*$E("input[name^=cartNum[]",B).value)}if(A.getAttribute("point")){$E(".itemTotal",B).innerHTML=A.getAttribute("point").toFloat()*$E("input[name^=cartNum[]",B).value}},update:function(A,C,B,D,E){if(C==updateTime){new XHR({method:"post",data:$("form-cart"),onSuccess:function(F){if(F.length>100){B.setProperty("number",D.value);$("cartTotal").setHTML(F);Cart.countItem(E,B)}else{D.value=B.getProperty("number");alert(F)}updateTime=0}}).send(A)}},inputUpdate:function(B){B=new Event(B);var A=$(B.target);for(obj=A.getParent();!obj.getAttribute("urlupdate");obj=obj.getParent()){}if(obj.getProperty("number").toInt()>A.value){A.value=A.value.toInt()+1;var C=$E(".decrease",obj)}else{A.value=A.value.toInt()-1;var C=$E(".increase",obj)}B.target=C;C.fireEvent("click",B)},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,onComplete:function(D,C,E){if(window.ie){$("amountInfo").setHTML(D)}}}).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()},moneyFormat:function(A){A=A.toFloat();A=A.round(moneyFormat.decimals)+"";var B=A.indexOf(".");if(B<0){B=A.length;part=""}else{part=A.substr(B+1)}while(part.length<moneyFormat.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 moneyFormat.sign+C.join(moneyFormat.thousands_sep)+moneyFormat.dec_point+part}};$ES(".increase","form-cart").each(function(A){A.addEvent("click",function(C){C=new Event(C).stop();var B=C.target;for(obj=B.getParent();!obj.getAttribute("urlupdate");obj=obj.getParent()){}$E("input[name^=cartNum[]",obj).value=$E("input[name^=cartNum[]",obj).value.toInt()+1;Cart.update.delay(800,this,[obj.getAttribute("urlupdate"),++updateTime,obj,$E("input[name^=cartNum[]",obj),B])})});$ES(".decrease","form-cart").each(function(A){A.addEvent("click",function(C){C=new Event(C).stop();var B=C.target;for(obj=B.getParent();!obj.getAttribute("urlupdate");obj=obj.getParent()){}if($E("input[name^=cartNum[]",obj).value.toInt()>1){$E("input[name^=cartNum[]",obj).value=$E("input[name^=cartNum[]",obj).value.toInt()-1;Cart.update.delay(800,this,[obj.getAttribute("urlupdate"),++updateTime,obj,$E("input[name^=cartNum[]",obj),B])}})});$ES(".quiet","form-cart").each(function(A){A.addEvent("click",function(D){D=new Event(D).stop();var C=D.target;for(obj=C.getParent();!obj.getAttribute("urlremove");obj=obj.getParent()){}var B=obj.getAttribute("urlremove");obj.remove();new Ajax(B,{method:"post",update:"cartTotal",data:$("form-cart")}).request()})});if($("clearCart")){$("clearCart").addEvent("click",function(C){C=new Event(C).stop();var B=C.target;var A=B.getAttribute("url");$("cartItems").remove();new Ajax(A,{method:"post",onComplete:function(D){$("cart-items").remove();$("cart-coupon").remove();$("cart-none-msg").style.display="inline"}}).request()})}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")})}$ES(".cal").each(function(A){A.makeCalable()});var compare_goods=new Class({showad:true,Toppx:0,PageWidth:window.getWidth()-210,MinScreenW:window.screen.height,initialize:function(){var A='<div class="title"><h3 >商品对比 <a class="close fontnormal fontcolorOrange" onClick="show_compare.hidead();return false;" href="#">[关闭]</a></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]"));if($chk(B)){for(i=0;i<B.length;i++){E+="<div class='division clearfix' id='goods_"+C[i]+"'><div class='span-3'><span title='"+D[i]+"'><a href='?product-"+C[i]+".html'>"+D[i]+"</a></span></div><a class='floatRight lnk' href='#' onClick='show_compare.del_compare("+C[i]+");return false;'>删除</a></div>"}}document.write('<div id="goods_compare" class="FormWrap" style="width:180px;position: absolute;top:-1000px; display:none;z-index:1000">'+A+'<form id="-form-diff" action="'+Shop.url.product_diff+'" method="post" target="_compare_goods"><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()-210;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(",");if(I.length>=4){alert("对比的产品不能超过4个");return false}else{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='division clearfix' id='goods_"+B+"'><div class='span-3'><span title='"+A+"'><a href='?product-"+B+".html'>"+A+"</a></span></div><a class='floatRight lnk' href='#' onClick='show_compare.del_compare("+B+");return false;'>删除</a></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 D=[];var C=[];var B=[];this.specCtls.each(function(F){if(F.value=="_"){C.push(F)}else{B.push(F.value);D.push(F.getProperty("spec")+":"+F.value)}});if(C.length>0){this.productStatus=0}else{var A=this.products[D.join("-")];var E=function(F){return A?A.getProperty(F):null};E("nostore")?this.productStatus=-1:this.productStatus=1;this.setOptions({nostore:E("nostore"),productId:E("product"),productName:this.options.name+":"+B.join(","),productBn:E("bn"),basePrice:parseFloat($E("td.price",this.products[D.join("-")]).getProperty("price"))});if($("goodsBn")){$("goodsBn").innerHTML=this.options.productBn}if(this.options.scoresetting==1&&$("goodsScore")){$("goodsScore").innerHTML=(this.options.basePrice*this.options.scorerate).toInt()}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='缺货中<input type="hidden" name="goods[product_id]" value="'+this.options.productId+'" />';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=$chk(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(B,A){this.container=$E(".goods-detail-pic-thumbnail");this.imgs=$ES("img",this.container);this.imgEl=$E(".goods-detail-pic","goods-viewer").getElement("a");if(!this.container||!this.imgs){return }this.maxHeight=A||$E(".goods-detail-pic","goods-viewer").getSize().y;this.maxWidth=B||$E(".goods-detail-pic","goods-viewer").getSize().x;this.imgs.each(function(C,D){C.addEvent("mouseenter",this.changeImg.bind(this,[C.src,C.alt]))}.bind(this));this.imgs[0].fireEvent("mouseenter");$ES("a",this.container.getParent()).each(function(C){C.addEvent("click",function(G){G=new Event(G).stop();var D=C.getProperty("href");var E=window.screen.height*0.8;var F=window.screen.width*0.8;window.open(D,"newwindow","height="+E+", width="+F+", 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(F,E){var D=this.imgEl;var B=this.setImgSrc(F);D.empty().setOpacity(0);var G=D.getParent();G.addClass("goods-detail-pic_loading");var C=this;var A=new Asset.image(B,{alt:E,onload:function(){var H=$(this);if(H.$e){return }H.zoomImg(C.maxWidth,C.maxHeight);G.removeClass("goods-detail-pic_loading");D.empty().adopt(H);var I={opacity:1,"margin-top":0};if(D.getSize().y<G.getSize().y){I=$merge(I,{"margin-top":(G.getSize().y-D.getSize().y)/2})}D.effects().start(I);H.$e=true},onerror:function(){G.removeClass("goods-detail-pic_loading");D.setHTML('<span style="diaplay:block;font-family:Verdana;margin:10px;">NO PHOTO</span><h4>'+E+"</h4>")}})}});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";if(B[A].className=="star-on"&&B[A].getParent().className=="textbutton textcenter"){B[A].setText("已加入收藏")}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("index.php?member-"+B+"-ajaxDelFav.html",{method:"post",update:"",data:"t="+new Date().getTime()}).request()}else{$E("a",this).setText("已加入收藏");new Ajax("index.php?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;!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);