(function(a){a.prettyPhoto={version:"2.5.6"};a.fn.prettyPhoto=function(c){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">       <div class="pp_top">        <div class="pp_left"></div>        <div class="pp_middle"></div>        <div class="pp_right"></div>       </div>       <div class="pp_content_container">        <div class="pp_left">        <div class="pp_right">         <div class="pp_content">          <div class="pp_loaderIcon"></div>          <div class="pp_fade">           <a href="#" class="pp_expand" title="Expand the image">Expand</a>           <div class="pp_hoverContainer">            <a class="pp_next" href="#">next</a>            <a class="pp_previous" href="#">previous</a>           </div>           <div id="pp_full_res"></div>           <div class="pp_details clearfix">            <a class="pp_close" href="#">Close</a>            <p class="pp_description"></p>            <div class="pp_nav">             <a href="#" class="pp_arrow_previous">Previous</a>             <p class="currentTextHolder">0/0</p>             <a href="#" class="pp_arrow_next">Next</a>            </div>           </div>          </div>         </div>        </div>        </div>       </div>       <div class="pp_bottom">        <div class="pp_left"></div>        <div class="pp_middle"></div>        <div class="pp_right"></div>       </div>      </div>      <div class="pp_overlay"></div>      <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";a(".pp_overlay").size()==0&&z();var j=true,u=false,f,d,g,n,q,r,l,m,k=a(window).height(),i=a(window).width(),e=0,o=x();a(window).scroll(function(){o=x();p();t()});a(window).resize(function(){p();t()});a(document).keydown(function(b){if(d.is(":visible"))switch(b.keyCode){case 37:a.prettyPhoto.changePage("previous");break;case 39:a.prettyPhoto.changePage("next");break;case 27:!c.modal&&a.prettyPhoto.close()}});a(this).each(function(){a(this).bind("click",function(){_self=this;theRel=a(this).attr("rel");galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);var c=[],d=[],b=[];if(theGallery)a("a[rel*="+theGallery+"]").each(function(f){if(a(this)[0]===a(_self)[0])e=f;c.push(a(this).attr("href"));d.push(a(this).find("img").attr("alt"));b.push(a(this).attr("title"))});else{c=a(this).attr("href");d=a(this).find("img").attr("alt")?a(this).find("img").attr("alt"):"";b=a(this).attr("title")?a(this).attr("title"):""}a.prettyPhoto.open(c,d,b);return false})});a.prettyPhoto.open=function(j,k,i){a.browser.msie&&a.browser.version==6&&a("select").css("visibility","hidden");c.hideflash&&a("object,embed").css("visibility","hidden");images=a.makeArray(j);titles=a.makeArray(k);descriptions=a.makeArray(i);image_set=a(images).size()>0?true:false;y(a(images).size());a(".pp_loaderIcon").show();n.show().fadeTo(c.animationSpeed,c.opacity);d.find(".currentTextHolder").text(e+1+c.counter_separator_label+a(images).size());if(descriptions[e])d.find(".pp_description").show().html(unescape(descriptions[e]));else d.find(".pp_description").hide().text("");if(titles[e]&&c.showTitle){hasTitle=true;g.html(unescape(titles[e]))}else hasTitle=false;movie_width=parseFloat(b("width",images[e]))?b("width",images[e]):c.default_width.toString();movie_height=parseFloat(b("height",images[e]))?b("height",images[e]):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);u=true}d.fadeIn(function(){imgPreloader="";switch(v(images[e])){case"image":imgPreloader=new Image;nextImage=new Image;if(image_set&&e>a(images).size())nextImage.src=images[e+1];prevImage=new Image;if(image_set&&images[e-1])prevImage.src=images[e-1];d.find("#pp_full_res")[0].innerHTML=c.image_markup;d.find("#fullResImage").attr("src",images[e]);imgPreloader.onload=function(){f=h(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[e];break;case"youtube":f=h(movie_width,movie_height);movie="http://www.youtube.com/v/"+b("v",images[e]);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=h(movie_width,movie_height);movie_id=images[e];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=h(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[e]).replace(/{autoplay}/g,c.autoplay);break;case"flash":f=h(movie_width,movie_height);flash_vars=images[e];flash_vars=flash_vars.substring(images[e].indexOf("flashvars")+10,images[e].length);filename=images[e];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=h(movie_width,movie_height);frame_url=images[e];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[e]).clone().css({width:c.default_width}).wrapInner('<div id="pp_full_res"><div class="pp_inline clearfix"></div></div>').appendTo(a("body"));f=h(a(myClone).width(),a(myClone).height());a(myClone).remove();toInject=c.inline_markup.replace(/{content}/g,a(images[e]).html())}if(!imgPreloader){d.find("#pp_full_res")[0].innerHTML=toInject;_showContent()}})};a.prettyPhoto.changePage=function(b){if(b=="previous"){e--;if(e<0){e=0;return}}else{if(a(".pp_arrow_next").is(".disabled"))return;e++}if(!j)j=true;w(function(){a.prettyPhoto.open(images,titles,descriptions)});a("a.pp_expand,a.pp_contract").fadeOut(c.animationSpeed)};a.prettyPhoto.close=function(){d.find("object,embed").css("visibility","hidden");a("div.pp_pic_holder,div.ppt,.pp_fade").fadeOut(c.animationSpeed);n.fadeOut(c.animationSpeed,function(){a("#pp_full_res").html("");d.attr("style","").find("div:not(.pp_hoverContainer)").attr("style","");p();a.browser.msie&&a.browser.version==6&&a("select").css("visibility","visible");c.hideflash&&a("object,embed").css("visibility","visible");e=0;c.callback()});j=true};_showContent=function(){a(".pp_loaderIcon").hide();projectedTop=o.scrollTop+(k/2-f.containerHeight/2);if(projectedTop<0)projectedTop=0+g.height();d.find(".pp_content").animate({height:f.contentHeight},c.animationSpeed);d.animate({top:projectedTop,left:i/2-f.containerWidth/2,width:f.containerWidth},c.animationSpeed,function(){d.find(".pp_hoverContainer,#fullResImage").height(f.height).width(f.width);d.find(".pp_fade").fadeIn(c.animationSpeed);if(image_set&&v(images[e])=="image")d.find(".pp_hoverContainer").show();else d.find(".pp_hoverContainer").hide();if(c.showTitle&&hasTitle){g.css({top:d.offset().top-25,left:d.offset().left+20,display:"none"});g.fadeIn(c.animationSpeed)}f.resized&&a("a.pp_expand,a.pp_contract").fadeIn(c.animationSpeed);c.changepicturecallback()})};function w(b){d.find("#pp_full_res object,#pp_full_res embed").css("visibility","hidden");d.find(".pp_fade").fadeOut(c.animationSpeed,function(){a(".pp_loaderIcon").show();b&&b()});g.fadeOut(c.animationSpeed)}function y(b){if(e==b-1){d.find("a.pp_next").css("visibility","hidden");d.find("a.pp_arrow_next").addClass("disabled").unbind("click")}else{d.find("a.pp_next").css("visibility","visible");d.find("a.pp_arrow_next.disabled").removeClass("disabled").bind("click",function(){a.prettyPhoto.changePage("next");return false})}if(e==0){d.find("a.pp_previous").css("visibility","hidden");d.find("a.pp_arrow_previous").addClass("disabled").unbind("click")}else{d.find("a.pp_previous").css("visibility","visible");d.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 h(b,a){hasBeenResized=false;s(b,a);imageWidth=b;imageHeight=a;if((m>i||l>k)&&j&&c.allowresize&&!u){hasBeenResized=true;notFitting=true;while(notFitting){if(m>i){imageWidth=i-200;imageHeight=a/b*imageWidth}else if(l>k){imageHeight=k-200;imageWidth=b/a*imageHeight}else notFitting=false;l=imageHeight;m=imageWidth}s(imageWidth,imageHeight)}return{width:Math.floor(imageWidth),height:Math.floor(imageHeight),containerHeight:Math.floor(l),containerWidth:Math.floor(m)+40,contentHeight:Math.floor(q),contentWidth:Math.floor(r),resized:hasBeenResized}}function s(b,c){b=parseFloat(b);c=parseFloat(c);$pp_details=d.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();q=c+detailsHeight;r=b;l=q+g.height()+d.find(".pp_top").height()+d.find(".pp_bottom").height();m=b}function v(a){return a.match(/youtube\.com\/watch/i)?"youtube":a.match(/vimeo\.com/i)?"vimeo":a.indexOf(".mov")!=-1?"quicktime":a.indexOf(".swf")!=-1?"flash":a.indexOf("iframe")!=-1?"iframe":a.substr(0,1)=="#"?"inline":"image"}function p(){if(j){titleHeight=g.height();contentHeight=d.height();contentwidth=d.width();projectedTop=k/2+o.scrollTop-(contentHeight+titleHeight)/2;d.css({top:projectedTop,left:i/2+o.scrollLeft-contentwidth/2});g.css({top:projectedTop-titleHeight,left:i/2+o.scrollLeft-contentwidth/2+20})}}function x(){return self.pageYOffset?{scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset}:document.documentElement&&document.documentElement.scrollTop?{scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft}:document.body?{scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft}:void 0}function t(){k=a(window).height();i=a(window).width();n.css({height:a(document).height()})}function z(){a("body").append(c.markup);d=a(".pp_pic_holder");g=a(".ppt");n=a("div.pp_overlay");d.attr("class","pp_pic_holder "+c.theme);n.css({opacity:0,height:a(document).height()}).bind("click",function(){!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");j=false}else{$this.removeClass("pp_contract").addClass("pp_expand");j=true}w(function(){a.prettyPhoto.open(images,titles,descriptions)});d.find(".pp_fade").fadeOut(c.animationSpeed);return false});d.find(".pp_previous, .pp_arrow_previous").bind("click",function(){a.prettyPhoto.changePage("previous");return false});d.find(".pp_next, .pp_arrow_next").bind("click",function(){a.prettyPhoto.changePage("next");return false})}p()};function b(a,e){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var c="[\\?&]"+a+"=([^&#]*)",d=new RegExp(c),b=d.exec(e);return b==null?"":b[1]}})(jQuery)
