var Lightbox={fileLoadingImage:'../../inc/images/loading.gif',fileBottomNavCloseImage:'../../inc/images/closelabel.gif',overlayOpacity:0.8,resizeSpeed:'normal',borderSize:10,imageArray:new Array,activeImage:0,overlaySpeed:'slow',initialize:function(){Lightbox.updateImageList();$("body").append('<div id="overlay"></div> 			<div id="lightbox"> 				<div id="outerImageContainer"> 					<div id="imageContainer"> 						<img id="lightboxImage" galleryimg="false" /> 						<div style="" id="hoverNav"> 							<a href="#" id="prevLink"></a> 							<a href="#" id="nextLink"></a> 						</div> 						<div id="loading"> 							<a href="#" id="loadingLink"> 								<img src="'+Lightbox.fileLoadingImage+'" /> 							</a> 						</div> 					</div> 				</div> 				<div id="imageDataContainer"> 					<div id="imageData"> 						<div id="imageDetails"> 							<span id="caption"></span> 							<span id="numberDisplay"></span> 						</div> 						<div id="bottomNav"> 							<a href="#" id="bottomNavClose"> 								<img src="'+Lightbox.fileBottomNavCloseImage+'" /> 							</a> 						</div> 					</div> 				</div> 			</div>');$('#overlay').click(function(){Lightbox.end();return false}).hide();$('#lightbox').hide();$('#loadingLink').click(function(){Lightbox.end();return false});$('#bottomNavClose').click(function(){Lightbox.end();return false});$('#outerImageContainer').width(250).height(250);$('#prevLink').css({paddingTop:Lightbox.borderSize,paddingLeft:Lightbox.borderSize});$('#nextLink').css({paddingTop:Lightbox.borderSize,paddingRight:Lightbox.borderSize});$('#prevLink').click(function(){Lightbox.changeImage(Lightbox.activeImage-1);return false});$('#nextLink').click(function(){Lightbox.changeImage(Lightbox.activeImage+1);return false})},updateImageList:function(){var anchors=$('a');var areas=$('area');for(var i=0;i<anchors.length;i++){var anchor=anchors[i];var relAttribute=String(anchor.getAttribute('rel'));if(anchor.getAttribute('href')&&(relAttribute.toLowerCase().match('lightbox'))){anchor.onclick=function(){Lightbox.start(this);return false}}}for(var i=0;i<areas.length;i++){var area=areas[i];var relAttribute=String(area.getAttribute('rel'));if(area.getAttribute('href')&&(relAttribute.toLowerCase().match('lightbox'))){area.onclick=function(){Lightbox.start(this);return false}}}},start:function(imageLink){$("select, embed, object").hide();var arrayPageSize=Lightbox.getPageSize();$('#overlay').width(arrayPageSize[0]).height(arrayPageSize[1]);$('#overlay').css({opacity:Lightbox.overlayOpacity}).fadeIn(Lightbox.overlaySpeed);Lightbox.imageArray=new Array;imageNum=0;var anchors=$(imageLink.tagName);imageLink=$(imageLink);if((imageLink.attr('rel')=='lightbox')){Lightbox.imageArray.push(new Array(imageLink.attr('href'),imageLink.attr('title')))}else{for(var i=0;i<anchors.length;i++){var anchor=$(anchors[i]);if(anchor.attr('href')&&(anchor.attr('rel')==imageLink.attr('rel'))){Lightbox.imageArray.push(new Array(anchor.attr('href'),anchor.attr('title')))}}for(i=0;i<Lightbox.imageArray.length;i++){for(var j=Lightbox.imageArray.length-1;j>i;j--){if(Lightbox.imageArray[i][0]==Lightbox.imageArray[j][0]){Lightbox.imageArray.splice(j,1)}}}while(Lightbox.imageArray[imageNum][0]!=imageLink.attr('href')){imageNum++}}var arrayPageScroll=Lightbox.getPageScroll();var lightboxTop=arrayPageScroll[1]+(arrayPageSize[3]/10);var lightboxLeft=arrayPageScroll[0];$("#lightbox").css({top:lightboxTop,left:lightboxLeft});$("#lightbox").show();Lightbox.changeImage(imageNum)},changeImage:function(imageNum){Lightbox.activeImage=imageNum;$('#loading').show();$('#lightboxImage, #hoverNav, #imageDataContainer, #numberDisplay').hide();imgPreloader=new Image();imgPreloader.onload=function(){$('#lightboxImage').attr('src',Lightbox.imageArray[Lightbox.activeImage][0]);Lightbox.resizeImageContainer(this.width,this.height);if($.browser.msie)imgPreloader.onload=function(){}};imgPreloader.src=Lightbox.imageArray[Lightbox.activeImage][0]},resizeImageContainer:function(imgWidth,imgHeight){this.widthCurrent=$('#outerImageContainer').width();this.heightCurrent=$('#outerImageContainer').height();this.widthNew=(imgWidth+(Lightbox.borderSize*2));this.heightNew=(imgHeight+(Lightbox.borderSize*2));this.wDiff=this.widthCurrent-this.widthNew;this.hDiff=this.heightCurrent-this.heightNew;if(this.hDiff!=0||this.wDiff!=0){$('#outerImageContainer').animate({width:this.widthNew,height:this.heightNew},Lightbox.resizeSpeed,'linear',function(){Lightbox.showImage()})}else{if($.browser.msie){Lightbox.pause(250)}else{Lightbox.pause(100)}Lightbox.showImage()}$('#prevLink, #nextLink').height(imgHeight);$('#prevLink, #nextLink').width(parseInt(imgWidth/2));$('#imageDataContainer').width(this.widthNew)},showImage:function(){$('#loading').hide();$('#lightboxImage').fadeIn(Lightbox.resizeSpeed,Lightbox.updateDetails)},updateDetails:function(){if(Lightbox.imageArray[Lightbox.activeImage][1]){$('#caption').html(Lightbox.imageArray[Lightbox.activeImage][1]).show()}if(Lightbox.imageArray.length>1){$('#numberDisplay').html("Image "+eval(parseInt(Lightbox.activeImage)+1)+" of "+Lightbox.imageArray.length).show()}$("#imageDataContainer").slideDown(Lightbox.resizeSpeed,function(){$('#hoverNav').show();Lightbox.updateNav();var arrayPageSize=Lightbox.getPageSize();$('#overlay').height(arrayPageSize[1]);Lightbox.preloadNeighborImages();Lightbox.enableKeyboardNav()})},updateNav:function(){if(Lightbox.activeImage!=0){$('#prevLink').show()}else{$('#prevLink').hide()}if(Lightbox.activeImage!=(Lightbox.imageArray.length-1)){$('#nextLink').show()}else{$('#nextLink').hide()}},enableKeyboardNav:function(){document.onkeydown=Lightbox.keyboardAction},disableKeyboardNav:function(){document.onkeydown=''},keyboardAction:function(e){if(e==null){keycode=event.keyCode;escapeKey=27}else{keycode=e.keyCode;escapeKey=e.DOM_VK_ESCAPE}key=String.fromCharCode(keycode).toLowerCase();if((key=='x')||(key=='o')||(key=='c')||(keycode==escapeKey)){Lightbox.end()}else if((key=='p')||(keycode==37)){if(Lightbox.activeImage!=0){Lightbox.disableKeyboardNav();Lightbox.changeImage(Lightbox.activeImage-1)}}else if((key=='n')||(keycode==39)){if(Lightbox.activeImage!=(Lightbox.imageArray.length-1)){Lightbox.disableKeyboardNav();Lightbox.changeImage(Lightbox.activeImage+1)}}},preloadNeighborImages:function(){if((Lightbox.imageArray.length-1)>Lightbox.activeImage){preloadNextImage=new Image();preloadNextImage.src=Lightbox.imageArray[parseInt(Lightbox.activeImage)+1][0]}if(Lightbox.activeImage>0){preloadPrevImage=new Image();preloadPrevImage.src=Lightbox.imageArray[parseInt(Lightbox.activeImage)-1][0]}},end:function(){Lightbox.disableKeyboardNav();$('#lightbox').hide();$("#overlay").fadeOut(Lightbox.overlaySpeed);$("select, object, embed").show()},getPageScroll:function(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft}arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll},getPageSize:function(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight}var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth}else{windowWidth=self.innerWidth}windowHeight=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight}if(yScroll<windowHeight){pageHeight=windowHeight}else{pageHeight=yScroll}if(xScroll<windowWidth){pageWidth=xScroll}else{pageWidth=windowWidth}arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize},pause:function(ms){var date=new Date();curDate=null;do{var curDate=new Date()}while(curDate-date<ms)}};$(document).ready(function(){Lightbox.initialize()});
