/*
	Slimbox v2.04 - The ultimate lightweight Lightbox clone for jQuery
	(c) 2007-2010 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
(function($){var g=$(window),options,images,activeImage=-1,activeURL,prevImage,nextImage,compatibleOverlay,middle,centerWidth,centerHeight,ie6=!window.XMLHttpRequest,hiddenElements=[],documentElement=document.documentElement,preload={},preloadPrev=new Image(),preloadNext=new Image(),present,presentationMode,slideshowMode,slideshowActive,slideshowTimer,playLink,pauseLink,saveLink,overlay,wrapper,center,image,sizer,prevLink,nextLink,bottomContainer,bottom,caption;$(function(){$('body').append($([overlay=$('<div id="sbOverlay" />')[0],wrapper=$('<div id="lightboxWrapper" />').append([center=$('<div id="sbCenter" />').append($('<a id="closeLink" href="#" />').add(overlay).click(close)[0])[0],bottomContainer=$('<div id="sbBottomContainer" />')[0]])[0]]).css('display','none'));image=$('<div id="sbImage" />').appendTo(center).append(sizer=$('<div style="position: relative;" />').append([prevLink=$('<a id="prevLink" href="#" />').click(previous)[0],nextLink=$('<a id="nextLink" href="#" />').click(next)[0]])[0])[0];bottom=$('<div id="sbBottom" />').appendTo(bottomContainer).append([playLink=$('<a id="playLink" href="#" />').click(play)[0],pauseLink=$('<a id="pauseLink" href="#" />').click(pause)[0],saveLink=$('<a id="saveLink" href="#" target="_blank" />')[0],caption=$('<div id="sbCaption" />')[0],present=$('<div id="sbPresent" />')[0],$('<div style="clear: both;" />')[0]])[0]});$.slimbox=function(a,b,c){options=$.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:'swing',initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:'Image ###x### of ###y###',closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78],slideshowKeys:[83],allowSave:false,slideshowAutoplay:false,slideshowInterval:3000,slideshowAutoclose:true},c);if(typeof a=='string'){a=[[a,b]];b=0}middle=g.scrollTop()+(g.height()/2);centerWidth=options.initialWidth;centerHeight=options.initialHeight;$(wrapper).css({top:Math.max(0,middle-(centerHeight/2)),width:centerWidth,height:centerHeight,marginLeft:-centerWidth/2}).show();compatibleOverlay=ie6||(overlay.currentStyle&&(overlay.currentStyle.position!='fixed'));if(compatibleOverlay)overlay.style.position='absolute';$(overlay).css('opacity',options.overlayOpacity).fadeIn(options.overlayFadeDuration);position();setup(1);images=a;options.loop=options.loop&&(images.length>1);slideshowActive=options.slideshowAutoplay&&slideshowMode;return changeImage(b)};$.fn.slimbox=function(c,d,e){d=d||function(a){a.rel.match(/present.+/)?presentationMode=true:presentationMode=false;a.rel.match(/slideshow.+/)?slideshowMode=true:slideshowMode=false;return[a.href,a.title]};e=e||function(){return true};var f=this;return f.unbind('click').click(function(){var b=this,startIndex=0,filteredLinks,i=0,length;filteredLinks=$.grep(f,function(a,i){return e.call(b,a,i)});for(length=filteredLinks.length;i<length;++i){if(filteredLinks[i]==b)startIndex=i;filteredLinks[i]=d(filteredLinks[i],i)}return $.slimbox(filteredLinks,startIndex,c)})};function position(){var l=g.scrollLeft(),w=g.width();$(wrapper).css('left',l+(w/2));if(compatibleOverlay)$(overlay).css({left:l,top:g.scrollTop(),width:w,height:g.height()})}function setup(c){if(c){$('object').add(ie6?'select':'embed').each(function(a,b){hiddenElements[a]=[b,b.style.visibility];b.style.visibility='hidden'})}else{$.each(hiddenElements,function(a,b){b[0].style.visibility=b[1]});hiddenElements=[]}var d=c?'bind':'unbind';g[d]('scroll resize',position);$(document)[d]('keydown',keyDown)}function keyDown(a){var b=a.keyCode,fn=$.inArray;return(fn(b,options.closeKeys)>=0)?close():(fn(b,options.nextKeys)>=0)?next():(fn(b,options.previousKeys)>=0)?previous():(fn(b,options.slideshowKeys)>=0)?togglePlayPause():false}function previous(){return changeImage(prevImage)}function next(){return changeImage(nextImage)}function changeImage(a){if(a>=0){activeImage=a;activeURL=images[activeImage][0];prevImage=(activeImage||(options.loop?images.length:0))-1;nextImage=((activeImage+1)%images.length)||(options.loop?0:-1);stop();center.className='sbLoading';preload=new Image();preload.onload=animateBox;preload.src=activeURL}return false}function animateBox(){$("#closeLink").hide();center.className='';$(image).css({backgroundImage:'url('+activeURL+')',visibility:'hidden',display:''});$(sizer).width(preload.width);$([sizer,prevLink,nextLink]).height(preload.height);$(caption).html(images[activeImage][1]||'');if(presentationMode){$(present).html('').css('display','');for(i=0;i<images.length;i++){var b=activeImage==i?'act':'no';var c=$('<a id="pmi'+(i+1)+'" href="#" class="'+b+'"></a>').click(function(){var a=parseInt($(this).text())-1;pause();return changeImage(a)});i<9?c.html('0'+(i+1)):c.html(i+1);c.appendTo(present)}}else{$(present).html('').css('display','none')}if(prevImage>=0)preloadPrev.src=images[prevImage][0];if(nextImage>=0)preloadNext.src=images[nextImage][0];centerWidth=image.offsetWidth;centerHeight=image.offsetHeight;var d=Math.max(0,middle-(centerHeight/2));var e=wrapper.offsetHeight,nWidth=wrapper.offsetWidth;if(wrapper.offsetHeight!=centerHeight)e=centerHeight;if(wrapper.offsetWidth!=centerWidth)nWidth=centerWidth;$(wrapper).animate({width:nWidth,marginLeft:-centerWidth/2,height:e,top:d},options.resizeDuration,options.resizeEasing,function(){$(bottomContainer).css({width:centerWidth,top:centerHeight,marginLeft:-centerWidth/2,visibility:'hidden',display:''});$(image).css({display:'none',visibility:'',opacity:''}).fadeIn(options.imageFadeDuration,animateCaption)});$(center).animate({height:e,top:"0",width:nWidth,marginLeft:-centerWidth/2},options.resizeDuration,options.resizeEasing)}function animateCaption(){if(prevImage>=0)$(prevLink).show();if(nextImage>=0)$(nextLink).show();var h=$(bottomContainer).height()+image.offsetHeight;$(bottom).css('marginTop',-bottom.offsetHeight).animate({marginTop:0},options.captionAnimationDuration);$(wrapper).animate({height:h},options.captionAnimationDuration,function(){$("#closeLink").show()});bottomContainer.style.visibility='';$(playLink).css('display','none');$(pauseLink).css('display','none');if(slideshowMode){clearTimeout(slideshowTimer);if(slideshowActive){$(pauseLink).css('display','');if(activeImage!=(images.length-1)){slideshowTimer=setTimeout(next,options.slideshowInterval)}else{if(options.slideshowAutoclose){slideshowTimer=setTimeout(close,options.slideshowInterval)}else if(options.loop){slideshowTimer=setTimeout(changeImage,options.slideshowInterval,0)}else{pause()}}}else{$(playLink).css('display','')}}options.allowSave?$(saveLink).attr('href',images[activeImage][0]).css('display',''):$(saveLink).css('display','none')}function togglePlayPause(){if(slideshowActive){pause()}else{play()}return false}function play(){slideshowActive=true;if(activeImage!=(images.length-1)){next()}else{if(options.slideshowAutoclose&&!options.loop){slideshowTimer=setTimeout(close,0)}else if(options.loop){changeImage(0)}else{}}return false}function pause(){slideshowActive=false;clearTimeout(slideshowTimer);$(playLink).css('display','');$(pauseLink).css('display','none');return false}function stop(){preload.onload=null;preload.src=preloadPrev.src=preloadNext.src=activeURL;$([center,image,bottom]).stop(true);$([prevLink,nextLink,image,bottomContainer]).hide()}function close(){if(activeImage>=0){pause();stop();activeImage=prevImage=nextImage=-1;$(wrapper).hide();$(overlay).stop().fadeOut(options.overlayFadeDuration,setup);clearTimeout(slideshowTimer)}return false}})(jQuery);var SlimboxOptions=jQuery.extend({},window.SlimboxOptions||{});if(!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)){jQuery(function($){$("a[rel^='lightbox']").slimbox(SlimboxOptions,null,function(a){return(this==a)||((this.rel.length>8)&&(this.rel==a.rel))})})}
