var QuickBox_custom=new Class({Implements:Options,options:{resizeDuration:400,resizeTransition:Fx.Transitions.Circ.easeOut,initialWidth:250,initialHeight:250,padding:10,animateCaption:true,counter:"Zdjęcie {NUM} z {TOTAL}"},initialize:function(a,b){this.setOptions(b);this.anchors=a;if(this.anchors.lenght==0)return;this.anchors.each(function(a){a.store("caption",a.get("title")||"");if(a.getParent().get("id")!="slider"){a.addEvent("click",this.open.bindWithEvent(this,a))}},this);this.overlay=(new Element("div",{id:"qbOverlay",events:{click:this.close.bindWithEvent(this)}})).inject(document.body,"top");this.quickBox=(new Element("div",{id:"qbBox",styles:{width:this.options.initialWidth,height:this.options.initialHeight,marginLeft:-(this.options.initialWidth/2),position:"absolute"}})).inject(document.body,"top");this.prevLink=(new Element("a",{id:"qbPrev",href:"#"})).inject(this.quickBox);this.nextLink=this.prevLink.clone().setProperty("id","qbNext").injectInside(this.quickBox);this.stage=(new Element("div",{id:"qbStage"})).inject(this.quickBox);this.prevLink.addEvent("click",this.changeImage.bindWithEvent(this,-1));this.nextLink.addEvent("click",this.changeImage.bindWithEvent(this,1));this.bottom=(new Element("div",{id:"qbBottom"})).inject(this.quickBox);this.closeButton=(new Element("div",{id:"qbClose",events:{click:this.close.bindWithEvent(this)}})).inject(this.bottom);this.caption=(new Element("div",{id:"qbCaption"})).inject(this.bottom);this.counter=(new Element("div",{id:"qbCounter"})).inject(this.bottom);var c=this.nextEffect.bind(this);this.fx={overlay:new Fx.Tween(this.overlay,{property:"opacity"}),resize:new Fx.Morph(this.quickBox,{duration:this.options.resizeDuration,transition:this.options.resizeTransition,onComplete:c}),show:new Fx.Tween(this.stage,{property:"opacity",onComplete:c}),bottom:new Fx.Tween(this.bottom,{property:"top",duration:200,onComplete:c})};this.active=false;document.addEvent("keydown",this.keyboardListener.bindWithEvent(this))},open:function(a,b){this.active=true;var c=window.getSize();var d=window.getScroll();var e=window.getScrollSize();var f=Math.round(c.y<768?c.y/36:c.y/10);var g=d.y+f;this.overlay.setStyles({opacity:0,display:"block",width:e.x,height:e.y});this.quickBox.setStyles({display:"block",top:g});this.fx.overlay.start(.8);this.startLoad(b);return false},startLoad:function(a,b){if(!a)return;var c=new Asset.image(a.get("href"),{onload:function(){if(!b&&this.currentLink==a)this.nextEffect()}.bind(this)});if(!b){this.stage.addClass("loading");this.stage.setStyle("display","block");this.stage.empty();this.bottom.setStyle("opacity",0);this.prevLink.setStyle("display","none");this.nextLink.setStyle("display","none");this.currentLink=a;this.currentCaption=a.retrieve("caption");this.currentImage=c;this.currentIndex=this.anchors.indexOf(a);this.step=1}},keyboardListener:function(a){if(!this.active)return;if(a.key!="f5")a.preventDefault();switch(a.key){case"esc":this.close();break;case"left":this.changeImage(a,-1);break;case"right":this.changeImage(a,1)}},mouseWheelListener:function(a){if(!this.active)return;if(a.wheel>0)this.changeImage(a,-1);if(a.wheel<0)this.changeImage(a,1)},changeImage:function(a,b){a.preventDefault();var c=this.currentIndex+b;if(c>this.anchors.length-1)c=0;if(c<0)c=this.anchors.length-1;var d=this.anchors[c];if(!d)return false;for(var e in this.fx)this.fx[e].cancel();this.startLoad(d)},nextEffect:function(){switch(this.step++){case 1:var a=this.currentImage.width+this.options.padding*2;var b=this.currentImage.height+this.options.padding*2;this.prevLink.setStyle("height",b);this.nextLink.setStyle("height",b);this.fx.resize.start({width:a,height:b,marginLeft:-(this.currentImage.width/2)});break;case 2:this.stage.removeClass("loading");this.stage.setStyle("opacity",0);this.currentImage.setStyle("margin",this.options.padding);this.currentImage.inject(this.stage);this.fx.show.start(1);break;case 3:this.prevLink.setStyle("display","block");this.nextLink.setStyle("display","block");if(this.options.animateCaption){if(this.options.counter){var c=this.anchors.length;var d=this.currentIndex+1;var e=this.options.counter;e=e.replace(/\{NUM\}/,d);e=e.replace(/\{TOTAL\}/,c);this.counter.set("text",e)}this.caption.set("text",this.currentCaption);var f=this.bottom.getStyle("height").toInt();this.bottom.setStyles({opacity:1,top:-f});this.fx.bottom.start(0)}break;case 4:this.startLoad(this.anchors[this.currentIndex-1],true);this.startLoad(this.anchors[this.currentIndex+1],true);break}},close:function(){this.quickBox.setStyle("display","none");this.overlay.fade("out");this.active=false}});var QuickBox_custom_single=new Class({Implements:Options,options:{resizeDuration:400,resizeTransition:Fx.Transitions.Circ.easeOut,initialWidth:250,initialHeight:250,padding:10,animateCaption:true,counter:"Zdjęcie {NUM} z {TOTAL}"},initialize:function(a,b){this.setOptions(b);this.anchors=a;if(this.anchors.lenght==0)return;this.anchors.each(function(a){a.store("caption",a.get("title")||"");if(a.getParent().get("id")!="slider"){a.addEvent("click",this.open.bindWithEvent(this,a))}},this);this.overlay=(new Element("div",{id:"qbOverlay",events:{click:this.close.bindWithEvent(this)}})).inject(document.body,"top");this.quickBox=(new Element("div",{id:"qbBox",styles:{width:this.options.initialWidth,height:this.options.initialHeight,marginLeft:-(this.options.initialWidth/2),position:"absolute"}})).inject(document.body,"top");this.stage=(new Element("div",{id:"qbStage"})).inject(this.quickBox);this.bottom=(new Element("div",{id:"qbBottom"})).inject(this.quickBox);this.closeButton=(new Element("div",{id:"qbClose",events:{click:this.close.bindWithEvent(this)}})).inject(this.bottom);this.caption=(new Element("div",{id:"qbCaption"})).inject(this.bottom);this.counter=(new Element("div",{id:"qbCounter"})).inject(this.bottom);var c=this.nextEffect.bind(this);this.fx={overlay:new Fx.Tween(this.overlay,{property:"opacity"}),resize:new Fx.Morph(this.quickBox,{duration:this.options.resizeDuration,transition:this.options.resizeTransition,onComplete:c}),show:new Fx.Tween(this.stage,{property:"opacity",onComplete:c}),bottom:new Fx.Tween(this.bottom,{property:"top",duration:200,onComplete:c})};this.active=false;document.addEvent("keydown",this.keyboardListener.bindWithEvent(this))},open:function(a,b){this.active=true;var c=window.getSize();var d=window.getScroll();var e=window.getScrollSize();var f=Math.round(c.y<768?c.y/36:c.y/10);var g=d.y+f;this.overlay.setStyles({opacity:0,display:"block",width:e.x,height:e.y});this.quickBox.setStyles({display:"block",top:g});this.fx.overlay.start(.8);this.startLoad(b);return false},startLoad:function(a,b){if(!a)return;var c=new Asset.image(a.get("href"),{onload:function(){if(!b&&this.currentLink==a)this.nextEffect()}.bind(this)});if(!b){this.stage.addClass("loading");this.stage.setStyle("display","block");this.stage.empty();this.bottom.setStyle("opacity",0);this.currentLink=a;this.currentCaption=a.retrieve("caption");this.currentImage=c;this.currentIndex=this.anchors.indexOf(a);this.step=1}},keyboardListener:function(a){if(!this.active)return;if(a.key!="f5")a.preventDefault();switch(a.key){case"esc":this.close();break;case"left":this.changeImage(a,-1);break;case"right":this.changeImage(a,1)}},mouseWheelListener:function(a){if(!this.active)return;if(a.wheel>0)this.changeImage(a,-1);if(a.wheel<0)this.changeImage(a,1)},changeImage:function(a,b){a.preventDefault();var c=this.currentIndex+b;if(c>this.anchors.length-1)c=0;if(c<0)c=this.anchors.length-1;var d=this.anchors[c];if(!d)return false;for(var e in this.fx)this.fx[e].cancel();this.startLoad(d)},nextEffect:function(){switch(this.step++){case 1:var a=this.currentImage.width+this.options.padding*2;var b=this.currentImage.height+this.options.padding*2;this.fx.resize.start({width:a,height:b,marginLeft:-(this.currentImage.width/2)});break;case 2:this.stage.removeClass("loading");this.stage.setStyle("opacity",0);this.currentImage.setStyle("margin",this.options.padding);this.currentImage.inject(this.stage);this.fx.show.start(1);break;case 3:if(this.options.animateCaption){this.caption.set("text",this.currentCaption);var c=this.bottom.getStyle("height").toInt();this.bottom.setStyles({opacity:1,top:-c});this.fx.bottom.start(0)}break;case 4:this.startLoad(this.anchors[this.currentIndex-1],true);this.startLoad(this.anchors[this.currentIndex+1],true);break}},close:function(){this.quickBox.setStyle("display","none");this.overlay.fade("out");this.active=false}});window.addEvent("domready",function(){if(document.getElementById("tripPhotoBox")){var a=$$(".lightboxStep4");if(a.length>0){new QuickBox_custom(a)}}});window.addEvent("domready",function(){if(document.getElementById("GalleryStep4")){var a=$$(".lightboxStep4G");if(a.length>0){new QuickBox_custom(a)}}});window.addEvent("domready",function(){if(document.getElementById("wyniki")){var a=$$(".lightbox-s3");if(a.length>0){new QuickBox_custom_single(a)}}})
