(function(a){function b(a,b){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var c="[\\?&]"+a+"=([^&#]*)";var d=new RegExp(c);var e=d.exec(b);if(e==null)return"";else return e[1]}a.prettyPhoto={version:"2.5.6"};a.fn.prettyPhoto=function(c){function z(){a("body").append(c.markup);g=a(".pp_pic_holder");h=a(".ppt");i=a("div.pp_overlay");g.attr("class","pp_pic_holder "+c.theme);i.css({opacity:0,height:a(document).height()}).bind("click",function(){if(!c.modal)a.prettyPhoto.close()});a("a.pp_close").bind("click",function(){a.prettyPhoto.close();return false});a("a.pp_expand").bind("click",function(){$this=a(this);if($this.hasClass("pp_expand")){$this.removeClass("pp_expand").addClass("pp_contract");d=false}else{$this.removeClass("pp_contract").addClass("pp_expand");d=true}r(function(){a.prettyPhoto.open(images,titles,descriptions)});g.find(".pp_fade").fadeOut(c.animationSpeed);return false});g.find(".pp_previous, .pp_arrow_previous").bind("click",function(){a.prettyPhoto.changePage("previous");return false});g.find(".pp_next, .pp_arrow_next").bind("click",function(){a.prettyPhoto.changePage("next");return false})}function y(){n=a(window).height();o=a(window).width();i.css({height:a(document).height()})}function x(){if(self.pageYOffset){return{scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset}}else if(document.documentElement&&document.documentElement.scrollTop){return{scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft}}else if(document.body){return{scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft}}}function w(){if(d){titleHeight=h.height();contentHeight=g.height();contentwidth=g.width();projectedTop=n/2+q["scrollTop"]-(contentHeight+titleHeight)/2;g.css({top:projectedTop,left:o/2+q["scrollLeft"]-contentwidth/2});h.css({top:projectedTop-titleHeight,left:o/2+q["scrollLeft"]-contentwidth/2+20})}}function v(a){if(a.match(/youtube\.com\/watch/i)){return"youtube"}else if(a.match(/vimeo\.com/i)){return"vimeo"}else if(a.indexOf(".mov")!=-1){return"quicktime"}else if(a.indexOf(".swf")!=-1){return"flash"}else if(a.indexOf("iframe")!=-1){return"iframe"}else if(a.substr(0,1)=="#"){return"inline"}else{return"image"}}function u(b,c){b=parseFloat(b);c=parseFloat(c);$pp_details=g.find(".pp_details");$pp_details.width(b);detailsHeight=parseFloat($pp_details.css("marginTop"))+parseFloat($pp_details.css("marginBottom"));$pp_details=$pp_details.clone().appendTo(a("body")).css({position:"absolute",top:-1e4});detailsHeight+=$pp_details.height();detailsHeight=detailsHeight<=34?36:detailsHeight;if(a.browser.msie&&a.browser.version==7)detailsHeight+=8;$pp_details.remove();j=c+detailsHeight;k=b;l=j+h.height()+g.find(".pp_top").height()+g.find(".pp_bottom").height();m=b}function t(a,b){hasBeenResized=false;u(a,b);imageWidth=a;imageHeight=b;if((m>o||l>n)&&d&&c.allowresize&&!e){hasBeenResized=true;notFitting=true;while(notFitting){if(m>o){imageWidth=o-200;imageHeight=b/a*imageWidth}else if(l>n){imageHeight=n-200;imageWidth=a/b*imageHeight}else{notFitting=false}l=imageHeight;m=imageWidth}u(imageWidth,imageHeight)}return{width:Math.floor(imageWidth),height:Math.floor(imageHeight),containerHeight:Math.floor(l),containerWidth:Math.floor(m)+40,contentHeight:Math.floor(j),contentWidth:Math.floor(k),resized:hasBeenResized}}function s(b){if(p==b-1){g.find("a.pp_next").css("visibility","hidden");g.find("a.pp_arrow_next").addClass("disabled").unbind("click")}else{g.find("a.pp_next").css("visibility","visible");g.find("a.pp_arrow_next.disabled").removeClass("disabled").bind("click",function(){a.prettyPhoto.changePage("next");return false})}if(p==0){g.find("a.pp_previous").css("visibility","hidden");g.find("a.pp_arrow_previous").addClass("disabled").unbind("click")}else{g.find("a.pp_previous").css("visibility","visible");g.find("a.pp_arrow_previous.disabled").removeClass("disabled").bind("click",function(){a.prettyPhoto.changePage("previous");return false})}if(b>1){a(".pp_nav").show()}else{a(".pp_nav").hide()}}function r(b){g.find("#pp_full_res object,#pp_full_res embed").css("visibility","hidden");g.find(".pp_fade").fadeOut(c.animationSpeed,function(){a(".pp_loaderIcon").show();if(b)b()});h.fadeOut(c.animationSpeed)}c=jQuery.extend({animationSpeed:"normal",opacity:.8,showTitle:true,allowresize:true,default_width:500,default_height:344,counter_separator_label:"/",theme:"light_rounded",hideflash:false,wmode:"opaque",autoplay:true,modal:false,changepicturecallback:function(){},callback:function(){},markup:'<div class="pp_pic_holder"> \n      <div class="pp_top"> \n       <div class="pp_left"></div> \n       <div class="pp_middle"></div> \n       <div class="pp_right"></div> \n      </div> \n      <div class="pp_content_container"> \n       <div class="pp_left"> \n       <div class="pp_right"> \n        <div class="pp_content"> \n         <div class="pp_loaderIcon"></div> \n         <div class="pp_fade"> \n          <a href="#" class="pp_expand" title="Expand the image">Expand</a> \n          <div class="pp_hoverContainer"> \n           <a class="pp_next" href="#">next</a> \n           <a class="pp_previous" href="#">previous</a> \n          </div> \n          <div id="pp_full_res"></div> \n          <div class="pp_details clearfix"> \n           <a class="pp_close" href="#">Close</a> \n           <p class="pp_description"></p> \n           <div class="pp_nav"> \n            <a href="#" class="pp_arrow_previous">Previous</a> \n            <p class="currentTextHolder">0/0</p> \n            <a href="#" class="pp_arrow_next">Next</a> \n           </div> \n          </div> \n         </div> \n        </div> \n       </div> \n       </div> \n      </div> \n      <div class="pp_bottom"> \n       <div class="pp_left"></div> \n       <div class="pp_middle"></div> \n       <div class="pp_right"></div> \n      </div> \n     </div> \n     <div class="pp_overlay"></div> \n     <div class="ppt"></div>',image_markup:'<img id="fullResImage" src="" />',flash_markup:'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',quicktime_markup:'<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',iframe_markup:'<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',inline_markup:'<div class="pp_inline clearfix">{content}</div>'},c);if(a.browser.msie&&parseInt(a.browser.version)==6){c.theme="light_square"}if(a(".pp_overlay").size()==0)z();var d=true,e=false,f,g,h,i,j,k,l,m,n=a(window).height(),o=a(window).width(),p=0,q=x();a(window).scroll(function(){q=x();w();y()});a(window).resize(function(){w();y()});a(document).keydown(function(b){if(g.is(":visible"))switch(b.keyCode){case 37:a.prettyPhoto.changePage("previous");break;case 39:a.prettyPhoto.changePage("next");break;case 27:if(!c.modal)a.prettyPhoto.close();break}});a(this).each(function(){a(this).bind("click",function(){_self=this;theRel=a(this).attr("rel");galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);var b=new Array,c=new Array,d=new Array;if(theGallery){a("a[rel*="+theGallery+"]").each(function(e){if(a(this)[0]===a(_self)[0])p=e;b.push(a(this).attr("href"));c.push(a(this).find("img").attr("alt"));d.push(a(this).attr("title"))})}else{b=a(this).attr("href");c=a(this).find("img").attr("alt")?a(this).find("img").attr("alt"):"";d=a(this).attr("title")?a(this).attr("title"):""}a.prettyPhoto.open(b,c,d);return false})});a.prettyPhoto.open=function(d,j,k){if(a.browser.msie&&a.browser.version==6){a("select").css("visibility","hidden")}if(c.hideflash)a("object,embed").css("visibility","hidden");images=a.makeArray(d);titles=a.makeArray(j);descriptions=a.makeArray(k);image_set=a(images).size()>0?true:false;s(a(images).size());a(".pp_loaderIcon").show();i.show().fadeTo(c.animationSpeed,c.opacity);g.find(".currentTextHolder").text(p+1+c.counter_separator_label+a(images).size());if(descriptions[p]){g.find(".pp_description").show().html(unescape(descriptions[p]))}else{g.find(".pp_description").hide().text("")}if(titles[p]&&c.showTitle){hasTitle=true;h.html(unescape(titles[p]))}else{hasTitle=false}movie_width=parseFloat(b("width",images[p]))?b("width",images[p]):c.default_width.toString();movie_height=parseFloat(b("height",images[p]))?b("height",images[p]):c.default_height.toString();if(movie_width.indexOf("%")!=-1||movie_height.indexOf("%")!=-1){movie_height=parseFloat(a(window).height()*parseFloat(movie_height)/100-100);movie_width=parseFloat(a(window).width()*parseFloat(movie_width)/100-100);e=true}g.fadeIn(function(){imgPreloader="";switch(v(images[p])){case"image":imgPreloader=new Image;nextImage=new Image;if(image_set&&p>a(images).size())nextImage.src=images[p+1];prevImage=new Image;if(image_set&&images[p-1])prevImage.src=images[p-1];g.find("#pp_full_res")[0].innerHTML=c.image_markup;g.find("#fullResImage").attr("src",images[p]);imgPreloader.onload=function(){f=t(imgPreloader.width,imgPreloader.height);_showContent()};imgPreloader.onerror=function(){alert("Image cannot be loaded. Make sure the path is correct and image exist.");a.prettyPhoto.close()};imgPreloader.src=images[p];break;case"youtube":f=t(movie_width,movie_height);movie="http://www.youtube.com/v/"+b("v",images[p]);if(c.autoplay)movie+="&autoplay=1";toInject=c.flash_markup.replace(/{width}/g,f["width"]).replace(/{height}/g,f["height"]).replace(/{wmode}/g,c.wmode).replace(/{path}/g,movie);break;case"vimeo":f=t(movie_width,movie_height);movie_id=images[p];movie="http://vimeo.com/moogaloop.swf?clip_id="+movie_id.replace("http://vimeo.com/","");if(c.autoplay)movie+="&autoplay=1";toInject=c.flash_markup.replace(/{width}/g,f["width"]).replace(/{height}/g,f["height"]).replace(/{wmode}/g,c.wmode).replace(/{path}/g,movie);break;case"quicktime":f=t(movie_width,movie_height);f["height"]+=15;f["contentHeight"]+=15;f["containerHeight"]+=15;toInject=c.quicktime_markup.replace(/{width}/g,f["width"]).replace(/{height}/g,f["height"]).replace(/{wmode}/g,c.wmode).replace(/{path}/g,images[p]).replace(/{autoplay}/g,c.autoplay);break;case"flash":f=t(movie_width,movie_height);flash_vars=images[p];flash_vars=flash_vars.substring(images[p].indexOf("flashvars")+10,images[p].length);filename=images[p];filename=filename.substring(0,filename.indexOf("?"));toInject=c.flash_markup.replace(/{width}/g,f["width"]).replace(/{height}/g,f["height"]).replace(/{wmode}/g,c.wmode).replace(/{path}/g,filename+"?"+flash_vars);break;case"iframe":f=t(movie_width,movie_height);frame_url=images[p];frame_url=frame_url.substr(0,frame_url.indexOf("iframe")-1);toInject=c.iframe_markup.replace(/{width}/g,f["width"]).replace(/{height}/g,f["height"]).replace(/{path}/g,frame_url);break;case"inline":myClone=a(images[p]).clone().css({width:c.default_width}).wrapInner('<div id="pp_full_res"><div class="pp_inline clearfix"></div></div>').appendTo(a("body"));f=t(a(myClone).width(),a(myClone).height());a(myClone).remove();toInject=c.inline_markup.replace(/{content}/g,a(images[p]).html());break}if(!imgPreloader){g.find("#pp_full_res")[0].innerHTML=toInject;_showContent()}})};a.prettyPhoto.changePage=function(b){if(b=="previous"){p--;if(p<0){p=0;return}}else{if(a(".pp_arrow_next").is(".disabled"))return;p++}if(!d)d=true;r(function(){a.prettyPhoto.open(images,titles,descriptions)});a("a.pp_expand,a.pp_contract").fadeOut(c.animationSpeed)};a.prettyPhoto.close=function(){g.find("object,embed").css("visibility","hidden");a("div.pp_pic_holder,div.ppt,.pp_fade").fadeOut(c.animationSpeed);i.fadeOut(c.animationSpeed,function(){a("#pp_full_res").html("");g.attr("style","").find("div:not(.pp_hoverContainer)").attr("style","");w();if(a.browser.msie&&a.browser.version==6){a("select").css("visibility","visible")}if(c.hideflash)a("object,embed").css("visibility","visible");p=0;c.callback()});d=true};_showContent=function(){a(".pp_loaderIcon").hide();projectedTop=q["scrollTop"]+(n/2-f["containerHeight"]/2);if(projectedTop<0)projectedTop=0+h.height();g.find(".pp_content").animate({height:f["contentHeight"]},c.animationSpeed);g.animate({top:projectedTop,left:o/2-f["containerWidth"]/2,width:f["containerWidth"]},c.animationSpeed,function(){g.find(".pp_hoverContainer,#fullResImage").height(f["height"]).width(f["width"]);g.find(".pp_fade").fadeIn(c.animationSpeed);if(image_set&&v(images[p])=="image"){g.find(".pp_hoverContainer").show()}else{g.find(".pp_hoverContainer").hide()}if(c.showTitle&&hasTitle){h.css({top:g.offset().top-25,left:g.offset().left+20,display:"none"});h.fadeIn(c.animationSpeed)}if(f["resized"])a("a.pp_expand,a.pp_contract").fadeIn(c.animationSpeed);c.changepicturecallback()})};w()}})(jQuery)
