(function(a){a.fn.lightBox=function(o){o=jQuery.extend({overlayBgColor:"#000",overlayOpacity:0.8,fixedNavigation:false,imageLoading:"/images/lightbox-ico-loading.gif",imageBtnPrev:"/images/lightbox-btn-prev.gif",imageBtnNext:"/images/lightbox-btn-next.gif",imageBtnClose:"/images/lightbox-btn-close.gif",imageBlank:"/images/lightbox-blank.gif",containerBorderSize:10,containerResizeSpeed:400,txtImage:"Image",txtOf:"of",keyToClose:"c",keyToPrev:"p",keyToNext:"n",imageArray:[],activeImage:0},o);var g=this;function r(){n(this,g);return false}function n(v,t){a("embed, object, select").css({visibility:"hidden"});c();o.imageArray.length=0;o.activeImage=0;if(t.length==1){o.imageArray.push(new Array(v.getAttribute("href"),v.getAttribute("title")))}else{for(var u=0;u<t.length;u++){o.imageArray.push(new Array(t[u].getAttribute("href"),t[u].getAttribute("title")))}}while(o.imageArray[o.activeImage][0]!=v.getAttribute("href")){o.activeImage++}l()}function c(){a("body").append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+o.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+o.imageBtnClose+'"></a></div></div></div></div>');var u=i();a("#jquery-overlay").css({backgroundColor:o.overlayBgColor,opacity:o.overlayOpacity,width:u[0],height:u[1]}).fadeIn();var t=j();a("#jquery-lightbox").css({top:t[1]+(u[3]/10),left:t[0]}).show();a("#jquery-overlay,#jquery-lightbox").click(function(){b()});a("#lightbox-loading-link,#lightbox-secNav-btnClose").click(function(){b();return false});a(window).resize(function(){var w=i();a("#jquery-overlay").css({width:w[0],height:w[1]});var v=j();a("#jquery-lightbox").css({top:v[1]+(w[3]/10),left:v[0]})})}function l(){a("#lightbox-loading").show();if(o.fixedNavigation){a("#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber").hide()}else{a("#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber").hide()}var t=new Image();t.onload=function(){a("#lightbox-image").attr("src",o.imageArray[o.activeImage][0]);f(t.width,t.height);t.onload=function(){}};t.src=o.imageArray[o.activeImage][0]}function f(y,z){var t=a("#lightbox-container-image-box").width();var x=a("#lightbox-container-image-box").height();var w=(y+(o.containerBorderSize*2));var v=(z+(o.containerBorderSize*2));var u=t-w;var A=x-v;a("#lightbox-container-image-box").animate({width:w,height:v},o.containerResizeSpeed,function(){h()});if((u==0)&&(A==0)){if(a.browser.msie){p(250)}else{p(100)}}a("#lightbox-container-image-data-box").css({width:y});a("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css({height:z+(o.containerBorderSize*2)})}function h(){a("#lightbox-loading").hide();a("#lightbox-image").fadeIn(function(){d();s()});m()}function d(){a("#lightbox-container-image-data-box").slideDown("fast");a("#lightbox-image-details-caption").hide();if(o.imageArray[o.activeImage][1]){a("#lightbox-image-details-caption").html(o.imageArray[o.activeImage][1]).show()}if(o.imageArray.length>1){a("#lightbox-image-details-currentNumber").html(o.txtImage+" "+(o.activeImage+1)+" "+o.txtOf+" "+o.imageArray.length).show()}}function s(){a("#lightbox-nav").show();a("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css({background:"transparent url("+o.imageBlank+") no-repeat"});if(o.activeImage!=0){if(o.fixedNavigation){a("#lightbox-nav-btnPrev").css({background:"url("+o.imageBtnPrev+") left 15% no-repeat"}).unbind().bind("click",function(){o.activeImage=o.activeImage-1;l();return false})}else{a("#lightbox-nav-btnPrev").unbind().hover(function(){a(this).css({background:"url("+o.imageBtnPrev+") left 15% no-repeat"})},function(){a(this).css({background:"transparent url("+o.imageBlank+") no-repeat"})}).show().bind("click",function(){o.activeImage=o.activeImage-1;l();return false})}}if(o.activeImage!=(o.imageArray.length-1)){if(o.fixedNavigation){a("#lightbox-nav-btnNext").css({background:"url("+o.imageBtnNext+") right 15% no-repeat"}).unbind().bind("click",function(){o.activeImage=o.activeImage+1;l();return false})}else{a("#lightbox-nav-btnNext").unbind().hover(function(){a(this).css({background:"url("+o.imageBtnNext+") right 15% no-repeat"})},function(){a(this).css({background:"transparent url("+o.imageBlank+") no-repeat"})}).show().bind("click",function(){o.activeImage=o.activeImage+1;l();return false})}}q()}function q(){a(document).keydown(function(t){e(t)})}function k(){a(document).unbind()}function e(t){if(t==null){keycode=event.keyCode;escapeKey=27}else{keycode=t.keyCode;escapeKey=t.DOM_VK_ESCAPE}key=String.fromCharCode(keycode).toLowerCase();if((key==o.keyToClose)||(key=="x")||(keycode==escapeKey)){b()}if((key==o.keyToPrev)||(keycode==37)){if(o.activeImage!=0){o.activeImage=o.activeImage-1;l();k()}}if((key==o.keyToNext)||(keycode==39)){if(o.activeImage!=(o.imageArray.length-1)){o.activeImage=o.activeImage+1;l();k()}}}function m(){if((o.imageArray.length-1)>o.activeImage){objNext=new Image();objNext.src=o.imageArray[o.activeImage+1][0]}if(o.activeImage>0){objPrev=new Image();objPrev.src=o.imageArray[o.activeImage-1][0]}}function b(){a("#jquery-lightbox").remove();a("#jquery-overlay").fadeOut(function(){a("#jquery-overlay").remove()});a("embed, object, select").css({visibility:"visible"})}function i(){var v,u;if(window.innerHeight&&window.scrollMaxY){v=window.innerWidth+window.scrollMaxX;u=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){v=document.body.scrollWidth;u=document.body.scrollHeight}else{v=document.body.offsetWidth;u=document.body.offsetHeight}}var t,w;if(self.innerHeight){if(document.documentElement.clientWidth){t=document.documentElement.clientWidth}else{t=self.innerWidth}w=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){t=document.documentElement.clientWidth;w=document.documentElement.clientHeight}else{if(document.body){t=document.body.clientWidth;w=document.body.clientHeight}}}if(u<w){pageHeight=w}else{pageHeight=u}if(v<t){pageWidth=v}else{pageWidth=t}arrayPageSize=new Array(pageWidth,pageHeight,t,w);return arrayPageSize}function j(){var u,t;if(self.pageYOffset){t=self.pageYOffset;u=self.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollTop){t=document.documentElement.scrollTop;u=document.documentElement.scrollLeft}else{if(document.body){t=document.body.scrollTop;u=document.body.scrollLeft}}}arrayPageScroll=new Array(u,t);return arrayPageScroll}function p(v){var u=new Date();t=null;do{var t=new Date()}while(t-u<v)}return this.unbind("click").click(r)}})(jQuery);