jQuery.fn.prettyPhoto=function(j){var k=false;var l=0;var m=0;var n=0;var o=false;var p=0;var q=true;var r=[];jQuery(window).scroll(function(){_centerPicture()});jQuery(window).resize(function(){_centerPicture();_resizeOverlay()});jQuery(document).keyup(function(e){switch(e.keyCode){case 37:if(m==1)return;changePicture('previous');break;case 39:if(m==l)return;changePicture('next');break;case 27:close();break}});j=jQuery.extend({animationSpeed:'normal',padding:40,opacity:0.35,showTitle:true,allowresize:true,counter_separator_label:'/'},j);jQuery(this).each(function(){r[r.length]=this;jQuery(this).bind('click',function(){open(this);return false})});function open(a){p=jQuery(a);theRel=jQuery(p).attr('rel');galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);contentType="image";if(jQuery(p).attr('href').indexOf('.swf')>0){o=false;contentType='flash'};k=false;l=0;for(i=0;i<r.length;i++){if(jQuery(r[i]).attr('rel').indexOf(theGallery)!=-1){l++;if(l>1)k=true;if(jQuery(r[i]).attr('href')==jQuery(a).attr('href')){m=l;n=i}}};_buildOverlay(k);jQuery('div.pictureHolder p.currentTextHolder').text(m+j.counter_separator_label+l);_centerPicture();jQuery('div.pictureHolder #fullResImageContainer').hide();jQuery('.loaderIcon').show();(contentType=='image')?_preload():_writeFlash()};showimage=function(a,b,c,d,e,f,g){jQuery('.loaderIcon').hide();var h=_getScroll();if(jQuery.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=jQuery(window).height();windowWidth=jQuery(window).width()};jQuery('div.pictureHolder .content').animate({'height':e,'width':c},j.animationSpeed);projectedTop=h['scrollTop']+((windowHeight/2)-(d/2));if(projectedTop<0)projectedTop=0+jQuery('div.prettyPhotoTitle').height();jQuery('div.pictureHolder').animate({'top':projectedTop,'left':((windowWidth/2)-(c/2)),'width':c},j.animationSpeed,function(){jQuery('#fullResImage').attr({'width':a,'height':b});jQuery('div.pictureHolder').width(c);jQuery('div.pictureHolder .hoverContainer').height(b).width(a);_shownav();jQuery('div.pictureHolder #fullResImageContainer').fadeIn(j.animationSpeed);if(g)jQuery('a.expand,a.contract').fadeIn(j.animationSpeed)})};function changePicture(a){if(a=='previous'){n--;m--}else{n++;m++};if(!q)q=true;jQuery('div.pictureHolder .hoverContainer,div.pictureHolder .details').fadeOut(j.animationSpeed);jQuery('div.pictureHolder #fullResImageContainer').fadeOut(j.animationSpeed,function(){jQuery('.loaderIcon').show();_preload()});_hideTitle();jQuery('a.expand,a.contract').fadeOut(j.animationSpeed,function(){jQuery(this).removeClass('contract').addClass('expand')})};function close(){jQuery('div.pictureHolder,div.prettyPhotoTitle').fadeOut(j.animationSpeed,function(){jQuery('div.prettyPhotoOverlay').fadeOut(j.animationSpeed,function(){jQuery('div.prettyPhotoOverlay,div.pictureHolder,div.prettyPhotoTitle').remove();if(jQuery.browser.msie&&jQuery.browser.version==6){jQuery('select').css('visibility','visible')}})})};function _checkPosition(){if(m==l){jQuery('div.pictureHolder a.next').css('visibility','hidden');jQuery('div.pictureHolder a.arrow_next').addClass('disabled').unbind('click')}else{jQuery('div.pictureHolder a.next').css('visibility','visible');jQuery('div.pictureHolder a.arrow_next.disabled').removeClass('disabled').bind('click',function(){changePicture('next');return false})};if(m==1){jQuery('div.pictureHolder a.previous').css('visibility','hidden');jQuery('div.pictureHolder a.arrow_previous').addClass('disabled').unbind('click')}else{jQuery('div.pictureHolder a.previous').css('visibility','visible');jQuery('div.pictureHolder a.arrow_previous.disabled').removeClass('disabled').bind('click',function(){changePicture('previous');return false})};jQuery('div.pictureHolder p.currentTextHolder').text(m+j.counter_separator_label+l);(k)?jQueryc=jQuery(r[n]):jQueryc=jQuery(p);if(jQueryc.attr('title')){jQuery('div.pictureHolder .description').show().html(unescape(jQueryc.attr('title')))}else{jQuery('div.pictureHolder .description').hide().text('')};if(jQueryc.find('img').attr('alt')&&j.showTitle){o=true;jQuery('div.prettyPhotoTitle .prettyPhotoTitleContent').html(unescape(jQueryc.find('img').attr('alt')))}else{o=false}};function _fitToViewport(a,b){hasBeenResized=false;jQuery('div.pictureHolder .details').width(a);jQuery('div.pictureHolder .details p.description').width(a-parseFloat(jQuery('div.pictureHolder a.close').css('width')));contentHeight=b+parseFloat(jQuery('div.pictureHolder .details').height())+parseFloat(jQuery('div.pictureHolder .details').css('margin-top'))+parseFloat(jQuery('div.pictureHolder .details').css('margin-bottom'));contentWidth=a;containerHeight=b+parseFloat(jQuery('div.prettyPhotoTitle').height())+parseFloat(jQuery('div.pictureHolder .top').height())+parseFloat(jQuery('div.pictureHolder .bottom').height());containerWidth=a+j.padding;imageWidth=a;imageHeight=b;if(jQuery.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=jQuery(window).height();windowWidth=jQuery(window).width()};if(((containerWidth>windowWidth)||(containerHeight>windowHeight))&&q&&j.allowresize){hasBeenResized=true;if((containerWidth>windowWidth)&&(containerHeight>windowHeight)){var c=(containerWidth+200)/windowWidth;var d=(containerHeight+200)/windowHeight}else{var c=windowWidth/containerWidth;var d=windowHeight/containerHeight}if(d>c){imageWidth=Math.round(a*(1/d));imageHeight=Math.round(b*(1/d))}else{imageWidth=Math.round(a*(1/c));imageHeight=Math.round(b*(1/c))};contentHeight=imageHeight+parseFloat(jQuery('div.pictureHolder .details').height())+parseFloat(jQuery('div.pictureHolder .details').css('margin-top'))+parseFloat(jQuery('div.pictureHolder .details').css('margin-bottom'));contentWidth=imageWidth;containerHeight=imageHeight+parseFloat(jQuery('div.prettyPhotoTitle').height())+parseFloat(jQuery('div.pictureHolder .top').height())+parseFloat(jQuery('div.pictureHolder .bottom').height());containerWidth=imageWidth+j.padding;jQuery('div.pictureHolder .details').width(contentWidth);jQuery('div.pictureHolder .details p.description').width(contentWidth-parseFloat(jQuery('div.pictureHolder a.close').css('width')))};return{width:imageWidth,height:imageHeight,containerHeight:containerHeight,containerWidth:containerWidth,contentHeight:contentHeight,contentWidth:contentWidth,resized:hasBeenResized}};function _centerPicture(){if(jQuery('div.pictureHolder').size()>0){var a=_getScroll();if(jQuery.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=jQuery(window).height();windowWidth=jQuery(window).width()};if(q){projectedTop=(windowHeight/2)+a['scrollTop']-(jQuery('div.pictureHolder').height()/2);if(projectedTop<0)projectedTop=0+jQuery('div.prettyPhotoTitle').height();jQuery('div.pictureHolder').css({'top':projectedTop,'left':(windowWidth/2)+a['scrollLeft']-(jQuery('div.pictureHolder').width()/2)});jQuery('div.prettyPhotoTitle').css({'top':jQuery('div.pictureHolder').offset().top-jQuery('div.prettyPhotoTitle').height(),'left':jQuery('div.pictureHolder').offset().left+(j.padding/2)})}}};function _shownav(){if(k)jQuery('div.pictureHolder .hoverContainer').fadeIn(j.animationSpeed);jQuery('div.pictureHolder .details').fadeIn(j.animationSpeed);_showTitle()};function _showTitle(){if(j.showTitle&&o){jQuery('div.prettyPhotoTitle').css({'top':jQuery('div.pictureHolder').offset().top,'left':jQuery('div.pictureHolder').offset().left+(j.padding/2),'display':'block'});jQuery('div.prettyPhotoTitle div.prettyPhotoTitleContent').css('width','auto');if(jQuery('div.prettyPhotoTitle').width()>jQuery('div.pictureHolder').width()){jQuery('div.prettyPhotoTitle div.prettyPhotoTitleContent').css('width',jQuery('div.pictureHolder').width()-(j.padding*2))}else{jQuery('div.prettyPhotoTitle div.prettyPhotoTitleContent').css('width','')};jQuery('div.prettyPhotoTitle').animate({'top':(jQuery('div.pictureHolder').offset().top-22)},j.animationSpeed)}};function _hideTitle(){jQuery('div.prettyPhotoTitle').animate({'top':(jQuery('div.pictureHolder').offset().top)},j.animationSpeed,function(){jQuery(this).css('display','none')})};function _preload(){_checkPosition();imgPreloader=new Image();nextImage=new Image();if(k)nextImage.src=jQuery(r[n+1]).attr('href');prevImage=new Image();if(k&&r[n-1])prevImage.src=jQuery(r[n-1]).attr('href');jQuery('div.pictureHolder .content').css('overflow','hidden');if(k){jQuery('div.pictureHolder #fullResImage').attr('src',jQuery(r[n]).attr('href'))}else{jQuery('div.pictureHolder #fullResImage').attr('src',jQuery(p).attr('href'))};imgPreloader.onload=function(){var a=_fitToViewport(imgPreloader.width,imgPreloader.height);imgPreloader.width=a['width'];imgPreloader.height=a['height'];setTimeout('showimage(imgPreloader.width,imgPreloader.height,'+a["containerWidth"]+','+a["containerHeight"]+','+a["contentHeight"]+','+a["contentWidth"]+','+a["resized"]+')',500)};(k)?imgPreloader.src=jQuery(r[n]).attr('href'):imgPreloader.src=jQuery(p).attr('href')};function _getScroll(){scrollTop=window.pageYOffset||document.documentElement.scrollTop||0;scrollLeft=window.pageXOffset||document.documentElement.scrollLeft||0;return{scrollTop:scrollTop,scrollLeft:scrollLeft}};function _resizeOverlay(){jQuery('div.prettyPhotoOverlay').css({'height':jQuery(document).height(),'width':jQuery(window).width()})};function _writeFlash(){flashParams=jQuery(p).attr('rel').split(';');jQuery(flashParams).each(function(i){if(flashParams[i].indexOf('width')>=0)flashWidth=flashParams[i].substring(flashParams[i].indexOf('width')+6,flashParams[i].length);if(flashParams[i].indexOf('height')>=0)flashHeight=flashParams[i].substring(flashParams[i].indexOf('height')+7,flashParams[i].length);if(flashParams[i].indexOf('flashvars')>=0)flashVars=flashParams[i].substring(flashParams[i].indexOf('flashvars')+10,flashParams[i].length)});jQuery('.pictureHolder #fullResImageContainer').append('<embed width="'+flashWidth+'" height="'+flashHeight+'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="opaque" name="prettyFlash" flashvars="'+flashVars+'" allowscriptaccess="always" bgcolor="#FFFFFF" quality="high" src="'+jQuery(p).attr('href')+'"/>');jQuery('#fullResImage').hide();contentHeight=parseFloat(flashHeight)+parseFloat(jQuery('div.pictureHolder .details').height())+parseFloat(jQuery('div.pictureHolder .details').css('margin-top'))+parseFloat(jQuery('div.pictureHolder .details').css('margin-bottom'));contentWidth=parseFloat(flashWidth)+parseFloat(jQuery('div.pictureHolder .details').width())+parseFloat(jQuery('div.pictureHolder .details').css('margin-left'))+parseFloat(jQuery('div.pictureHolder .details').css('margin-right'));containerHeight=contentHeight+parseFloat(jQuery('div.pictureHolder .top').height())+parseFloat(jQuery('div.pictureHolder .bottom').height());containerWidth=parseFloat(flashWidth)+parseFloat(jQuery('div.pictureHolder .content').css("padding-left"))+parseFloat(jQuery('div.pictureHolder .content').css("padding-right"))+j.padding;setTimeout('showimage('+flashWidth+','+flashHeight+','+containerWidth+','+containerHeight+','+contentHeight+','+contentWidth+')',500)};function _buildOverlay(){backgroundDiv="<div class='prettyPhotoOverlay'></div>";jQuery('body').append(backgroundDiv);jQuery('div.prettyPhotoOverlay').css('height',jQuery(document).height()).bind('click',function(){close()});pictureHolder='<div class="pictureHolder"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content"><a href="#" class="expand" title="Expand the image">Expand</a><div class="loaderIcon"></div><div class="hoverContainer"><a class="next" href="#">next</a><a class="previous" href="#">previous</a></div><div id="fullResImageContainer"><img id="fullResImage" src="" /></div><div class="details clearfix"><a class="close" href="#">Close</a><p class="description"></p><div class="nav"><a href="#" class="arrow_previous">Previous</a><p class="currentTextHolder">0'+j.counter_separator_label+'0</p><a href="#" class="arrow_next">Next</a></div></div></div><div class="bottom"><div class="left"></div><div class="middle"></div><div class="right"></div></div></div>';titleHolder='<div class="prettyPhotoTitle"><div class="prettyPhotoTitleLeft"></div><div class="prettyPhotoTitleContent"></div><div class="prettyPhotoTitleRight"></div></div>';jQuery('body').append(pictureHolder).append(titleHolder);jQuery('.pictureHolder,.titleHolder').css({'opacity':0});jQuery('a.close').bind('click',function(){close();return false});jQuery('a.expand').bind('click',function(){if(jQuery(this).hasClass('expand')){jQuery(this).removeClass('expand').addClass('contract');q=false}else{jQuery(this).removeClass('contract').addClass('expand');q=true};_hideTitle();jQuery('div.pictureHolder .hoverContainer,div.pictureHolder #fullResImageContainer').fadeOut(j.animationSpeed);jQuery('div.pictureHolder .details').fadeOut(j.animationSpeed,function(){_preload()});return false});jQuery('.pictureHolder .previous,.pictureHolder .arrow_previous').bind('click',function(){changePicture('previous');return false});jQuery('.pictureHolder .next,.pictureHolder .arrow_next').bind('click',function(){changePicture('next');return false});jQuery('.hoverContainer').css({'margin-left':j.padding/2});if(!k){jQuery('.hoverContainer,.nav').hide()};if(jQuery.browser.msie&&jQuery.browser.version==6){jQuery('select').css('visibility','hidden')};jQuery('div.prettyPhotoOverlay').css('opacity',0).fadeTo(j.animationSpeed,j.opacity,function(){jQuery('div.pictureHolder').css('opacity',0).fadeIn(j.animationSpeed,function(){jQuery('div.pictureHolder').attr('style','left:'+jQuery('div.pictureHolder').css('left')+';top:'+jQuery('div.pictureHolder').css('top')+';')})})}};