var lightgallery=(function(){var G={isOpen:false,images:[],container:null,picture:null,current:null,loaderImage:null,minPadding:15,options:{animate:true,framesNumber:20,speed:30,resizeSync:false,enableZoom:true,fadeImage:true,alias:'lightgallery'},langVars:{next:'Next',prev:'Previous',zoomIn:'Zoom In',zoomOut:'Zoom Out',fullSize:'Fit Screen',fitScreen:'Fit Screen',close:'Close',image:'Image',of:'of'},setLangVars:function(vars){extend(this.langVars,vars);},init:function(options){var opt=this.options;extend(opt,options);var imgs=document.getElementsByTagName('a'),rel,r;for(var i=0,len=imgs.length;i<len;i++){if(rel=imgs[i].rel){if(r=rel.match(new RegExp('^'+opt.alias+'\\[([a-zA-Z]+)\\]|'+opt.alias+'$'))){addEvent(imgs[i],'click',this.showImage);if(r[1]){imgs[i].__gallery__=r[1];if(!this.images[r[1]])
this.images[r[1]]=[];imgs[i].__index__=this.images[r[1]].push(imgs[i])-1;}}}}
var b=document.getElementsByTagName('body')[0];b.appendChild(this.overlay=ce('div',{id:'LG_overlay'}));b.appendChild(this.container=this.createContainer());if(b.attachEvent)
addEvent(b,'keypress',keyPressHandler);else
addEvent(window,'keypress',keyPressHandler);this.loaderImage=ce('img',{src:''});this.loaderImage.onload=function(){G.hideLoadingIcon();G.loaderImage.__is_loaded__=true;G.picture.setAttribute("src",G.loaderImage.src);G.setContPos();G.preload(G.current);}
this.dy=this.container.offsetHeight;this.dx=0;},open:function(){var ar=getPageSize();css(G.overlay,{width:(G.overlayWidth=ar[0])+"px",height:(G.overlayHeight=ar[1])+"px",display:'block'});fadeIn(G.overlay,0,85,9);G.picture.style.display='block';G.setContPos();css(G.container,{visibility:'visible',display:'block'});G.isOpen=true;},close:function(){G.overlay.style.display='none';css(G.container,{visibility:'hidden',display:'none'});G.isOpen=false;var i=G.loaderImage;i.src=G.picture.src='';i.__is_loaded__=false;},createContainer:function(){var lng=G.langVars;if(G.options.enableZoom){var zoomIn=ce('div',{'class':'LG_zoomIn',title:lng.zoomIn,events:{click:G.zoomIn}});var zoomOut=ce('div',{'class':'LG_zoomOut',title:lng.zoomOut,events:{click:G.zoomOut}})}
return ce('div',{id:'LG_container'},ce('div',0,zoomIn,zoomOut,this.fullSizeBtn=ce('div',{'class':'LG_zoomNormal',title:lng.fullSize,events:{click:G.zoomNormal}}),this.imgIndex=ce('div',{'class':'LG_imgIndex'}),ce('div',{'class':'LG_closeBtn',title:lng.close,events:{'click':G.close}}),ce('br',{clear:'all'})),this.picture=ce('img',{id:'LG_pic',width:300,height:300}),this.titleBar=ce('div',{'class':'LG_titleBar'}),this.prevBtn=ce('div',{'class':'LG_prevLink',title:lng.prev,events:{click:G.prev,mouseover:showBtn,mouseout:hideBtn}}),this.nextBtn=ce('div',{'class':'LG_nextLink',title:lng.next,events:{click:G.next,mouseover:showBtn,mouseout:hideBtn}}))},zoomIn:function(){G.Zoom(1.1)},zoomOut:function(){G.Zoom(.9)},zoomNormal:function(){if(this.$disabled)
return;var p=G.picture,i=G.loaderImage;G.Zoom(p.width==i.width&&p.height==i.height?0:1);},Zoom:function(coef){G.hideContent();G.setContPos(coef)},setContPos:function(vScale){var i=G.loaderImage,p=G.picture,iWidth=i.width,iHeight=i.height,pWidth,pHeight,w,h,dx=G.dx,dy=G.dy,padding=G.minPadding,fullSizeBtn=G.fullSizeBtn;opt=G.options,lng=G.langVars,framesNumber=opt.framesNumber,ar=getPageSize(),wScr=ar[2],hScr=ar[3],dim_scr=wScr/hScr,dim_pic=iWidth/iHeight;if(i.__is_loaded__&&!vScale){if(wScr>(iWidth+dx+padding)&&hScr>(iHeight+dy+padding)){var disableFullSize=true;pWidth=iWidth;pHeight=iHeight;}else{if(dim_scr>dim_pic)
pWidth=Math.floor((pHeight=hScr-dy-padding)*dim_pic);else
pHeight=Math.floor((pWidth=wScr-dx-padding)*dim_pic);}
w=(p.width=pWidth)+dx;h=(p.height=pHeight)+dy;}else if(vScale==1){var isFullSize=true;w=(p.width=i.width)+dx;h=(p.height=i.height)+dy;}else if(vScale<1||vScale>1){w=(p.width=Math.floor(p.width*vScale))+dx;h=(p.height=Math.floor(p.height*vScale))+dy;}else{w=h=300;var disableAnimate=true;}
if(disableFullSize){fullSizeBtn.className='LG_zoom_disabled';fullSizeBtn.$disabled=true;}else{fullSizeBtn.className=isFullSize?'LG_fitScreen':'LG_zoomNormal';fullSizeBtn.setAttribute('title',isFullSize?lng.fitScreen:lng.fullSize);fullSizeBtn.$disabled=false;}
w=Math.max(w,300);css(G.overlay,{width:(w>G.overlayWidth?w+10:G.overlayWidth)+'px',height:(h>G.overlayHeight?h+10:G.overlayHeight)+'px'});var scr=getScrollXY(),y=(hScr>h?Math.floor(Math.abs((hScr-h)/2)):0)+scr[1],x=(wScr>w?Math.floor(Math.abs((wScr-w)/2)):0)+scr[0],nw=(w/3)+'px',nh=(h-dy-10)+'px';css(G.nextBtn,{width:nw,height:nh});css(G.prevBtn,{width:nw,height:nh});if(opt.animate&&!disableAnimate){var anime=new Movie(G.container,framesNumber,opt.speed);if(opt.resizeSync){anime.addThread('width',null,w,0,framesNumber);anime.addThread('left',null,x,0,framesNumber);anime.addThread('height',null,h,0,framesNumber);anime.addThread('top',null,y,0,framesNumber);}else{var middle=Math.ceil(framesNumber/2);anime.addThread('width',null,w,0,middle);anime.addThread('left',null,x,0,middle);anime.addThread('height',null,h,middle,framesNumber);anime.addThread('top',null,y,middle,framesNumber);}
anime.addAction(function(){G.showContent()},opt.framesNumber-1);anime.run();}else{css(G.container,{top:y+"px",left:x+"px",width:w+"px",height:h+"px"});G.showContent();}},preload:function(index){if(window.opera)return;var gallery=G.images[G.gallery];if(!gallery)
return;(new Image).src=(gallery[index+1]!==undefined)?gallery[index+1].href:'';(new Image).src=(gallery[index-1]!==undefined)?gallery[index-1].href:'';},showImage:function(e){var i=this.__index__,e=e||window.event;stopDefault(e);if(this.__gallery__&&i>-1){G.gallery=this.__gallery__;G.show(i);}else{G.showSingle(this);}},showSingle:function(elem){if(!G.isOpen)
G.open();G.hideContent();G.showLoadingIcon();G.loaderImage.__is_loaded__=false;G.loaderImage.src=elem.href;G.titleBar.innerHTML=elem.title;G.imgIndex.innerHTML='';G.prevBtn.style.visibility='hidden';G.nextBtn.style.visibility='hidden';},show:function(index){if(!index&&G.gallery===null)
return;if(!G.isOpen)
G.open();var gallery=G.images[G.gallery],i=G.loaderImage,prev=G.prevBtn,next=G.nextBtn,ns=next.style,ps=prev.style;if(index<0||index>gallery.length-1)
return;G.hideContent();G.showLoadingIcon();i.__is_loaded__=false;i.src=gallery[index].href;G.titleBar.innerHTML=gallery[index].title;G.imgIndex.innerHTML=lng.image+' '+(index+1)+' '+lng.of+' '+gallery.length;if(index===0){setOpacity(prev,0);prev.$active=false;next.$active=true;ps.visibility='hidden';ns.visibility='visible';}else if(index===gallery.length-1){setOpacity(next,0);prev.$active=true;next.$active=false;ps.visibility='visible';ns.visibility='hidden';}else if(index>0||index<gallery.length-1){prev.$active=next.$active=true;ps.visibility=ns.visibility='visible';}
G.current=index;window.focus();},showLoadingIcon:function(){G.container.className='LG_loading';},hideLoadingIcon:function(){G.container.className='';},hideContent:function(){for(var i=G.container.childNodes.length;--i>-1;)
G.container.childNodes[i].style.display='none';setOpacity(G.picture,0);},showContent:function(){var nodes=G.container.childNodes,opt=G.options,showLoop=function(){for(var i=nodes.length;--i>-1;)
nodes[i].style.display='block';};if(opt.fadeImage){var anime=new Movie(G.picture,8,opt.speed);anime.addThread('opacity',0,100);anime.addAction(showLoop,0);anime.run();}else{showLoop();setOpacity(G.picture,100);}},next:function(){if(G.current<G.images[G.gallery].length-1)
G.show(++G.current);},prev:function(){if(G.current>0)
G.show(--G.current)}}
function keyPressHandler(e){if(!G.isOpen)
return;var e=e||window.event,code=e.keyCode?e.keyCode:(e.which?e.which:e.charCode);switch(code){case 110:G.next();break;case 98:G.prev();break;case 102:G.zoomNormal();break;case 43:G.zoomIn();break;case 45:G.zoomOut();break;case 27:G.close();}
stopDefault(e);}
function showBtn(){if(this.$active)
fadeIn(this,0,100)}
function hideBtn(){if(this.$active)
fadeOut(this,100,0)}
function fadeIn(elem,levelStart,levelEnd,frames,speed){levelEnd=levelEnd||100;if(G.options.animate){var anime=new Movie(elem,frames||5,speed||40);anime.addThread('opacity',levelStart||0,levelEnd);anime.run();}else{setOpacity(elem,levelEnd);}}
function fadeOut(elem,levelStart,levelEnd,frames,speed){levelEnd=levelEnd||0;if(G.options.animate){var anime=new Movie(elem,frames||5,speed||40);anime.addThread('opacity',levelStart||100,levelEnd);anime.run();}else{setOpacity(elem,levelEnd);}}
function stopDefault(e){if(e.preventDefault)
e.preventDefault();else
e.returnValue=false;}
function addEvent(obj,type,fn){if(window.addEventListener)
obj.addEventListener(type,fn,false);else{obj["e"+type+fn]=fn;obj[type+fn]=function(){obj["e"+type+fn](window.event)}
obj.attachEvent("on"+type,obj[type+fn])}}
function extend(target,source){for(var i in source)
target[i]=source[i];}
function css(elem,styles){extend(elem.style,styles);}
function getPageSize(){var xScroll,yScroll,windowWidth,windowHeight,b=document.body,de=document.documentElement;if(window.innerHeight&&window.scrollMaxY){xScroll=b.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;}else if(b.scrollHeight>b.offsetHeight){xScroll=b.scrollWidth;yScroll=b.scrollHeight;}else if(de&&de.scrollHeight>de.offsetHeight){xScroll=de.scrollWidth;yScroll=de.scrollHeight;}else{xScroll=b.offsetWidth;yScroll=b.offsetHeight;}
if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(de&&de.clientHeight){windowWidth=de.clientWidth;windowHeight=de.clientHeight;}else if(b){windowWidth=b.clientWidth;windowHeight=b.clientHeight;}
var pageHeight=yScroll<windowHeight?windowHeight:yScroll;var pageWidth=xScroll<windowWidth?windowWidth:xScroll;return[pageWidth,pageHeight,windowWidth,windowHeight]}
function getScrollXY(){var scrOfX=0,scrOfY=0,b=document.body,de=document.documentElement;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}else if(b&&(b.scrollLeft||b.scrollTop)){scrOfY=b.scrollTop;scrOfX=b.scrollLeft;}else if(de&&(de.scrollLeft||de.scrollTop)){scrOfY=de.scrollTop;scrOfX=de.scrollLeft;}
return[scrOfX,scrOfY];}
function getStyle(elem,name){var d=document.defaultView;if(elem.style[name])
return elem.style[name];else if(elem.currentStyle)
return elem.currentStyle[name];else if(d&&d.getComputedStyle){name=name.replace(/([A-Z])/g,"-$1");name=name.toLowerCase();var s=d.getComputedStyle(elem,"");return s&&s.getPropertyValue(name);}
return null;}
function setOpacity(){setOpacity=arguments[0].filters?function(elem,level){elem.style.filter="alpha(opacity="+level+")"}:function(elem,level){elem.style.opacity=level/100}
setOpacity(arguments[0],arguments[1]);}
function ce(tag,attr){var elem=document.createElement(tag);if(attr){for(var name in attr){if(name=='events'){for(var j in attr[name])
addEvent(elem,j,attr[name][j]);}else{var value=attr[name];if(typeof value!="undefined"){if(name=='class'||name=='for'){name={"for":"htmlFor","class":"className"}[name]||name;elem[name]=value;}else
elem.setAttribute(name,value);}}}}
for(var i=2,len=arguments.length;i<len;i++){if(typeof arguments[i]=='string')
elem.innerHTML+=arguments[i];else
elem.appendChild(arguments[i]);}
return elem;}
function Movie(elem,num_frames,speed){if(!elem)
return null;this.elem=elem;this.numFrames=num_frames||0;this.frames=[];this.speed=speed||10;}
Movie.prototype={addThread:function(style,startValue,endValue,startFrame,endFrame){if(!style||endValue==='undefined'||endValue===null)return;if(style!=='opacity')
startValue=parseFloat(getStyle(this.elem,style));startFrame=startFrame||0;endFrame=endFrame||this.numFrames;var elem=this.elem,F=this.frames,count=(endFrame-startFrame)||1,isMore=startValue>endValue,step=Math.ceil((isMore?startValue-endValue:endValue-startValue)/count);for(startFrame;startFrame<endFrame;startFrame++){startValue=isMore?(startValue-endValue)<=step?endValue:Math.ceil(startValue-step):(endValue-startValue)<=step?endValue:Math.ceil(startValue+step);if(!F[startFrame])
F[startFrame]=new MovieFrame;F[startFrame].addStyle([elem,style,startValue]);}},addAction:function(func,frameNumber){this.frames[frameNumber].addAction(func);},step:function(){var frame=this.frames.shift();if(frame)
frame.exec();else
clearInterval(this.interval);},run:function(){clearInterval(this.interval);this.step();var t=this;if(this.numFrames>1)
this.interval=setInterval(function(){t.step()},this.speed)}}
function MovieFrame(){this.actions=[];this.styles=[];}
MovieFrame.prototype={addAction:function(f){this.actions.push(f)},addStyle:function(aStyle){this.styles.push(aStyle);},exec:function(){var s=this.styles,act,i;for(i=s.length;--i>-1;){if(s[i][1]=='opacity')
setOpacity(s[i][0],s[i][2]);else
s[i][0].style[s[i][1]]=s[i][2]+'px';}
if(act=this.actions.shift())act();}}
return G;})();
