Code:
var Fasteditbox;(function(){var y,f,M,F,L,l,D,j,k,i,H,w,r,x=new Image(),R=new Image(),p=false,u=false,P,b,h,c,Q,C,J,S,B,N,E,v,z,m,g="none",e,d="fasteditBox",A;window.addEvent("domready",function(){$(document.body).adopt($$([P=new Element("div",{id:"feOverlay"}).addEvent("click",K),b=new Element("div",{id:"feCenter"})]).setStyle("display","none"));h=new Element("div",{id:"feImage"}).injectInside(b);c=new Element("div",{id:"feBottom"}).injectInside(b).adopt(new Element("a",{id:"feCloseLink",href:"#"}).addEvent("click",K),C=new Element("div",{id:"feTitle"}),S=new Element("div",{id:"feNumber"}),J=new Element("div",{id:"feCaption"}));w={overlay:new Fx.Tween(P,{property:"opacity",duration:360}).set(0),image:new Fx.Tween(h,{property:"opacity",duration:360,onComplete:G}),bottom:new Fx.Tween(c,{property:"opacity",duration:240}).set(0)}});Fasteditbox={close:function(){K()},open:function(V,U,T){y=$extend({loop:false,stopKey:true,overlayOpacity:0.7,resizeOpening:false,resizeDuration:240,resizeTransition:false,initialWidth:320,initialHeight:180,defaultWidth:750,defaultHeight:600,showCaption:false,showCounter:false,counterText:"({x} of {y})"},T||{});if((Browser.Engine.gecko)&&(Browser.Engine.version<19)){p=true;y.overlayOpacity=1;P.className="feOverlayFF"}if(typeof V=="string"){V=[[V,U,T]];U=0}f=V;y.loop=y.loop&&(f.length>1);if((Browser.Engine.trident)&&(Browser.Engine.version<5)){u=true;P.className="feOverlayIE";P.setStyle("position","absolute");I()}o();q(true);l=window.getScrollTop()+(window.getHeight()/2);j=window.getScrollLeft()+(window.getWidth()/2);w.resize=new Fx.Morph(b,$extend({duration:y.resizeDuration,onComplete:O},y.resizeTransition?{transition:y.resizeTransition}:{}));b.setStyles({top:l,left:j,width:y.initialWidth,height:y.initialHeight,marginTop:-(y.initialHeight/2),marginLeft:-(y.initialWidth/2),display:""});w.overlay.start(y.overlayOpacity);return a(U)}};Element.implement({fasteditbox:function(T,U){$$(this).fasteditbox(T,U);return this}});Elements.implement({fasteditbox:function(T,W,V){W=W||function(X){v=X.rel.split(/[\[\]]/);v=v[1];return[X.href,X.title,v]};V=V||function(){return true};var U=this;U.removeEvents("click").addEvent("click",function(){var Y=U.filter(V,this);var Z=[];var X=[];Y.each(function(ab,aa){if(X.indexOf(ab.toString())<0){Z.include(Y[aa]);X.include(Y[aa].toString())}});return Fasteditbox.open(Z.map(W),X.indexOf(this.toString()),T)});return U}});function I(){P.setStyles({top:window.getScrollTop(),left:window.getScrollLeft()})}function o(){i=window.getWidth();H=window.getHeight();P.setStyles({width:i,height:H})}function q(T){["object",window.ie?"select":"embed"].forEach(function(V){Array.forEach(document.getElementsByTagName(V),function(W){if(T){W._fasteditbox=W.style.visibility}W.style.visibility=T?"hidden":W._fasteditbox})});P.style.display=T?"":"none";var U=T?"addEvent":"removeEvent";if(u){window[U]("scroll",I)}window[U]("resize",o);document[U]("keydown",s)}function s(T){switch(T.code){case 27:case 88:case 67:K();break;case 37:case 80:previous();break;case 39:case 78:next()}if(y.stopKey){return false}}function a(T){if(T>=0){h.set("html","");M=T;F=((M||!y.loop)?M:f.length)-1;L=M+1;if(L==f.length){L=y.loop?0:-1}t();b.className="feLoading";if(!f[T][2]){f[T][2]=""}N=f[T][2].split(" ");E=N.length;if(E>1){z=(N[E-2].match("%"))?(window.getWidth()*((N[E-2].replace("%",""))*0.01))+"px":N[E-2]+"px";m=(N[E-1].match("%"))?(window.getHeight()*((N[E-1].replace("%",""))*0.01))+"px":N[E-1]+"px"}else{z="";m=""}B=f[T][0];Q=f[M][1].split("::");g="url";z=z||y.defaultWidth;m=m||y.defaultHeight;d="mediaId_"+new Date().getTime();r=new Element("iframe",{src:B,id:d,width:z,height:m,frameborder:0,events:{load:function(){$(r.contentWindow.document.body).addClass("fastedit");if(r.get("src")!=r.contentWindow.document.location.href){document.location.reload()}}}});n()}return false}function n(){h.setStyles({backgroundImage:"none",display:""});r.inject(h);h.setStyles({width:z,height:m});C.set("html",(y.showCaption)?Q[0]:"");J.set("html",(y.showCaption&&(Q.length>1))?Q[1]:"");S.set("html",(y.showCounter&&(f.length>1))?y.counterText.replace(/{x}/,M+1).replace(/{y}/,f.length):"");if((F>=0)&&(f[F][0].match(/\.gif|\.jpg|\.png|twitpic\.com/i))){x.src=f[F][0].replace(/twitpic\.com/i,"twitpic.com/show/full")}if((L>=0)&&(f[L][0].match(/\.gif|\.jpg|\.png|twitpic\.com/i))){R.src=f[L][0].replace(/twitpic\.com/i,"twitpic.com/show/full")}z=h.offsetWidth;m=h.offsetHeight+c.offsetHeight;if(m>=l+l-10){D=-(l-10)}else{D=-(m/2)}if(z>=j+j-10){k=-(j-10)}else{k=-(z/2)}if(y.resizeOpening){w.resize.start({width:z,height:m,marginTop:D,marginLeft:k})}else{b.setStyles({width:z,height:m,marginTop:D,marginLeft:k});O()}}function O(){w.image.start(1)}function G(){b.className="";w.bottom.start(1)}function t(){if(r){r.onload=$empty}w.resize.cancel();w.image.cancel().set(0);w.bottom.cancel().set(0)}function K(){if(M>=0){window.location.reload()}return false}})();Fasteditbox.scanPage=function(){var a=$$("a").filter(function(b){return b.rel&&b.rel.test(/^fastedit/i)});$$(a).fasteditbox({},null,function(c){var b=this.rel.replace(/[[]|]/gi," ");var d=b.split(" ");return(this==c)||((this.rel.length>8)&&c.rel.match(d[1]))})};window.addEvent("domready",Fasteditbox.scanPage);