var Slimbox;
(function(){
var _1=0,_2,_3,_4,_5,_6,_7,fx,_9,_a=new Image(),_b=new Image(),_c,_d,_e,_f,_10,_11,_12,_13,_14,_15,_16,_17;
window.addEvent("domready",function(){
$(document.body).adopt($$([_c=new Element("div",{id:"lbOverlay"}).addEvent("click",close),_d=new Element("div",{id:"lbCenter"}),_12=new Element("div",{id:"lbBottomContainer"})]).setStyle("display","none"));
_e=new Element("div",{id:"lbImage"}).injectInside(_d).adopt(_10=new Element("a",{id:"lbPrevLink",href:"#"}).addEvent("click",previous),_11=new Element("a",{id:"lbNextLink",href:"#"}).addEvent("click",next));
_f=new Element("iframe",{id:"lbImage"}).addEvent("load",nextEffect).injectInside(_e);
_13=new Element("div",{id:"lbBottom"}).injectInside(_12).adopt(new Element("a",{id:"lbCloseLink",href:"#"}).addEvent("click",close),_16=new Element("a",{id:"lbPrintLink",href:"#"}).addEvent("click",print),_17=new Element("a",{id:"lbSaveLink",href:"#"}).addEvent("click",save),_14=new Element("div",{id:"lbCaption"}),_15=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}));
fx={overlay:new Fx.Tween(_c,{property:"opacity",duration:500}).set(0),image:new Fx.Tween(_e,{property:"opacity",duration:500,onComplete:nextEffect}),bottom:new Fx.Tween(_13,{property:"margin-top",duration:400})};
});
Slimbox={open:function(_18,_19,_1a){
_2=$extend({loop:false,overlayOpacity:0.8,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,psScriptPath:"",enablePrintButton:0,enableSaveButton:0,animateCaption:true,showCounter:true,counterText:"Item {x} of {y}",defaultIframeWidth:850,defaultIframeHeight:500},_1a||{});
if(typeof _18=="string"){
_18=[[_18,_19]];
_19=0;
}
_3=_18;
_2.loop=_2.loop&&(_3.length>1);
position();
setup(true);
_7=window.getScrollTop()+(window.getHeight()/15);
fx.resize=new Fx.Morph(_d,$extend({duration:_2.resizeDuration,onComplete:nextEffect},_2.resizeTransition?{transition:_2.resizeTransition}:{}));
_d.setStyles({top:_7,width:_2.initialWidth,height:_2.initialHeight,marginLeft:-(_2.initialWidth/2),display:""});
fx.overlay.start(_2.overlayOpacity);
_1=1;
return changeImage(_19);
}};
Element.implement({slimbox:function(_1b,_1c){
$$(this).slimbox(_1b,_1c);
return this;
}});
Elements.implement({slimbox:function(_1d,_1e,_1f){
_1e=_1e||function(el){
return [el.href,el.title,el.rev];
};
_1f=_1f||function(){
return true;
};
var _21=this;
_21.removeEvents("click").addEvent("click",function(){
var _22=_21.filter(_1f,this);
return Slimbox.open(_22.map(_1e),_22.indexOf(this),_1d);
});
return _21;
}});
function position(){
_c.setStyles({top:window.getScrollTop(),height:window.getHeight()});
};
function setup(_23){
["object",window.ie?"select":"embed"].forEach(function(tag){
Array.forEach(document.getElementsByTagName(tag),function(el){
if(_23){
el._slimbox=el.style.visibility;
}
el.style.visibility=_23?"hidden":el._slimbox;
});
});
_c.style.display=_23?"":"none";
var fn=_23?"addEvent":"removeEvent";
window[fn]("scroll",position)[fn]("resize",position);
document[fn]("keydown",keyDown);
};
function keyDown(_27){
switch(_27.code){
case 27:
case 88:
case 67:
close();
break;
case 37:
case 80:
previous();
break;
case 39:
case 78:
next();
}
return false;
};
function previous(){
return changeImage(_5);
};
function next(){
return changeImage(_6);
};
function changeImage(_28){
if((_1==1)&&(_28>=0)){
_1=2;
_4=_28;
_5=((_4||!_2.loop)?_4:_3.length)-1;
_6=_4+1;
if(_6==_3.length){
_6=_2.loop?0:-1;
}
$$(_10,_11,_e,_f,_12).setStyle("display","none");
fx.bottom.cancel().set(0);
fx.image.set(0);
_d.className="lbLoading";
var url=_3[_4][0];
var _2a=/\.(jpe?g|png|gif|bmp)/i;
if(url.match(_2a)){
$$(_16,_17).setStyle("display","");
_9=new Image();
_9.datatype="image";
_9.onload=nextEffect;
_9.src=url;
}else{
$$(_16,_17).setStyle("display","none");
_9=new Object();
_9.datatype="iframe";
rev=_3[_4][2];
_9.w=matchOrDefault(rev,new RegExp("width=(\\d+)","i"),_2.defaultIframeWidth);
_9.h=matchOrDefault(rev,new RegExp("height=(\\d+)","i"),_2.defaultIframeHeight);
_f.setProperties({id:"lbFrame_"+new Date().getTime(),width:_9.w,height:_9.h,scrolling:"yes",frameBorder:0,src:url});
}
}
return false;
};
function nextEffect(){
switch(_1++){
case 2:
_d.className="";
if(_9.datatype=="image"){
_e.setStyles({backgroundImage:"url("+_9.src+")",display:""});
$$(_e,_13).setStyle("width",_9.width);
$$(_e,_10,_11).setStyle("height",_9.height);
$$(_10,_11).setStyle("width","50%");
}else{
_e.setStyles({backgroundImage:"",display:""});
$$(_e,_13).setStyle("width",_9.w);
$$(_e).setStyle("height",_9.h);
$$(_10,_11).setStyle("height","35px");
$$(_10,_11).setStyle("width","65px");
_f.setStyles({display:""});
}
_14.set("html",_3[_4][1]||"");
_15.set("html",(_2.showCounter&&(_3.length>1))?_2.counterText.replace(/{x}/,_4+1).replace(/{y}/,_3.length):"");
if(_5>=0){
_a.src=_3[_5][0];
}
if(_6>=0){
_b.src=_3[_6][0];
}
if(_d.clientHeight!=_e.offsetHeight){
fx.resize.start({height:_e.offsetHeight});
break;
}
_1++;
case 3:
if(_d.clientWidth!=_e.offsetWidth){
fx.resize.start({width:_e.offsetWidth,marginLeft:-_e.offsetWidth/2});
break;
}
_1++;
case 4:
_12.setStyles({top:_7+_d.clientHeight,marginLeft:_d.style.marginLeft,visibility:"hidden",display:""});
fx.image.start(1);
break;
case 5:
if(_5>=0){
_10.style.display="";
}
if(_6>=0){
_11.style.display="";
}
if(_2.animateCaption){
fx.bottom.set(-_13.offsetHeight).start(0);
}
_12.style.visibility="";
_1=1;
}
};
function close(){
if(_1){
_1=0;
_9.onload=$empty;
for(var f in fx){
fx[f].cancel();
}
$$(_d,_12).setStyle("display","none");
fx.overlay.chain(setup).start(0);
}
return false;
};
function matchOrDefault(str,re,val){
var _2f=str.match(re);
return _2f?_2f[1]:val;
};
function print(){
return printOrSave("print");
};
function save(){
return printOrSave("save");
};
function printOrSave(_30){
if(_2.psScriptPath){
var _31=window.open(_2.psScriptPath+"?mode="+_30+"&image="+_3[_4][0],"printsave","left=0,top=0,width="+(parseInt(_e.style.width))+",height="+(parseInt(_e.style.height))+",toolbar=0,resizable=1");
return false;
}
return true;
};
})();


