ShowImgs=function(a){this.Bel=a.BID;this.Sel=a.SID;this.BID=a.BID+"_img_asdakjjhaflreiq893214us";this.SCLASS=a.SCLASS;this.BCLASS=a.BCLASS;this.titleEl=(a.titleEl)?Ext.get(a.titleEl):null;this.introEl=(a.introEl)?Ext.get(a.introEl):null;this.bclick=(a.bclick)?a.bclick:null;this.BW=a.BW;this.BH=a.BH;this.dh=Ext.DomHelper;this.currentImgIndex=0;this.load(a.imgsArr);ShowImgs.superclass.constructor.call(this,{})};Ext.extend(ShowImgs,Ext.util.Observable,{load:function(imgsArr){var owner=this;if(Ext.isString(imgsArr)){imgsArr=eval(imgsArr)}if(!Ext.isArray(imgsArr)){imgsArr=[imgsArr]}if(imgsArr.length<=0){return}this.imgsArr=imgsArr;this.dh.append(this.Bel,{tag:"img",id:"currentBigImg_ShowImgs",cls:"nextPage",style:"margin:0 auto;cursor:pointer;width:"+this.BW+"px;height:"+this.BH+"px"});this.currentBigImg_ShowImgs=Ext.get("currentBigImg_ShowImgs");if(owner.bclick=="next"){this.currentBigImg_ShowImgs.on("mousemove",function(e){if(e.getPageX()>(this.getX()+this.getWidth()*0.5)){this.setStyle({cursor:"url('/common/images/arr_right.cur'),pointer"})}else{this.setStyle({cursor:"url('/common/images/arr_left.cur'),pointer"})}})}this.currentBigImg_ShowImgs.on("click",function(e){if(owner.bclick=="next"){if(e.getPageX()>(this.getX()+this.getWidth()*0.5)){owner.currentImgIndex+=1}else{owner.currentImgIndex-=1;if(owner.currentImgIndex<0){owner.currentImgIndex=(owner.imgsArr.length-1)}}if(owner.currentImgIndex>=owner.imgsArr.length){owner.currentImgIndex=0}owner.simgClick({target:"currentSigImg_ShowImgs_"+owner.currentImgIndex})}else{owner.showBG();owner.loadImg(owner.currentImgIndex)}});this.currentBigImg_ShowImgs.on("dblclick",function(){owner.showBG();owner.loadImg(owner.currentImgIndex)});this.currentBigImg_ShowImgs.on("load",function(){document.getElementById("currentBigImg_ShowImgs").style.width="auto";document.getElementById("currentBigImg_ShowImgs").style.height="auto";this.set({w:this.getWidth(),h:this.getHeight(),rad:this.getHeight()/this.getWidth()});owner.resizeImg(this,{width:owner.BW,height:owner.BH})});var cns=[];for(var i=0;i<this.imgsArr.length;i++){if(isNaN(this.imgsArr[i].id)){this.imgsArr[i].imgURL=this.imgsArr[i].id}else{this.imgsArr[i].imgURL="/img.asp?sid="+this.imgsArr[i].id}cns.push({tag:"img",style:"cursor:pointer;",id:"currentSigImg_ShowImgs_"+i,src:this.imgsArr[i].imgURL})}this.dh.append(this.Sel,{tag:"div",cn:cns});for(var i=0;i<this.imgsArr.length;i++){var simg=Ext.get("currentSigImg_ShowImgs_"+i);simg.on("load",function(){if(owner.SCLASS){this.addClass(owner.SCLASS)}if(this.id=="currentSigImg_ShowImgs_0"){owner.simgClick({target:"currentSigImg_ShowImgs_0"})}});simg.on("click",owner.simgClick,owner)}},simgClick:function(b){var a=Ext.get(b.target);this.currentImgIndex=new Number(a.getAttribute("id").replace("currentSigImg_ShowImgs_",""));if(a.getAttribute("src").indexOf("/SIMG_")>0){this.currentBigImg_ShowImgs.set({src:"/img.asp?id="+a.getAttribute("src").split("/SIMG_")[1].split(".")[0]})}else{this.currentBigImg_ShowImgs.set({src:a.getAttribute("src").replace("?sid=","?id=")})}if(this.titleEl){this.titleEl.dom.innerHTML=this.imgsArr[this.currentImgIndex].title}if(this.introEl){this.introEl.dom.innerHTML=this.imgsArr[this.currentImgIndex].intro.replace(/\r\n/gi,"<br />")}},loadImg:function(b){var a=this;if(!Ext.fly("showDivContent_showDivLoadInfo")){this.dh.append(Ext.getBody(),{tag:"div",html:"请稍等,正在载入数据",id:"showDivContent_showDivLoadInfo"})}Ext.fly("showDivContent_showDivLoadInfo").setStyle({display:"block",backgroundColor:"#fff",padding:"15px",border:"#036 solid 5px",position:"absolute",left:((Ext.getBody().getWidth()-100)/2)+"px",top:(document.documentElement.scrollTop+(document.documentElement.clientHeight-50)*0.5)+"px",zIndex:5000});if(!this.showDivContent){this.dh.append(Ext.getBody(),{tag:"img",title:"点击旁边的灰色背景或者双击图片:关闭",src:this.imgsArr[b].imgURL.replace("/SIMG_","/BIMG_").replace("?sid=","?id="),id:"showDivContent_showImgs"});this.showDivContent=Ext.get("showDivContent_showImgs");this.showDivContent.on("load",function(){Ext.fly("showDivContent_showDivLoadInfo").dom.style.display="none";document.getElementById("showDivContent_showImgs").style.width="auto";document.getElementById("showDivContent_showImgs").style.height="auto";this.set({w:this.getWidth(),h:this.getHeight(),rad:this.getHeight()/this.getWidth()});a.resizeImg(this,{width:document.documentElement.clientWidth*0.8,height:document.documentElement.clientHeight*0.95});this.setStyle({cursor:"pointer",backgroundColor:"#fff",padding:"15px",position:"absolute",left:((Ext.getBody().getWidth()-this.getWidth())/2)+"px",top:(document.documentElement.scrollTop+(document.documentElement.clientHeight-this.getHeight())*0.5)+"px",zIndex:5000});this.dom.style.visibility="visible"});this.showDivContent.on("click",function(){if(this.imgsArr.length==1){this.closeImgShow()}else{var c=this.showDivContent.getAttribute("nid");if(c==0){this.closeImgShow()}else{this.loadImg(c)}}},this);this.showDivContent.on("dblclick",function(){this.closeImgShow()},this)}else{this.showDivContent.dom.style.visibility="hidden";this.showDivContent.dom.style.display="block";this.showDivContent.set({src:this.imgsArr[b].imgURL.replace("/SIMG_","/BIMG_").replace("?sid=","?id=")})}b++;if(b>=this.imgsArr.length){b=0}this.showDivContent.set({nid:b})},resizeImg:function(c,d){var a=c.getAttribute("rad");var b=d.height/d.width;if(b>a){if(c.getAttribute("w")<=d.width){d.width=c.getAttribute("w")}c.setWidth(d.width);c.setHeight(d.width*a)}else{if(c.getAttribute("h")<=d.height){d.height=c.getAttribute("h")}c.setHeight(d.height);c.setWidth(d.height/a)}},showBG:function(){if(!this.showDivMask){this.dh.append(Ext.getBody(),{tag:"div",id:"showDivMask_showImgs"});this.showDivMask=Ext.get("showDivMask_showImgs");this.showDivMask.setOpacity(0.6);this.showDivMask.setStyle({display:"none",backgroundColor:"#000",position:"absolute",left:0,top:0,zIndex:5000});this.showDivMask.on("click",function(){this.closeImgShow()},this)}this.showDivMask.show();this.showDivMask.setStyle({width:"100%",height:document.documentElement.scrollHeight+"px"})},closeImgShow:function(){Ext.fly("showDivContent_showDivLoadInfo").dom.style.display="none";this.showDivMask.dom.style.display="none";this.showDivContent.dom.style.display="none"}});
