(function(A){A.fn.lightBox=function(P){P=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},P);var I=this;function R(){O(this,I);return false}function O(V,U){A("embed, object, select").css({visibility:"hidden"});C();P.imageArray.length=0;P.activeImage=0;if(U.length==1){P.imageArray.push(new Array(V.getAttribute("href"),V.getAttribute("title")))}else{for(var T=0;T<U.length;T++){P.imageArray.push(new Array(U[T].getAttribute("href"),U[T].getAttribute("title")))}}while(P.imageArray[P.activeImage][0]!=V.getAttribute("href")){P.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"></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"></a></div></div></div></div>');var T=F();A("#jquery-overlay").css({backgroundColor:P.overlayBgColor,opacity:P.overlayOpacity,width:T[0],height:T[1]}).fadeIn();var U=H();A("#jquery-lightbox").css({top:U[1]+(T[3]/10),left:U[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 V=F();A("#jquery-overlay").css({width:V[0],height:V[1]});var W=H();A("#jquery-lightbox").css({top:W[1]+(V[3]/10),left:W[0]})})}function L(){A("#lightbox-loading").show();if(P.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",P.imageArray[P.activeImage][0]);J(T.width,T.height);T.onload=function(){}};T.src=P.imageArray[P.activeImage][0]}function J(W,Z){var T=A("#lightbox-container-image-box").width();var Y=A("#lightbox-container-image-box").height();var X=(W+(P.containerBorderSize*2));var V=(Z+(P.containerBorderSize*2));var U=T-X;var a=Y-V;A("#lightbox-container-image-box").animate({width:X,height:V},P.containerResizeSpeed,function(){G()});if((U==0)&&(a==0)){if(A.browser.msie){N(250)}else{N(100)}}A("#lightbox-container-image-data-box").css({width:W});A("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css({height:Z+(P.containerBorderSize*2)})}function G(){A("#lightbox-loading").hide();A("#lightbox-image").fadeIn(function(){K();S()});Q()}function K(){A("#lightbox-container-image-data-box").slideDown("fast");A("#lightbox-image-details-caption").hide();if(P.imageArray[P.activeImage][1]){A("#lightbox-image-details-caption").html(P.imageArray[P.activeImage][1]).show()}if(P.imageArray.length>1){A("#lightbox-image-details-currentNumber").html(P.txtImage+" "+(P.activeImage+1)+" "+P.txtOf+" "+P.imageArray.length).show()}}function S(){A("#lightbox-nav").show();A("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css({background:"transparent url("+P.imageBlank+") no-repeat"});if(P.activeImage!=0){if(P.fixedNavigation){A("#lightbox-nav-btnPrev").css({background:"url("+P.imageBtnPrev+") left 15% no-repeat"}).unbind().bind("click",function(){P.activeImage=P.activeImage-1;L();return false})}else{A("#lightbox-nav-btnPrev").unbind().hover(function(){A(this).css({background:"url("+P.imageBtnPrev+") left 15% no-repeat"})},function(){A(this).css({background:"transparent url("+P.imageBlank+") no-repeat"})}).show().bind("click",function(){P.activeImage=P.activeImage-1;L();return false})}}if(P.activeImage!=(P.imageArray.length-1)){if(P.fixedNavigation){A("#lightbox-nav-btnNext").css({background:"url("+P.imageBtnNext+") right 15% no-repeat"}).unbind().bind("click",function(){P.activeImage=P.activeImage+1;L();return false})}else{A("#lightbox-nav-btnNext").unbind().hover(function(){A(this).css({background:"url("+P.imageBtnNext+") right 15% no-repeat"})},function(){A(this).css({background:"transparent url("+P.imageBlank+") no-repeat"})}).show().bind("click",function(){P.activeImage=P.activeImage+1;L();return false})}}M()}function M(){A(document).keydown(function(T){D(T)})}function E(){A(document).unbind()}function D(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==P.keyToClose)||(key=="x")||(keycode==escapeKey)){B()}if((key==P.keyToPrev)||(keycode==37)){if(P.activeImage!=0){P.activeImage=P.activeImage-1;L();E()}}if((key==P.keyToNext)||(keycode==39)){if(P.activeImage!=(P.imageArray.length-1)){P.activeImage=P.activeImage+1;L();E()}}}function Q(){if((P.imageArray.length-1)>P.activeImage){objNext=new Image();objNext.src=P.imageArray[P.activeImage+1][0]}if(P.activeImage>0){objPrev=new Image();objPrev.src=P.imageArray[P.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 F(){var V,T;if(window.innerHeight&&window.scrollMaxY){V=window.innerWidth+window.scrollMaxX;T=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){V=document.body.scrollWidth;T=document.body.scrollHeight}else{V=document.body.offsetWidth;T=document.body.offsetHeight}}var U,W;if(self.innerHeight){if(document.documentElement.clientWidth){U=document.documentElement.clientWidth}else{U=self.innerWidth}W=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){U=document.documentElement.clientWidth;W=document.documentElement.clientHeight}else{if(document.body){U=document.body.clientWidth;W=document.body.clientHeight}}}if(T<W){pageHeight=W}else{pageHeight=T}if(V<U){pageWidth=V}else{pageWidth=U}arrayPageSize=new Array(pageWidth,pageHeight,U,W);return arrayPageSize}function H(){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 N(V){var U=new Date();T=null;do{var T=new Date()}while(T-U<V)}return this.unbind("click").click(R)}})(jQuery);(function(B){B.fn.caret=function(E,C){if(this.length==0){return }if(typeof E=="number"){C=(typeof C=="number")?C:E;return this.each(function(){if(this.setSelectionRange){this.focus();this.setSelectionRange(E,C)}else{if(this.createTextRange){var F=this.createTextRange();F.collapse(true);F.moveEnd("character",C);F.moveStart("character",E);F.select()}}})}else{if(this[0].setSelectionRange){E=this[0].selectionStart;C=this[0].selectionEnd}else{if(document.selection&&document.selection.createRange){var D=document.selection.createRange();E=0-D.duplicate().moveStart("character",-100000);C=E+D.text.length}}return{begin:E,end:C}}};var A={"9":"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"};B.mask={addPlaceholder:function(D,C){A[D]=C}};B.fn.unmask=function(){return this.trigger("unmask")};B.fn.mask=function(C,E){E=B.extend({placeholder:"_",completed:null},E);var D=new RegExp("^"+B.map(C.split(""),function(G,F){return A[G]||((/[A-Za-z0-9]/.test(G)?"":"\\")+G)}).join("")+"$");return this.each(function(){var O=B(this);var I=new Array(C.length);var J=new Array(C.length);var F=false;var N=false;var Q=null;B.each(C.split(""),function(S,T){J[S]=(A[T]==null);I[S]=J[S]?T:E.placeholder;if(!J[S]&&Q==null){Q=S}});function P(){H();L();setTimeout(function(){B(O[0]).caret(F?C.length:Q)},0)}function K(T){var U=B(this).caret();var S=T.keyCode;N=(S<16||(S>16&&S<32)||(S>32&&S<41));if((U.begin-U.end)!=0&&(!N||S==8||S==46)){G(U.begin,U.end)}if(S==8){while(U.begin-->=0){if(!J[U.begin]){I[U.begin]=E.placeholder;if(B.browser.opera){s=L();O.val(s.substring(0,U.begin)+" "+s.substring(U.begin));B(this).caret(U.begin+1)}else{L();B(this).caret(Math.max(Q,U.begin))}return false}}}else{if(S==46){G(U.begin,U.begin+1);L();B(this).caret(Math.max(Q,U.begin));return false}else{if(S==27){G(0,C.length);L();B(this).caret(Q);return false}}}}function R(V){if(N){N=false;return(V.keyCode==8)?false:null}V=V||window.event;var S=V.charCode||V.keyCode||V.which;var W=B(this).caret();if(V.ctrlKey||V.altKey){return true}else{if((S>=41&&S<=122)||S==32||S>186){var U=M(W.begin-1);if(U<C.length){if(new RegExp(A[C.charAt(U)]).test(String.fromCharCode(S))){I[U]=String.fromCharCode(S);L();var T=M(U);B(this).caret(T);if(E.completed&&T==C.length){E.completed.call(O)}}}}}return false}function G(U,S){for(var T=U;T<S&&T<C.length;T++){if(!J[T]){I[T]=E.placeholder}}}function L(){return O.val(I.join("")).val()}function H(){var W=O.val();var V=Q;for(var T=0;T<C.length;T++){if(!J[T]){I[T]=E.placeholder;while(V++<W.length){var S=new RegExp(A[C.charAt(T)]);if(W.charAt(V-1).match(S)){I[T]=W.charAt(V-1);break}}}}var U=L();if(!U.match(D)){O.val("");G(0,C.length);F=false}else{F=true}}function M(S){while(++S<C.length){if(!J[S]){return S}}return C.length}O.one("unmask",function(){O.unbind("focus",P);O.unbind("blur",H);O.unbind("keydown",K);O.unbind("keypress",R);if(B.browser.msie){this.onpaste=null}else{if(B.browser.mozilla){this.removeEventListener("input",H,false)}}});O.bind("focus",P);O.bind("blur",H);O.bind("keydown",K);O.bind("keypress",R);if(B.browser.msie){this.onpaste=function(){setTimeout(H,0)}}else{if(B.browser.mozilla){this.addEventListener("input",H,false)}}H()})}})(jQuery);