var Slimbox=(function(){var p=window,J=Browser.Engine.trident4,d,i,k=-1,v,q,r,z,w,e,g,m={},K=new Image(),L=new Image(),n,f,s,u,x,y,o,A,M,B,C,l,t,D;p.addEvent("domready",function(){$(document.body).adopt($$(n=new Element("div",{id:"lbOverlay",events:{click:E}}),f=new Element("div",{id:"lbCenter"}),o=new Element("div",{id:"lbBottomContainer"})).setStyle("display","none"));s=new Element("div",{id:"lbImage"}).injectInside(f).adopt(u=new Element("div",{styles:{position:"relative"}}).adopt(x=new Element("a",{id:"lbPrevLink",href:"#",events:{click:N}}),y=new Element("a",{id:"lbNextLink",href:"#",events:{click:O}})));A=new Element("div",{id:"lbBottom"}).injectInside(o).adopt(new Element("a",{id:"lbCloseLink",href:"#",events:{click:E}}),M=new Element("div",{id:"lbCaption"}),B=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}))});function F(){var a=p.getScroll(),b=p.getSize();$$(f,o).setStyle("left",a.x+(b.x/2));if(z)n.setStyles({left:a.x,top:a.y,width:b.x,height:b.y})}function P(c){["object",J?"select":"embed"].forEach(function(b){Array.forEach(document.getElementsByTagName(b),function(a){if(c)a._0=a.style.visibility;a.style.visibility=c?"hidden":a._0})});n.style.display=c?"":"none";var h=c?"addEvent":"removeEvent";p[h]("scroll",F)[h]("resize",F);document[h]("keydown",Q)}function Q(a){var b=a.code;return d.closeKeys.contains(b)?E():d.nextKeys.contains(b)?O():d.previousKeys.contains(b)?N():false}function N(){return G(q)}function O(){return G(r)}function G(a){if(a>=0){k=a;v=i[a][0];q=(k||(d.loop?i.length:0))-1;r=((k+1)%i.length)||(d.loop?0:-1);H();f.className="lbLoading";m=new Image();m.onload=R;m.src=v}return false}function R(){f.className="";t.set(0);s.setStyles({backgroundImage:"url("+v+")",display:""});u.setStyle("width",m.width);$$(u,x,y).setStyle("height",m.height);M.set("html",i[k][1]||"");B.set("html",(((i.length>1)&&d.counterText)||"").replace(/{x}/,k+1).replace(/{y}/,i.length));if(q>=0)K.src=i[q][0];if(r>=0)L.src=i[r][0];e=s.offsetWidth;g=s.offsetHeight;var a=Math.max(0,w-(g/2)),b=0,c;if(f.offsetHeight!=g){b=l.start({height:g,top:a})}if(f.offsetWidth!=e){b=l.start({width:e,marginLeft:-e/2})}c=function(){o.setStyles({width:e,top:a+g,marginLeft:-e/2,visibility:"hidden",display:""});t.start(1)};if(b){l.chain(c)}else{c()}}function S(){if(q>=0)x.style.display="";if(r>=0)y.style.display="";D.set(-A.offsetHeight).start(0);o.style.visibility=""}function H(){f.getChildren('object').destroy();m.onload=$empty;m.src=K.src=L.src=v;l.cancel();t.cancel();D.cancel();$$(x,y,s,o).setStyle("display","none")}function E(){if(k>=0){H();k=q=r=-1;f.style.display="none";C.cancel().chain(P).start(0)}return false}function T(b,c){[data,flashVars]=b.split('?');params=flashVars.parseQueryString();H();f.className="";B.empty();t.set(0);k=1;u.setStyle("width",c.width);u.setStyle("height",c.height);e=c.width+20;g=c.height+20;var h=Math.max(0,w-(g/2)),j=0,I;if(f.offsetHeight!=g){j=l.start({height:g,top:h})}if(f.offsetWidth!=e){j=l.start({width:e,marginLeft:-e/2})}I=function(){o.setStyles({width:e,top:h+g,marginLeft:-e/2,visibility:"hidden",display:""});t.start(1);var a=new Swiff(data,{width:c.width,height:c.height,vars:params,params:{allowFullscreen:true}});a.inject(f)};if(j){l.chain(I)}else{I()}}Element.implement({slimbox:function(a,b){$$(this).slimbox(a,b);return this}});Elements.implement({slimbox:function(b,c,h){c=c||function(a){return[a.href,a.title]};h=h||function(){return true};var j=this;j.removeEvents("click").addEvent("click",function(){var a=j.filter(h,this);return Slimbox.open(a.map(c),a.indexOf(this),b)});return j}});return{open:function(a,b,c,h){d=$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]},c||{});if(h){var j=a}C=new Fx.Tween(n,{property:"opacity",duration:d.overlayFadeDuration});l=new Fx.Morph(f,$extend({duration:d.resizeDuration,link:"chain"},d.resizeTransition?{transition:d.resizeTransition}:{}));t=new Fx.Tween(s,{property:"opacity",duration:d.imageFadeDuration,onComplete:S});D=new Fx.Tween(A,{property:"margin-top",duration:d.captionAnimationDuration});if(typeof a=="string"){a=[[a,b]];b=0}w=p.getScrollTop()+(p.getHeight()/2);e=d.initialWidth;g=d.initialHeight;f.setStyles({top:Math.max(0,w-(g/2)),width:e,height:g,marginLeft:-e/2,display:""});z=J||(n.currentStyle&&(n.currentStyle.position!="fixed"));if(z)n.style.position="absolute";C.set(0).start(d.overlayOpacity);F();P(1);i=a;d.loop=d.loop&&(i.length>1);if(h){return T(j,{width:c.videoWidth,height:c.videoHeight})}return G(b)}}})();


// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
Slimbox.scanPage = function() {
	$$("a").filter(function(el) {
		return el.rel && el.rel.test(/^lightbox/i);
	}).slimbox({counterText: '<span>{x}</span> / {y}'}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
};
if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
	window.addEvent("domready", Slimbox.scanPage);
}

// video layer
myLightWindow = function() {}
myLightWindow.activateWindow = function(arg) {
	Slimbox.open(arg.href, '', {
		videoWidth: arg.width,
		videoHeight: arg.height
	}, true);
}
