var Photo={prompt:new Prompt(),hash:{a:[]},photoDel:function(D,B,C,A){this.prompt.confirm(["删除图片","确定要删除此图片吗？"],{onReturn:function(E){if(E){this.delfn(D,B,C,A)}}.bind(this)})},delfn:function(D,B,C,A){new AjaxReq({url:A||"/ajax/json/pic/delete",method:"post",callType:"json",data:{biz:C,photoid:D,userid:B},onRequest:function(){if(Mbox.isOpen){Mbox.openLite('<div class="Doing">正在删除，请稍候......</div>',300,30,{closable:0})}},onSuccess:function(E){if(E.code==200){if(Mbox.isOpen){Mbox.openLite('<div class="Doing">图片删除成功！</div>',300,30,{closable:0})}var F="/member/"+B+"/photos";window.setTimeout("location.replace('"+F+"');",1000)}else{Photo.prompt.alert(["确定",E.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}})}},photoNav:function(D,H,K,M){var O=$(D),B=DP.data("nav"),C={left:(B.left&&B.left!="")?B.left:null,right:(B.right&&B.right!="")?B.right:null},N={left:"dp_photos_preview2",right:"dp_photos_next2"},G={left:"cursor-left",right:"cursor-right"},F={left:{yes:"点击查看上一张",no:"没有上一张啦"},right:{yes:"点击查看下一张",no:"没有下一张啦"}};H=$(H);function A(U){var P=C[U];var R=new Element("div");var T=U=="left"?(E-$("aDetail").getStyle("width").toFloat())/2+3:(-J/2+7);var Q=(new Element("img",{src:H.src}));var S=["position:absolute","opacity:0","filter:alpha(opacity=0)","overflow:hidden","width:50%","height:"+L+"px","top:0",U+":0"].join(";");R.style.cssText=S;if(Browser.ie&&Browser.version==6){Q.setStyles({position:"relative",top:-8,left:T,height:H.getHeight()})}Q.inject(R,"bottom");R.set("title",P?F[U]["yes"]:F[U]["no"]);R.addClass(P?G[U]:"");R.addEvent("click",function(){if(P){location.href=P+"#single-img";pageTracker._trackPageview(N[U])}});R.inject(O,"bottom")}if(O){var L=O.getHeight(),E=O.getWidth(),I=H.getHeight(),J=H.getWidth();O.setStyle("position","relative");A("left");A("right")}},toggleMore:function(G,D){G=$(G);var E,F="J_active",B=false,A,C=Photo.hash.a;if(G){D=D||".J_more-btn";E=G.getElement(D),B=G.hasClass(F);if(E){C.push(E);A=E.getElement("a")||E;E.addEvent("click",function(H){H&&H.preventDefault();G.toggleClass(F);A.set("text",B?"更多":"收起");B=!B})}}},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},"main-filter":function(C){var B=C.split(","),A=this.hash.a;B.each(function(D){try{A[D].fireEvent("click")}catch(E){}},this)},hashFn:function(){var D={},C=location.hash.replace("#!/","").split("/"),B=0,A=C.length;while(B<A){D[C[B].toLowerCase()]=C[B+1];B+=2}Object.each(D,function(F,E){try{this[E]&&this[E].call(this,F,E)}catch(G){}},this)}};
