/* ------------------------------------------------------------------------
	Class: prettyPhoto
	Use: Lightbox clone for jQuery
	Author: Stephane Caron (http://www.no-margin-for-errors.com)
	Version: 2.5.6
------------------------------------------------------------------------- */(function(a){function b(a,b){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var c="[\\?&]"+a+"=([^&#]*)",d=new RegExp(c),e=d.exec(b);return e==null?"":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(){c.modal||a.prettyPhoto.close()}),a("a.pp_close").bind("click",function(){a.prettyPhoto.close();return!1}),a("a.pp_expand").bind("click",function(){$this=a(this),$this.hasClass("pp_expand")?($this.removeClass("pp_expand").addClass("pp_contract"),d=!1):($this.removeClass("pp_contract").addClass("pp_expand"),d=!0),r(function(){a.prettyPhoto.open(images,titles,descriptions)}),g.find(".pp_fade").fadeOut(c.animationSpeed);return!1}),g.find(".pp_previous, .pp_arrow_previous").bind("click",function(){a.prettyPhoto.changePage("previous");return!1}),g.find(".pp_next, .pp_arrow_next").bind("click",function(){a.prettyPhoto.changePage("next");return!1})}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};if(document.documentElement&&document.documentElement.scrollTop)return{scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft};if(document.body)return{scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft}}function w(){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){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 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,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=!1,u(a,b),imageWidth=a,imageHeight=b;if((m>o||l>n)&&d&&c.allowresize&&!e){hasBeenResized=!0,notFitting=!0;while(notFitting)m>o?(imageWidth=o-200,imageHeight=b/a*imageWidth):l>n?(imageHeight=n-200,imageWidth=a/b*imageHeight):notFitting=!1,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){p==b-1?(g.find("a.pp_next").css("visibility","hidden"),g.find("a.pp_arrow_next").addClass("disabled").unbind("click")):(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!1})),p==0?(g.find("a.pp_previous").css("visibility","hidden"),g.find("a.pp_arrow_previous").addClass("disabled").unbind("click")):(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!1})),b>1?a(".pp_nav").show():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(),b&&b()}),h.fadeOut(c.animationSpeed)}c=jQuery.extend({animationSpeed:"normal",opacity:.8,showTitle:!0,allowresize:!0,default_width:500,default_height:344,counter_separator_label:"/",theme:"light_rounded",hideflash:!1,wmode:"opaque",autoplay:!0,modal:!1,changepicturecallback:function(){},callback:function(){},markup:'<div class="pp_pic_holder"> \n\t\t\t\t\t\t<div class="pp_top"> \n\t\t\t\t\t\t\t<div class="pp_left"></div> \n\t\t\t\t\t\t\t<div class="pp_middle"></div> \n\t\t\t\t\t\t\t<div class="pp_right"></div> \n\t\t\t\t\t\t</div> \n\t\t\t\t\t\t<div class="pp_content_container"> \n\t\t\t\t\t\t\t<div class="pp_left"> \n\t\t\t\t\t\t\t<div class="pp_right"> \n\t\t\t\t\t\t\t\t<div class="pp_content"> \n\t\t\t\t\t\t\t\t\t<div class="pp_loaderIcon"></div> \n\t\t\t\t\t\t\t\t\t<div class="pp_fade"> \n\t\t\t\t\t\t\t\t\t\t<a href="#" class="pp_expand" title="Expand the image">Expand</a> \n\t\t\t\t\t\t\t\t\t\t<div class="pp_hoverContainer"> \n\t\t\t\t\t\t\t\t\t\t\t<a class="pp_next" href="#">next</a> \n\t\t\t\t\t\t\t\t\t\t\t<a class="pp_previous" href="#">previous</a> \n\t\t\t\t\t\t\t\t\t\t</div> \n\t\t\t\t\t\t\t\t\t\t<div id="pp_full_res"></div> \n\t\t\t\t\t\t\t\t\t\t<div class="pp_details clearfix"> \n\t\t\t\t\t\t\t\t\t\t\t<a class="pp_close" href="#">Close</a> \n\t\t\t\t\t\t\t\t\t\t\t<p class="pp_description"></p> \n\t\t\t\t\t\t\t\t\t\t\t<div class="pp_nav"> \n\t\t\t\t\t\t\t\t\t\t\t\t<a href="#" class="pp_arrow_previous">Previous</a> \n\t\t\t\t\t\t\t\t\t\t\t\t<p class="currentTextHolder">0/0</p> \n\t\t\t\t\t\t\t\t\t\t\t\t<a href="#" class="pp_arrow_next">Next</a> \n\t\t\t\t\t\t\t\t\t\t\t</div> \n\t\t\t\t\t\t\t\t\t\t</div> \n\t\t\t\t\t\t\t\t\t</div> \n\t\t\t\t\t\t\t\t</div> \n\t\t\t\t\t\t\t</div> \n\t\t\t\t\t\t\t</div> \n\t\t\t\t\t\t</div> \n\t\t\t\t\t\t<div class="pp_bottom"> \n\t\t\t\t\t\t\t<div class="pp_left"></div> \n\t\t\t\t\t\t\t<div class="pp_middle"></div> \n\t\t\t\t\t\t\t<div class="pp_right"></div> \n\t\t\t\t\t\t</div> \n\t\t\t\t\t</div> \n\t\t\t\t\t<div class="pp_overlay"></div> \n\t\t\t\t\t<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),a.browser.msie&&parseInt(a.browser.version)==6&&(c.theme="light_square"),a(".pp_overlay").size()==0&&z();var d=!0,e=!1,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: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 b=[],c=[],d=[];theGallery?a("a[rel*="+theGallery+"]").each(function(e){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"))}):(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!1})}),a.prettyPhoto.open=function(d,j,k){a.browser.msie&&a.browser.version==6&&a("select").css("visibility","hidden"),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?!0:!1,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()),descriptions[p]?g.find(".pp_description").show().html(unescape(descriptions[p])):g.find(".pp_description").hide().text(""),titles[p]&&c.showTitle?(hasTitle=!0,h.html(unescape(titles[p]))):hasTitle=!1,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=!0;g.fadeIn(function(){imgPreloader="";switch(v(images[p])){case"image":imgPreloader=new Image,nextImage=new Image,image_set&&p>a(images).size()&&(nextImage.src=images[p+1]),prevImage=new Image,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]),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/",""),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())}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++}d||(d=!0),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(),a.browser.msie&&a.browser.version==6&&a("select").css("visibility","visible"),c.hideflash&&a("object,embed").css("visibility","visible"),p=0,c.callback()}),d=!0},_showContent=function(){a(".pp_loaderIcon").hide(),projectedTop=q.scrollTop+(n/2-f.containerHeight/2),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),image_set&&v(images[p])=="image"?g.find(".pp_hoverContainer").show():g.find(".pp_hoverContainer").hide(),c.showTitle&&hasTitle&&(h.css({top:g.offset().top-25,left:g.offset().left+20,display:"none"}),h.fadeIn(c.animationSpeed)),f.resized&&a("a.pp_expand,a.pp_contract").fadeIn(c.animationSpeed),c.changepicturecallback()})},w()}})(jQuery)

