/* Copyright (C) 2007 - 2011 YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

var Slimbox=function(){function g(){var a=n.getScroll(),b=n.getSize();$$(e,o).setStyle("left",a.x+b.x/2);F&&k.setStyles({left:a.x,top:a.y,width:b.x,height:b.y})}function G(a){["object",H?"select":"embed"].forEach(function(d){Array.forEach(document.getElementsByTagName(d),function(i){if(a)i._slimbox=i.style.visibility;i.style.visibility=a?"hidden":i._slimbox})});k.style.display=a?"":"none";var b=a?"addEvent":"removeEvent";n[b]("scroll",g)[b]("resize",g);document[b]("keydown",P)}function P(a){a=a.code;
return c.closeKeys.contains(a)?y():c.nextKeys.contains(a)?I():c.previousKeys.contains(a)?J():false}function J(){return z(p)}function I(){return z(q)}function z(a){if(a>=0){l=a;u=f[a][0];p=(l||(c.loop?f.length:0))-1;q=(l+1)%f.length||(c.loop?0:-1);K();e.className="lbLoading";m=new Image;m.onload=Q;m.src=u}return false}function Q(){e.className="";v.set(0);r.setStyles({backgroundImage:"url("+u+")",display:""});A.setStyle("width",m.width);$$(A,w,x).setStyle("height",m.height);L.set("html",f[l][1]||"");
M.set("html",(f.length>1&&c.counterText||"").replace(/{x}/,l+1).replace(/{y}/,f.length));if(p>=0)N.src=f[p][0];if(q>=0)O.src=f[q][0];h=r.offsetWidth;j=r.offsetHeight;var a=Math.max(0,B-j/2),b=0,d;if(e.offsetHeight!=j)b=s.start({height:j,top:a});if(e.offsetWidth!=h)b=s.start({width:h,marginLeft:-h/2});d=function(){o.setStyles({width:h,top:a+j,marginLeft:-h/2,visibility:"hidden",display:""});v.start(1)};b?s.chain(d):d()}function R(){if(p>=0)w.style.display="";if(q>=0)x.style.display="";C.set(-D.offsetHeight).start(0);
o.style.visibility=""}function K(){m.onload=$empty;m.src=N.src=O.src=u;s.cancel();v.cancel();C.cancel();$$(w,x,r,o).setStyle("display","none")}function y(){if(l>=0){K();l=p=q=-1;e.style.display="none";E.cancel().chain(G).start(0)}return false}var n=window,H=Browser.Engine.trident4,c,f,l=-1,u,p,q,F,B,h,j,m={},N=new Image,O=new Image,k,e,r,A,w,x,o,D,L,M,E,s,v,C;n.addEvent("domready",function(){$(document.body).adopt($$(k=new Element("div",{id:"lbOverlay",events:{click:y}}),e=new Element("div",{id:"lbCenter"}),
o=new Element("div",{id:"lbBottomContainer"})).setStyle("display","none"));r=(new Element("div",{id:"lbImage"})).injectInside(e).adopt(A=(new Element("div",{styles:{position:"relative"}})).adopt(w=new Element("a",{id:"lbPrevLink",href:"#",events:{click:J}}),x=new Element("a",{id:"lbNextLink",href:"#",events:{click:I}})));D=(new Element("div",{id:"lbBottom"})).injectInside(o).adopt(new Element("a",{id:"lbCloseLink",href:"#",events:{click:y}}),L=new Element("div",{id:"lbCaption"}),M=new Element("div",
{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}))});Element.implement({slimbox:function(a,b){$$(this).slimbox(a,b);return this}});Elements.implement({slimbox:function(a,b,d){b=b||function(t){return[t.href,t.title]};d=d||function(){return true};var i=this;i.removeEvents("click").addEvent("click",function(){var t=i.filter(d,this);return Slimbox.open(t.map(b),t.indexOf(this),a)});return i}});return{open:function(a,b,d){c=$extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,
resizeTransition:false,initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},d||{});E=new Fx.Tween(k,{property:"opacity",duration:c.overlayFadeDuration});s=new Fx.Morph(e,$extend({duration:c.resizeDuration,link:"chain"},c.resizeTransition?{transition:c.resizeTransition}:{}));v=new Fx.Tween(r,{property:"opacity",duration:c.imageFadeDuration,onComplete:R});C=new Fx.Tween(D,{property:"margin-top",
duration:c.captionAnimationDuration});if(typeof a=="string"){a=[[a,b]];b=0}B=n.getScrollTop()+n.getHeight()/2;h=c.initialWidth;j=c.initialHeight;e.setStyles({top:Math.max(0,B-j/2),width:h,height:j,marginLeft:-h/2,display:""});if(F=H||k.currentStyle&&k.currentStyle.position!="fixed")k.style.position="absolute";E.set(0).start(c.overlayOpacity);g();G(1);f=a;c.loop=c.loop&&f.length>1;return z(b)}}}();
Slimbox.scanPage=function(){$$("a").filter(function(g){return g.rel&&g.rel.test(/^lightbox/i)}).slimbox({},null,function(g){return this==g||this.rel.length>8&&this.rel==g.rel})};/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)||window.addEvent("domready",Slimbox.scanPage);

