(function(a){function j(e,m){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var n=RegExp("[\\?&]"+e+"=([^&#]*)").exec(m);return n==null?"":n[1]}a.prettyPhoto={version:"3.0"};$pp_overlay=$pp_pic_holder=undefined;a.fn.prettyPhoto=function(e){function m(b){$pp_pic_holder.find("#pp_full_res object,#pp_full_res embed").css("visibility","hidden");$pp_pic_holder.find(".pp_fade").fadeOut(settings.animationSpeed,function(){a(".pp_loaderIcon").show();b()})}function n(b){if(setPosition==b-1){$pp_pic_holder.find("a.pp_next").css("visibility", "hidden");$pp_pic_holder.find(".pp_nav a.pp_arrow_next").addClass("disabled").unbind("click")}else{$pp_pic_holder.find("a.pp_next").css("visibility","visible");$pp_pic_holder.find(".pp_nav a.pp_arrow_next.disabled").removeClass("disabled").bind("click",function(){a.prettyPhoto.changePage("next");return false})}if(setPosition==0){$pp_pic_holder.find("a.pp_previous").css("visibility","hidden");$pp_pic_holder.find(".pp_nav a.pp_arrow_previous").addClass("disabled").unbind("click")}else{$pp_pic_holder.find("a.pp_previous").css("visibility", "visible");$pp_pic_holder.find(".pp_nav a.pp_arrow_previous.disabled").removeClass("disabled").bind("click",function(){a.prettyPhoto.changePage("previous");return false})}b>1?a(".pp_nav").show():a(".pp_nav").hide()}function f(b,d){resized=false;s(b,d);imageWidth=b;imageHeight=d;if((k>h||l>i)&&doresize&&settings.allowresize&&!t){resized=true;for(fitting=false;!fitting;){if(k>h){imageWidth=h-200;imageHeight=d/b*imageWidth}else if(l>i){imageHeight=i-200;imageWidth=b/d*imageHeight}else fitting=true;l= imageHeight;k=imageWidth}s(imageWidth,imageHeight)}return{width:Math.floor(imageWidth),height:Math.floor(imageHeight),containerHeight:Math.floor(l),containerWidth:Math.floor(k)+40,contentHeight:Math.floor(p),contentWidth:Math.floor(u),resized:resized}}function s(b,d){b=parseFloat(b);d=parseFloat(d);$pp_details=$pp_pic_holder.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:-10000});detailsHeight+=$pp_details.height();detailsHeight=detailsHeight<=34?36:detailsHeight;if(a.browser.msie&&a.browser.version==7)detailsHeight+=8;$pp_details.remove();p=d+detailsHeight;u=b;l=p+$ppt.height()+$pp_pic_holder.find(".pp_top").height()+$pp_pic_holder.find(".pp_bottom").height();k=b}function o(b){if(!b)return"image";return b.match(/youtube\.com\/watch/i)?"youtube":b.match(/vimeo\.com/i)?"vimeo":b.indexOf(".mov")!=-1?"quicktime":b.indexOf(".swf")!=-1?"flash":b.indexOf("iframe")!= -1?"iframe":b.substr(0,1)=="#"?"inline":"image"}function q(){if(doresize&&typeof $pp_pic_holder!="undefined"){titleHeight=$ppt.height();contentHeight=$pp_pic_holder.height();contentwidth=$pp_pic_holder.width();projectedTop=i/2+scrollPos.scrollTop-contentHeight/2;$pp_pic_holder.css({top:projectedTop,left:h/2+scrollPos.scrollLeft-contentwidth/2})}}function v(){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(b){theRel=a(b).attr("rel");galleryRegExp=/\[(?:.*)\]/;pp_images=(isSet=galleryRegExp.exec(theRel)?true:false)?jQuery.map(r,function(d){if(a(d).attr("rel").indexOf(theRel)!=-1)return a(d).attr("href")}):a.makeArray(a(b).attr("href"));pp_titles=isSet?jQuery.map(r,function(d){if(a(d).attr("rel").indexOf(theRel)!=-1)return a(d).find("img").attr("alt")? a(d).find("img").attr("alt"):""}):a.makeArray(a(b).find("img").attr("alt"));pp_descriptions=isSet?jQuery.map(r,function(d){if(a(d).attr("rel").indexOf(theRel)!=-1)return a(d).attr("title")?a(d).attr("title"):""}):a.makeArray(a(b).attr("title"));a(".pp_pic_holder").length==0&&a("body").append(settings.markup);$pp_pic_holder=a(".pp_pic_holder");$ppt=a(".ppt");$pp_overlay=a("div.pp_overlay");if(isSet&&settings.overlay_gallery){currentGalleryPage=0;toInject="";for(b=0;b<pp_images.length;b++){pp_images[b]= pp_images[b].toLowerCase();classname=/(.*?).(jpg|jpeg|png|gif)$/.exec(pp_images[b])?"":"default";toInject+="<li class='"+classname+"'><a href='#'><img src='"+pp_images[b]+"' width='50' alt='' /></a></li>"}toInject=settings.gallery_markup.replace(/{gallery}/g,toInject);$pp_pic_holder.find("#pp_full_res").after(toInject);$pp_pic_holder.find(".pp_gallery .pp_arrow_next").click(function(){a.prettyPhoto.changeGalleryPage("next");a.prettyPhoto.stopSlideshow();return false});$pp_pic_holder.find(".pp_gallery .pp_arrow_previous").click(function(){a.prettyPhoto.changeGalleryPage("previous"); a.prettyPhoto.stopSlideshow();return false});$pp_pic_holder.find(".pp_content").hover(function(){$pp_pic_holder.find(".pp_gallery").fadeIn()},function(){$pp_pic_holder.find(".pp_gallery").fadeOut()});itemWidth=57;$pp_pic_holder.find(".pp_gallery ul li").each(function(d){a(this).css({position:"absolute",left:d*itemWidth});a(this).find("a").unbind("click").click(function(){a.prettyPhoto.changePage(d);a.prettyPhoto.stopSlideshow();return false})})}if(settings.slideshow){$pp_pic_holder.find(".pp_nav").prepend('<a href="#" class="pp_play">Play</a>'); $pp_pic_holder.find(".pp_nav .pp_play").click(function(){a.prettyPhoto.startSlideshow();return false})}$pp_pic_holder.attr("class","pp_pic_holder "+settings.theme);$pp_overlay.css({opacity:0,height:a(document).height(),width:a(document).width()}).bind("click",function(){settings.modal||a.prettyPhoto.close()});a("a.pp_close").bind("click",function(){a.prettyPhoto.close();return false});a("a.pp_expand").bind("click",function(){if(a(this).hasClass("pp_expand")){a(this).removeClass("pp_expand").addClass("pp_contract"); doresize=false}else{a(this).removeClass("pp_contract").addClass("pp_expand");doresize=true}m(function(){a.prettyPhoto.open()});return false});$pp_pic_holder.find(".pp_previous, .pp_nav .pp_arrow_previous").bind("click",function(){a.prettyPhoto.changePage("previous");a.prettyPhoto.stopSlideshow();return false});$pp_pic_holder.find(".pp_next, .pp_nav .pp_arrow_next").bind("click",function(){a.prettyPhoto.changePage("next");a.prettyPhoto.stopSlideshow();return false});q()}e=jQuery.extend({animationSpeed:"fast", slideshow:false,autoplay_slideshow:false,opacity:0.8,showTitle:true,allowresize:true,default_width:500,default_height:344,counter_separator_label:"/",theme:"facebook",hideflash:false,wmode:"opaque",autoplay:true,modal:false,overlay_gallery:true,changepicturecallback:function(){},callback:function(){},markup:'<div class="pp_pic_holder"> <div class="ppt">&nbsp;</div> <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>', gallery_markup:'<div class="pp_gallery"> <a href="#" class="pp_arrow_previous">Previous</a> <ul> {gallery} </ul> <a href="#" class="pp_arrow_next">Next</a> </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>'},e);var r=this,t=false,c,p,u,l,k,i=a(window).height(),h=a(window).width(),g;doresize=true;scrollPos=v();a(window).unbind("scroll").scroll(function(){scrollPos=v();q()});a(window).unbind("resize").resize(function(){q();i=a(window).height();h=a(window).width();typeof $pp_overlay!="undefined"&&$pp_overlay.height(a(document).height())});a(document).unbind("keydown").keydown(function(b){if(typeof $pp_pic_holder!="undefined")if($pp_pic_holder.is(":visible")){switch(b.keyCode){case 37:a.prettyPhoto.changePage("previous"); break;case 39:a.prettyPhoto.changePage("next");break;case 27:settings.modal||a.prettyPhoto.close();break}return false}});a.prettyPhoto.initialize=function(){settings=e;if(a.browser.msie&&parseInt(a.browser.version)==6)settings.theme="light_square";w(this);setItem=o(a(this).attr("href"))!="youtube"?a(this).attr("href").toLowerCase():a(this).attr("href");setPosition=jQuery.inArray(setItem,pp_images);a.prettyPhoto.open();return false};a.prettyPhoto.open=function(b,d,x){if(typeof settings=="undefined"){settings= e;w(this);pp_images=a.makeArray(b);pp_titles=d?a.makeArray(d):a.makeArray("");pp_descriptions=x?a.makeArray(x):a.makeArray("");isSet=pp_images.length>1?true:false;setPosition=0}a.browser.msie&&a.browser.version==6&&a("select").css("visibility","hidden");settings.hideflash&&a("object,embed").css("visibility","hidden");n(a(pp_images).size());a(".pp_loaderIcon").show();$ppt.is(":hidden")&&$ppt.css("opacity",0).show();$pp_overlay.show().fadeTo(settings.animationSpeed,settings.opacity);$pp_pic_holder.find(".currentTextHolder").text(setPosition+ 1+settings.counter_separator_label+a(pp_images).size());$pp_pic_holder.find(".pp_description").show().html(unescape(pp_descriptions[setPosition]));settings.showTitle&&pp_titles[setPosition]!=""?$ppt.html(unescape(pp_titles[setPosition])):$ppt.html("&nbsp;");movie_width=parseFloat(j("width",pp_images[setPosition]))?j("width",pp_images[setPosition]):settings.default_width.toString();movie_height=parseFloat(j("height",pp_images[setPosition]))?j("height",pp_images[setPosition]):settings.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);t=true}$pp_pic_holder.fadeIn(function(){imgPreloader="";switch(o(pp_images[setPosition])){case "image":imgPreloader=new Image;nextImage=new Image;if(isSet&&setPosition>a(pp_images).size())nextImage.src=pp_images[setPosition+1];prevImage=new Image;if(isSet&&pp_images[setPosition-1])prevImage.src= pp_images[setPosition-1];$pp_pic_holder.find("#pp_full_res")[0].innerHTML=settings.image_markup;$pp_pic_holder.find("#fullResImage").attr("src",pp_images[setPosition]);imgPreloader.onload=function(){c=f(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=pp_images[setPosition];break;case "youtube":c=f(movie_width,movie_height);movie="http://www.youtube.com/v/"+ j("v",pp_images[setPosition]);if(settings.autoplay)movie+="&autoplay=1";toInject=settings.flash_markup.replace(/{width}/g,c.width).replace(/{height}/g,c.height).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie);break;case "vimeo":c=f(movie_width,movie_height);movie_id=pp_images[setPosition];movie="http://vimeo.com/moogaloop.swf?clip_id="+movie_id.replace("http://vimeo.com/","");if(settings.autoplay)movie+="&autoplay=1";toInject=settings.flash_markup.replace(/{width}/g,c.width).replace(/{height}/g, c.height).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie);break;case "quicktime":c=f(movie_width,movie_height);c.height+=15;c.contentHeight+=15;c.containerHeight+=15;toInject=settings.quicktime_markup.replace(/{width}/g,c.width).replace(/{height}/g,c.height).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,pp_images[setPosition]).replace(/{autoplay}/g,settings.autoplay);break;case "flash":c=f(movie_width,movie_height);flash_vars=pp_images[setPosition];flash_vars=flash_vars.substring(pp_images[setPosition].indexOf("flashvars")+ 10,pp_images[setPosition].length);filename=pp_images[setPosition];filename=filename.substring(0,filename.indexOf("?"));toInject=settings.flash_markup.replace(/{width}/g,c.width).replace(/{height}/g,c.height).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,filename+"?"+flash_vars);break;case "iframe":c=f(movie_width,movie_height);frame_url=pp_images[setPosition];frame_url=frame_url.substr(0,frame_url.indexOf("iframe")-1);toInject=settings.iframe_markup.replace(/{width}/g,c.width).replace(/{height}/g, c.height).replace(/{path}/g,frame_url);break;case "inline":myClone=a(pp_images[setPosition]).clone().css({width:settings.default_width}).wrapInner('<div id="pp_full_res"><div class="pp_inline clearfix"></div></div>').appendTo(a("body"));c=f(a(myClone).width(),a(myClone).height());a(myClone).remove();toInject=settings.inline_markup.replace(/{content}/g,a(pp_images[setPosition]).html());break}if(!imgPreloader){$pp_pic_holder.find("#pp_full_res")[0].innerHTML=toInject;_showContent()}});return false}; a.prettyPhoto.changePage=function(b){currentGalleryPage=0;if(b=="previous"){setPosition--;if(setPosition<0){setPosition=0;return}}else if(b=="next"){if(g&&a(".pp_arrow_next").is(".disabled"))setPosition=-1;else if(a(".pp_arrow_next").is(".disabled"))return;setPosition++}else setPosition=b;doresize||(doresize=true);m(function(){a.prettyPhoto.open()})};a.prettyPhoto.changeGalleryPage=function(b){if(b=="next"){currentGalleryPage++;if(currentGalleryPage>totalPage)currentGalleryPage=0}else if(b=="previous"){currentGalleryPage--; if(currentGalleryPage<0)currentGalleryPage=totalPage}$pp_pic_holder.find(".pp_gallery li").each(function(d){a(this).animate({left:d*itemWidth-itemsPerPage*itemWidth*currentGalleryPage})})};a.prettyPhoto.startSlideshow=function(){typeof g=="undefined"?$pp_pic_holder.find(".pp_play").unbind("click").removeClass("pp_play").addClass("pp_pause").click(function(){a.prettyPhoto.stopSlideshow();return false}):a.prettyPhoto.changePage("next");g=setTimeout(a.prettyPhoto.startSlideshow,settings.slideshow)}; a.prettyPhoto.stopSlideshow=function(){$pp_pic_holder.find(".pp_pause").unbind("click").removeClass("pp_pause").addClass("pp_play").click(function(){a.prettyPhoto.startSlideshow();return false});clearTimeout(g)};a.prettyPhoto.close=function(){clearTimeout(g);$pp_pic_holder.find("object,embed").css("visibility","hidden");a("div.pp_pic_holder,div.ppt,.pp_fade").fadeOut(settings.animationSpeed,function(){a(this).remove()});$pp_overlay.fadeOut(settings.animationSpeed,function(){a.browser.msie&&a.browser.version== 6&&a("select").css("visibility","visible");settings.hideflash&&a("object,embed").css("visibility","visible");a(this).remove();settings.callback();doresize=true;delete settings})};_showContent=function(){a(".pp_loaderIcon").hide();$ppt.fadeTo(settings.animationSpeed,1);projectedTop=scrollPos.scrollTop+(i/2-c.containerHeight/2);if(projectedTop<0)projectedTop=0;$pp_pic_holder.find(".pp_content").animate({height:c.contentHeight},settings.animationSpeed);$pp_pic_holder.animate({top:projectedTop,left:h/ 2-c.containerWidth/2,width:c.containerWidth},settings.animationSpeed,function(){$pp_pic_holder.find(".pp_hoverContainer,#fullResImage").height(c.height).width(c.width);$pp_pic_holder.find(".pp_fade").fadeIn(settings.animationSpeed);isSet&&o(pp_images[setPosition])=="image"?$pp_pic_holder.find(".pp_hoverContainer").show():$pp_pic_holder.find(".pp_hoverContainer").hide();c.resized&&a("a.pp_expand,a.pp_contract").fadeIn(settings.animationSpeed);settings.changepicturecallback()});if(isSet&&settings.overlay_gallery&& o(pp_images[setPosition])=="image"){itemWidth=57;navWidth=settings.theme=="facebook"?58:38;itemsPerPage=Math.floor((c.containerWidth-100-navWidth)/itemWidth);itemsPerPage=itemsPerPage<pp_images.length?itemsPerPage:pp_images.length;totalPage=Math.ceil(pp_images.length/itemsPerPage)-1;if(totalPage==0){navWidth=0;$pp_pic_holder.find(".pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous").hide()}else{navWidth=settings.theme=="facebook"?58:38;$pp_pic_holder.find(".pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous").show()}galleryWidth= itemsPerPage*itemWidth+navWidth;$pp_pic_holder.find(".pp_gallery").width(galleryWidth).css("margin-left",-(galleryWidth/2));$pp_pic_holder.find(".pp_gallery ul").width(itemsPerPage*itemWidth);$pp_pic_holder.find(".pp_gallery ul li").each(function(b){a(this).css({position:"absolute",left:b*itemWidth})})}else{$pp_pic_holder.find(".pp_content").unbind("mouseenter mouseleave");$pp_pic_holder.find(".pp_gallery").hide()}if(settings.autoplay_slideshow){g=clearTimeout(g);a.prettyPhoto.startSlideshow();settings.autoplay_slideshow= false}};return this.unbind("click").click(a.prettyPhoto.initialize)}})(jQuery);
