var Photo={prompt:new Prompt(),photoDel:function(B,A){this.prompt.confirm(["删除图片","确定要删除此图片吗？"],{onReturn:function(C){if(C){this.delfn(B,A)}}.bind(this)})},delfn:function(B,A){new AjaxReq({url:"/photo.v",method:"post",callType:"json",data:{"do":"photodel",photoid:B,userid:A},onRequest:function(){if(Mbox.isOpen){Mbox.openLite('<div class="Doing">正在删除，请稍候......</div>',300,30,{closable:0})}},onSuccess:function(C){if(C.code==200){if(Mbox.isOpen){Mbox.openLite('<div class="Doing">图片删除成功！</div>',300,30,{closable:0})}var D="/member/"+A+"/photos";window.setTimeout("location.replace('"+D+"');",1000)}else{Photo.prompt.alert(["确定",C.msg||"操作失败"])}Mbox.close()}}).send()},photoEdit:function(B,A){new AjaxReq({url:"/photo.v",method:"post",callType:"json",data:{"do":"photoedit",photoid:B,userid:A},onSuccess:function(C){if(C.code==200){Photo.photoEditShow(B,A,C.msg.t,C.msg.st,C.msg.pt)}else{Photo.prompt.alert(["确定",C.msg||"操作失败"])}}}).send()},photoEditShow:function(M,D,H,A,C){var G=new Element("input",{type:"text",value:H,maxlength:20}).setStyles({width:"200px"});var I=new Element("span");var K=new Element("input",{type:"button",value:"提交"}).setStyles({cursor:"pointer",width:"60px"});var L=new Element("input",{type:"button",value:"取消"}).setStyles({cursor:"pointer",width:"60px"});var B=new Element("div").setStyles({padding:"10px 15px"});var E="";if(A=="10"){switch(C){case"1":E+='<div><br />图片类型:<input type="radio" value="1" name="type_item" checked />环境<input type="radio" value="2" name="type_item" />菜式<input type="radio" value="3" name="type_item" />其他</div>';break;case"2":E+='<div><br />图片类型:<input type="radio" value="1" name="type_item" />环境<input type="radio" value="2" name="type_item" checked />菜式<input type="radio" value="3" name="type_item" />其他</div>';break;case"3":E+='<div><br />图片类型:<input type="radio" value="1" name="type_item" />环境<input type="radio" value="2" name="type_item" />菜式<input type="radio" value="3" checked name="type_item" />其他</div>';break}}else{if(A=="60"){switch(C){case"":E+='<div><br />图片类型:<input type="radio" value="1" name="type_item"/>大堂<input type="radio" value="2" name="type_item" />外景<input type="radio" value="3" name="type_item" />房间<input type="radio" value="4" name="type_item" />其他</div>';break;case"1":E+='<div><br />图片类型:<input type="radio" value="1" name="type_item" checked />大堂<input type="radio" value="2" name="type_item" />外景<input type="radio" value="3" name="type_item" />房间<input type="radio" value="4" name="type_item" />其他</div>';break;case"2":E+='<div><br />图片类型:<input type="radio" value="1" name="type_item" />大堂<input type="radio" value="2" name="type_item" checked />外景<input type="radio" value="3" name="type_item" />房间<input type="radio" value="4" name="type_item" />其他</div>';break;case"3":E+='<div><br />图片类型:<input type="radio" value="1" name="type_item" />大堂<input type="radio" value="2" name="type_item" />外景<input type="radio" value="3" checked name="type_item" />房间<input type="radio" value="4" name="type_item" />其他</div>';break;case"4":E+='<div><br />图片类型:<input type="radio" value="1" name="type_item" />大堂<input type="radio" value="2" name="type_item" />外景<input type="radio" value="3" name="type_item" />房间<input type="radio" value="4" checked name="type_item" />其他</div>';break}}}B.appendText("图片标题: ").adopt([G,I]).appendHTML(E);G.addEvent("blur",function(){if(!$isMatch(G,$isMatch.MORE,0,true)){I.set("text","图片名不能为空").className="fv-err";G.store("valid",false)}else{I.set("text","").className="";G.store("valid",true)}});var J=function(){var N=true;[G].each(function(O){O.fireEvent("blur");if(!O.retrieve("valid")){N=false}});return N};var F=function(){var N;$$('[name="type_item"]').each(function(O){if(O.checked){N=O.value}});return N};K.addEvent("click",function(O){var N=F();if(J()){new AjaxReq({url:"/photo.v",method:"post",callType:"json",data:{"do":"photoeditsave",photoid:M,userid:D,pt:N,t:G.get("value")},onRequest:function(){if(Mbox.isOpen){Mbox.openLite('<div class="Doing">正在修改……</div>',100,30,{closable:0})}},onSuccess:function(P){if(P.code==200){if(Mbox.isOpen){Mbox.openLite('<div class="Doing">修改成功！</div>',200,30,{closable:0})}setTimeout(function(){Mbox.close()},1000);window.location.reload(true)}else{Photo.prompt.alert(["确定",P.msg||"操作失败"])}}}).send()}});L.addEvent("click",function(){if(Mbox.isOpen){Mbox.close()}});if(A=="10"||A=="60"){Mbox.open({url:$dialog("图片修改",[B],[K,L]),size:{x:315,y:185}})}else{Mbox.open({url:$dialog("图片修改",[B],[K,L]),size:{x:315,y:145}})}},photoCursor:function(C,B){$(B).title="change";$(B).title="";var A=function(J){var D=J.page.x;var F=$(C);var H=$(C).width;var G=$(C).offsetLeft;var I=$("preview");var E=$("next");while(F.offsetParent){G+=F.offsetParent.offsetLeft;F=F.offsetParent}if(D<(G+H/2)){if(I.href!=null&&I.href!=""){$(C).className="currentPhotoPre";$(B).title="上一张"}else{$(C).className="currentPhoto";$(B).href="#";$(B).title="已到第一张图片"}}else{if(E.href!=null&&E.href!=""){$(C).className="currentPhotoNext";$(B).title="下一张"}else{$(C).className="currentPhoto";$(B).href="#";$(B).title="已到最后一张图片"}}};$(C).addEvent("mousemove",A)},photoClick:function(C,B){var A=function(J){var D=J.page.x;var F=$(C);var H=$(C).width;var G=$(C).offsetLeft;var I=$("preview");var E=$("next");while(F.offsetParent){G+=F.offsetParent.offsetLeft;F=F.offsetParent}if(D<(G+H/2)){if(I.href!=null&&I.href!=""){$(B).href=I.href;pageTracker._trackPageview("dp_photos_preview2")}else{$(B).href="#"}}else{if(E.href!=null&&E.href!=""){$(B).href=E.href;pageTracker._trackPageview("dp_photos_next2")}else{$(B).href="#"}}};$(C).addEvent("click",A)},MovePrevious:function(){if($("shop_p").className=="previous unable"){$("shop_p").title="第一组"}else{$("shop_p").title="上一组"}},MoveNext:function(){if($("shop_n").className=="next unable"){$("shop_n").title="最后一组"}else{$("shop_n").title="下一组"}},CityChange:function(C,A){var B=$(C).value;new AjaxReq({url:"/shop.v",method:"post",callType:"json",data:{"do":"fst",cityID:B},onSuccess:function(D){$(A).options.length=0;if(D.code==200){var F=D.msg.data.length;for(var E=0;E<F;E++){$(A).options.add(new Option(D.msg.data[E].categoryName,D.msg.data[E].categoryID))}}}}).send()},searchShopName:function(F,B,D,C,E){var G=$(B).value;var A=$(D).value;var H=$(C).value;new AjaxReq({url:"/photo.v",method:"post",callType:"json",data:{"do":"findshopname",cityID:G,name:H,shopType:A},onSuccess:function(I){$(E).style.display="";$(E).options.length=0;if(I.code==200){var K=I.msg.data.length;if(K!=0){for(var J=0;J<K;J++){$(E).options.add(new Option(I.msg.data[J].ShopName+I.msg.data[J].BranchName+I.msg.data[J].ShopPower+I.msg.data[J].Address,I.msg.data[J].ShopID))}$(E).options.add(new Option("以上都不是,选择添加新商户","-1"));$(E).options[K].className="Color8"}else{$(E).options.add(new Option("没有找到匹配商户,选择添加新商户","-1"));$(E).options[0].className="Color8"}}}}).send()},AddShopReview:function(A,C,B){var F=$(C);var E=F.options[F.selectedIndex].value;var D=F.options[F.selectedIndex].text;$(B).value=E;$(A).value=D}};