function doLightBox(){var e,i,t="object"==typeof JQLBSettings,a=0;t&&JQLBSettings.slideshowSpeed&&(e=parseInt(JQLBSettings.slideshowSpeed)),t&&JQLBSettings.resizeSpeed&&(i=parseInt(JQLBSettings.resizeSpeed)),t&&JQLBSettings.marginSize&&(a=parseInt(JQLBSettings.marginSize));var n={prevLinkTitle:"previous image",nextLinkTitle:"next image",closeTitle:"close image gallery",image:"Image ",of:" of ",download:"Download",pause:"(pause slideshow)",play:"(play slideshow)"};jQuery('a[rel^="lightbox"]').lightbox({adminBarHeight:jQuery("#wpadminbar").height()||0,showNumbers:t&&"0"==JQLBSettings.showNumbers?!1:!0,showCaption:t&&"0"==JQLBSettings.showCaption?!1:!0,showTitle:t&&"0"==JQLBSettings.showTitle?!1:!0,marginSize:t&&a?a:0,fitToScreen:t&&"1"==JQLBSettings.fitToScreen?!0:!1,resizeSpeed:t&&i>=0?i:400,slidehowSpeed:t&&e>=0?e:4e3,showDownload:t&&"0"==JQLBSettings.showDownload?!1:!0,navbarOnTop:t&&"0"==JQLBSettings.navbarOnTop?!1:!0,strings:t&&"string"==typeof JQLBSettings.prevLinkTitle?JQLBSettings:n})}!function(e){function t(e,i){var t,a,n;for(e=e.split("."),i=i.split("."),a=Math.min(e.length,i.length),t=0;a>t;t++)if(n=parseInt(e[t],10)-parseInt(i[t],10),0!==n)return n;return e.length-i.length}e.fn.lightbox=function(a){function n(){return r(),g(this),!1}function r(){e(window).bind("orientationchange",o),e(window).bind("resize",o),e("#overlay").remove(),e("#lightbox").remove(),T.inprogress=!1,T.auto=-1;var i=T.strings,t='<div id="outerImageContainer"><div id="imageContainer"><iframe id="lightboxIframe" /><img id="lightboxImage"><div id="hoverNav"><a href="javascript://" title="'+i.prevLinkTitle+'" id="prevLink"></a><a href="javascript://" id="nextLink" title="'+i.nextLinkTitle+'"></a></div><div id="jqlb_loading"><a href="javascript://" id="loadingLink"><div id="jqlb_spinner"></div></a></div></div></div>',a='<div id="imageDataContainer" class="clearfix"><div id="imageData"><div id="imageDetails"><span id="titleAndCaption"></span><div id="controls"><span id="numberDisplay"></span> <a id="playPause" href="#"></a> <span id="downloadLink"></span></div></div><div id="bottomNav">';a+='<a href="javascript://" id="bottomNavClose" title="'+i.closeTitle+'"><div id="jqlb_closelabel"></div></a></div></div></div>';var n;T.navbarOnTop?(n='<div id="overlay"></div><div id="lightbox">'+a+t+"</div>",e("body").append(n),e("#imageDataContainer").addClass("ontop")):(n='<div id="overlay"></div><div id="lightbox">'+t+a+"</div>",e("body").append(n)),e("#overlay").click(function(){S()}).hide(),e("#lightbox").click(function(){S()}).hide(),e("#loadingLink").click(function(){return S(),!1}),e("#bottomNavClose").click(function(){return S(),!1}),e("#outerImageContainer").width(T.widthCurrent).height(T.heightCurrent),e("#imageDataContainer").width(T.widthCurrent),T.imageClickClose||(e("#lightboxImage").click(function(){return!1}),e("#hoverNav").click(function(){return!1}))}function o(){T.resizeTimeout&&(clearTimeout(T.resizeTimeout),T.resizeTimeout=!1),T.resizeTimeout=setTimeout(function(){u()},50)}function l(){return{pageWidth:e(document).width(),pageHeight:e(document).height(),viewportWidth:e(window).width(),viewportHeight:e(window).height()-T.adminBarHeight}}function d(){var i=e(document).scrollTop();return T.adminBarHeight&&0===parseInt(e("#wpadminbar").css("top"),10)&&(i+=T.adminBarHeight),{x:e(document).scrollLeft(),y:i}}function g(t){var a=l();e("#overlay").hide().css({width:a.pageWidth+"px",height:a.pageHeight+"px",opacity:T.overlayOpacity}).fadeIn(400);var n=0,r=[];if(T.downloads={},e("a").each(function(){if(this.href&&this.rel==t.rel){var i=e(this),a=T.showTitle?s(i):"",n=T.showCaption?h(i):{html:"",text:""};T.showTitle&&a.toLowerCase()==n.text.toLowerCase()&&(a=n.html,n.html="");var o=""!=a?'<span id="titleText">'+a+"</span>":"";o+=""!=a&&n.html?"<br />":"",o+=""!=n.html?'<span id="captionText">'+n.html+"</span>":"",(T.showDownload||i.attr("data-download"))&&(T.downloads[r.length]=i.attr("data-download")),r.push(new Array(this.href,o,r.length))}}),r.length>1){for(i=0;i<r.length;i++)for(j=r.length-1;j>i;j--)r[i][0]==r[j][0]&&r.splice(j,1);for(;r[n][0]!=t.href;)n++}T.imageArray=r;var o=d();m(o.y,o.x).show(),c(n),b()}function s(i){var t=i.attr("title")||"";if(!t){var a=i.children("img:first-child");a.attr("title")?t=a.attr("title"):a.attr("alt")&&(t=a.attr("alt"))}return e.trim(t)}function h(i){var t={html:"",text:""};if(i.parent().next(".gallery-caption").html()){var a=i.parent().next(".gallery-caption");t.html=a.html(),t.text=a.text()}else i.next(".wp-caption-text").html()&&(t.html=i.next(".wp-caption-text").html(),t.text=i.next(".wp-caption-text").text());return t.text=e.trim(t.text).replace("&#8217;","&#039;").replace("’","'").replace("…","..."),t}function m(i,t){return T.resizeSpeed>0?e("#lightbox").animate({top:i+"px",left:t+"px"},T.resizeSpeed,"linear"):e("#lightbox").css({top:i+"px",left:t+"px"})}function c(i){0==T.inprogress&&(T.inprogress=!0,T.activeImage=i,e("#jqlb_loading").show(),e("#lightboxImage").hide(),e("#hoverNav").hide(),e("#prevLink").hide(),e("#nextLink").hide(),p())}function p(){T.imgPreloader=new Image,T.imgPreloader.onload=function(){e("#lightboxImage").attr("src",T.imageArray[T.activeImage][0]),I(),u(),x()},T.imgPreloader.src=T.imageArray[T.activeImage][0]}function u(){if(T.imgPreloader){var i=T.imgPreloader.width,t=T.imgPreloader.height,a=l(),n=a.viewportWidth<a.pageWidth?a.pageWidth:a.viewportWidth;e("#overlay").css({width:n+"px",height:a.pageHeight+"px"});var r=a.viewportHeight-(e("#imageDataContainer").outerHeight(!0)+2*T.borderSize),o=a.viewportWidth-2*T.borderSize;if(T.fitToScreen){var g=r-T.marginSize,s=o-T.marginSize,h=1;t>g&&(h=g/t),i*=h,t*=h,h=1,i>s&&(h=s/i),i=Math.round(i*h),t=Math.round(t*h)}var m=d(),c=m.y+.5*r,p=c-.5*t,u=m.x;e("#lightboxImage").width(i).height(t),v(i,t,p,u)}}function v(i,t,a,n){T.widthCurrent=e("#outerImageContainer").outerWidth(),T.heightCurrent=e("#outerImageContainer").outerHeight();var r=Math.max(300,i+2*T.borderSize),o=t+2*T.borderSize;m(a,n),e("#imageDataContainer").animate({width:r},T.resizeSpeed,"linear"),e("#outerImageContainer").animate({width:r,height:o},T.resizeSpeed,"linear",function(){w()}),T.imageArray.length>1&&(e("#hoverNav").show(),e("#prevLink").show(),e("#nextLink").show()),e("#prevLink,#nextLink").height(t)}function w(){e("#jqlb_loading").hide(),f(),T.resizeSpeed>0?e("#lightboxImage").fadeIn("fast",function(){y()}):(e("#lightboxImage").show(),y()),T.inprogress=!1}function f(){e("#titleAndCaption").css("opacity",1),T.showDownload&&e("#downloadLink").css("opacity",1),T.showNumbers&&e("#numberDisplay").css("opacity",1),T.slidehowSpeed&&e("#playPause").css("opacity",1),T.resizeSpeed>0?e("#imageDetails").animate({opacity:1},"fast"):e("#imageDetails").css("opacity",1)}function y(){-1!=T.auto&&(clearTimeout(T.auto),T.auto=setTimeout(function(){c(T.activeImage==T.imageArray.length-1?0:T.activeImage+1)},T.slidehowSpeed)),k()}function x(){T.imageArray.length>1?(preloadNextImage=new Image,preloadNextImage.src=T.imageArray[T.activeImage==T.imageArray.length-1?0:T.activeImage+1][0],preloadPrevImage=new Image,preloadPrevImage.src=T.imageArray[0==T.activeImage?T.imageArray.length-1:T.activeImage-1][0]):(T.imageArray.length-1>T.activeImage&&(preloadNextImage=new Image,preloadNextImage.src=T.imageArray[T.activeImage+1][0]),T.activeImage>0&&(preloadPrevImage=new Image,preloadPrevImage.src=T.imageArray[T.activeImage-1][0]))}function I(){var i=T.imageArray,t=T.strings,a=T.activeImage,n=i[a][2],r=T.showNumbers&&i.length>1?t.image+(a+1)+t.of+i.length:"";if(e("#imageDetails").css("opacity",0),""!=i[a][1]?e("#titleAndCaption").css("opacity",0).html(i[a][1]):e("#titleAndCaption").empty(),T.showNumbers?e("#numberDisplay").css("opacity",0).html(r):e("#numberDisplay").empty(),T.slidehowSpeed&&i.length>1){var o=-1===T.auto?t.play:t.pause;e("#playPause").css("opacity",0).attr("href","#").text(o)}else e("#playPause").empty();if(T.showDownload||T.downloads[n]){var l=T.downloads[n]?T.downloads[n]:i[a][0];e("#downloadLink").css("opacity",0).html(e("<a>").attr("href",l).attr("target","_blank").attr("download","").text(t.download))}else e("#downloadLink").empty();e("#downloadLink").position()}function b(){T.imageArray.length>1&&(e("#prevLink").click(function(){return c(0==T.activeImage?T.imageArray.length-1:T.activeImage-1),!1}),e("#nextLink").click(function(){return c(T.activeImage==T.imageArray.length-1?0:T.activeImage+1),!1}),e.fn.touchwipe&&e("#imageContainer").touchwipe({wipeLeft:function(){c(T.activeImage==T.imageArray.length-1?0:T.activeImage+1)},wipeRight:function(){c(0==T.activeImage?T.imageArray.length-1:T.activeImage-1)},min_move_x:20,preventDefaultEvents:!0}),T.slidehowSpeed&&e("#playPause").unbind("click").click(function(){return-1!=T.auto?(e(this).text(T.strings.play),clearTimeout(T.auto),T.auto=-1):(e(this).text(T.strings.pause),T.auto=setTimeout(function(){c(T.activeImage==T.imageArray.length-1?0:T.activeImage+1)},T.slidehowSpeed)),!1}),k())}function S(){C(),clearTimeout(T.auto),T.auto=-1,e("#lightbox").hide(),e("#overlay").fadeOut()}function L(e){var i=e.data.opts,t=e.keyCode,a=27,n=String.fromCharCode(t).toLowerCase();return"x"==n||"o"==n||"c"==n||t==a?S():"p"==n||37==t?(C(),c(0==i.activeImage?i.imageArray.length-1:i.activeImage-1)):("n"==n||39==t)&&(C(),c(i.activeImage==i.imageArray.length-1?0:i.activeImage+1)),!1}function k(){e(document).unbind("keydown").bind("keydown",{opts:T},L)}function C(){e(document).unbind("keydown")}var T=e.extend({},e.fn.lightbox.defaults,a);return e("#overlay").is(":visible")&&e(window).trigger("resize"),t(e.fn.jquery,"1.7")>0?e(this).on("click",n):e(this).live("click",n)},e.fn.lightbox.defaults={showCaption:!1,showNumbers:!0,adminBarHeight:0,overlayOpacity:.8,borderSize:10,imageArray:new Array,activeImage:null,inprogress:!1,widthCurrent:300,heightCurrent:300,showTitle:!0,imageClickClose:!0},e(document).ready(doLightBox)}(jQuery);