');var p=e('
').css("display","none");var d=false;var v=false;var m=false;var g=false;var y=false;var b=null;var w=null;var E=0;var S=undefined;var x={};var T=undefined;var N={scregalCenterImg:{},scregalLeftImg:{},scregalRightImg:{}};var C={elems:".gallery-box > a",maxWidth:"95%",centerDisappearAnimation:{opacity:0},sideDisappearAnimation:{opacity:0},centerAppearAnimation:{opacity:1},sideAppearAnimation:{opacity:1},disappearDuration:2e3,appearDuration:2e3,disappearEasing:"easeInOutExpo",appearEasing:"easeInOutExpo",isNavigationHidden:false,isNavigationKeyboard:true,hideNavigationWhenAutoGallery:true,hideFrontWhenAutoGallery:false,runAutoGalleryAfterDelay:5e3,autoGalleryDelay:3e3,init:true,prev:undefined,next:undefined,close:undefined,addFront:true,frontContent:function(){},frontTitle:function(){return e('
')},basicHeight:function(){return e(window).height()},basicWidth:function(){return e(window).width()},getGalleryName:function(){return"rel"}};var k=function(n,r){var i=this;this.updateOptions(r);t=n;if(typeof n==="string"){t=e(n)}if(t.length){e(C.elems).each(function(){i.append(e(this))})}else{}if(C.init){this.init()}};k.prototype.init=function(){var n=this;if(!d){e("body").prepend(r);r.append(i,s,o,u,a,f);if(C.addFront){s.append(p);p.prepend(C.frontContent());p.show(0)}!C.prev?r.append(c):"";!C.next?r.append(l):"";!C.close?r.append(h):"";C.isNavigationHidden?n.disappearNavigation():"";this.set_other_handlers();d=true;t.trigger("scregalInitialized")}};k.prototype.updateOptions=function(t){t?e.extend(C,t):""};k.prototype.append=function(n){var r=this;n.each(function(){var n=e(this);var i=n.attr("data-rel")?n.attr("data-rel"):C.getGalleryName.call(n);!x[i]?x[i]=[]:"";var s={elem:n,href:n.attr("href"),rel:i,id:E++,frontTitle:C.frontTitle.call(n)};x[i].push(s);n.addClass("scregal");r.set_handler(n);n.data("scregal",s);t.trigger("elemAppended",[n])})};k.prototype.remove=function(n){var r=this;n.each(function(){var n=e(this).data("scregal");var r=x[n.rel];for(var i in r){var s=parseInt(i);if(r[s].id==n.id){r.splice(s,1)}}e(this).removeData("scregal");t.trigger("elemRemoved",[e(this)])})};k.prototype.set_recent_scregal_data=function(e){T=e};k.prototype.disappearNavigation=function(){g=true;l.add(c).add(h).add(C.prev+", "+C.next+", "+C.close).fadeOut(300)};k.prototype.appearNavigation=function(){if(!C.isNavigationHidden){g=false;l.add(c).add(h).add(C.prev+", "+C.next+", "+C.close).fadeIn(300)}};k.prototype.disappearFront=function(){y=true;p.fadeOut(300)};k.prototype.appearFront=function(){y=false;p.fadeIn(300)};k.prototype.is_navigation_hover=function(){var t=C.prev?C.prev+":hover":n(window.scregal.classnames.scregalLeftNavigation)+":hover";var r=C.next?C.next+":hover":n(window.scregal.classnames.scregalRightNavigation)+":hover";var i=e(t+", "+r);var s=i.length?true:false;return s};k.prototype.autoGalleryInit=function(){var e=this;clearTimeout(w);if(C.runAutoGalleryAfterDelay){w=setTimeout(function(){v&&!e.is_navigation_hover()?e.autoGalleryStart():""},C.runAutoGalleryAfterDelay)}};k.prototype.autoGalleryStart=function(){var e=this;m=true;C.hideNavigationWhenAutoGallery?e.disappearNavigation():"";C.hideFrontWhenAutoGallery?e.disappearFront():"";b=setInterval(function(t){e.gallery_progress(true)},C.autoGalleryDelay+Math.max(C.disappearDuration,C.appearDuration))};k.prototype.autoGalleryStop=function(){var e=this;m=false;clearInterval(b);e.autoGalleryInit()};k.prototype.set_other_handlers=function(){var t=this;var i=3;r.on("mousemove",function(e){y?t.appearFront():"";g&&!C.isNavigationHidden?t.appearNavigation():"";m?t.autoGalleryStop():"";t.autoGalleryInit()});e(n(window.scregal.classnames.scregalCenterImg)+", "+n(window.scregal.classnames.scregalLeftImg)+", "+n(window.scregal.classnames.scregalRightImg)).load(function(){N[e(this).attr("class")]["width"]=e(this).width();N[e(this).attr("class")]["height"]=e(this).height();N[e(this).attr("class")]["href"]=e(this).attr("src");if(--i==0){t.update_boxes_content();t.update_boxes_size();i=3}});e(window).resize(function(){t.update_boxes_size()});e("body").on("click",n(window.scregal.classnames.scregalRightBox),function(e){e.preventDefault();t.autoGalleryStop();t.gallery_progress(true)});e("body").on("click",n(window.scregal.classnames.scregalLeftBox),function(e){e.preventDefault();t.autoGalleryStop();t.gallery_progress()});e("body").on("click",C.prev+", "+n(window.scregal.classnames.scregalLeftNavigation),function(e){e.preventDefault();e.stopPropagation();t.gallery_progress()});e("body").on("click",C.next+", "+n(window.scregal.classnames.scregalRightNavigation),function(e){e.preventDefault();e.stopPropagation();t.gallery_progress(true)});e("body").on("click",C.close+", "+n(window.scregal.classnames.scregalClose),function(e){e.preventDefault();e.stopPropagation();t.closeGallery()});e(document).on("keyup",function(e){e.preventDefault();var n=e.which;if(v&&C.isNavigationKeyboard){switch(n){case 27:t.closeGallery();break;case 37:t.gallery_progress();t.autoGalleryStop();break;case 39:t.gallery_progress(true);t.autoGalleryStop();break}}})};k.prototype.openGallery=function(r){var i=this;var s=r.data("scregal");i.set_recent_scregal_data(s);i.load_gallery_data();v=true;e(n(window.scregal.classnames.scregalBox)).fadeIn(300);t.trigger("scregalAppeared")};k.prototype.set_handler=function(e){var t=this;S=function(n){n.preventDefault();t.openGallery(e)};e.on("click",S)};k.prototype.gallery_progress=function(e){var t=e?this.getNextIndex():this.getPrevIndex();var n=x[T.rel][t];this.set_recent_scregal_data(n);this.load_gallery_data()};k.prototype.closeGallery=function(){e(n(window.scregal.classnames.scregalBox)).fadeOut(300);e(n(window.scregal.classnames.scregalFigure)).remove();v=false;this.autoGalleryStop();t.trigger("scregalDisappeared")};k.prototype.getPrevIndex=function(){var e=T.id;var t=x[T.rel];var n=t.length;for(var r in t){var i=parseInt(r);if(t[i].id==e){return i==0?n-1:i-1}}};k.prototype.getNextIndex=function(){var e=T.id;var t=x[T.rel];var n=t.length;for(var r in t){var i=parseInt(r);if(t[i].id==e){return i==n-1?0:i+1}}};k.prototype.add_front_to_item=function(){e(n(window.scregal.classnames.scregalTitle)).html(T.frontTitle)};k.prototype.load_gallery_data=function(){var e=this.getPrevIndex();var t=this.getNextIndex();a.attr("src",T.href);u.attr("src",x[T.rel][e].href);f.attr("src",x[T.rel][t].href);C.addFront?this.add_front_to_item():""};k.prototype.on=function(e,n){t.on(e,n)};k.prototype.off=function(e,n){t.off(e,n)};k.prototype.update_boxes_size=function(){var e=C.basicWidth();var t=C.basicHeight();var n=N.scregalCenterImg.width;var r=N.scregalCenterImg.height;var u=Math.floor(n/(r/t));s.add(i).add(o).height(t);var a=typeof C.maxWidth=="string"?parseInt(C.maxWidth)/100*e>=u?u:parseInt(C.maxWidth)/100*e:C.maxWidth>=u?u:C.maxWidth;a=Math.floor(a);s.css({width:a});i.css({width:(e-a)/2});o.css({width:(e-a)/2})};k.prototype.update_boxes_content=function(){var t=e('