/* ------------------------------------------------------------------------
	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+"=([^&#]*)";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 A(a){if(a.length){var b=a.find("div").attr("id");var c=a.attr("videourl");var d=a.attr("width");var e=a.attr("height");var f=jQuery("meta[name=unisphere_js]").attr("content");flowplayer(b,{src:f+"/flowplayer-3.2.4.swf",cachebusting:true,wmode:"transparent",width:d,height:e},{clip:{url:c,autoPlay:false,scaling:"fit"},onLoad:function(){this.play()}})}}function z(){a("body").append(c.markup);d=a(".pp_pic_holder");e=a(".ppt");f=a("div.pp_overlay");d.attr("class","pp_pic_holder "+c.theme);f.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");g=false}else{$this.removeClass("pp_contract").addClass("pp_expand");g=true}r(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})}function y(){n=a(window).height();o=a(window).width();f.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(g){titleHeight=e.height();contentHeight=d.height();contentwidth=d.width();projectedTop=n/2+q["scrollTop"]-(contentHeight+titleHeight)/2;d.css({top:projectedTop,left:o/2+q["scrollLeft"]-contentwidth/2});e.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(".flv")!=-1||a.indexOf(".mp4")!=-1){return"flv"}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=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();j=c+detailsHeight;k=b;l=j+e.height()+d.find(".pp_top").height()+d.find(".pp_bottom").height();m=b}function t(a,b){hasBeenResized=false;u(a,b);imageWidth=a;imageHeight=b;if((m>o||l>n)&&g&&c.allowresize&&!h){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){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(p==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 r(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();if(b)b()});e.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\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>',flv_markup:'<div id="flv_video" videourl="{path}" width="{width}" height="{height}"><div id="objectflv_video"></div></div>',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"}var d,e,f;if(a(".pp_overlay").size()==0){z()}else{d=a(".pp_pic_holder");e=a(".ppt");f=a("div.pp_overlay")}var g=true,h=false,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(d.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(g,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(g);titles=a.makeArray(j);descriptions=a.makeArray(k);image_set=a(images).size()>0?true:false;s(a(images).size());a(".pp_loaderIcon").show();f.show().fadeTo(c.animationSpeed,c.opacity);d.find(".currentTextHolder").text(p+1+c.counter_separator_label+a(images).size());if(descriptions[p]){d.find(".pp_description").show().html(unescape(descriptions[p]))}else{d.find(".pp_description").hide().text("")}if(titles[p]&&c.showTitle){hasTitle=true;e.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);h=true}d.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];d.find("#pp_full_res")[0].innerHTML=c.image_markup;d.find("#fullResImage").attr("src",images[p]);imgPreloader.onload=function(){i=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":i=t(movie_width,movie_height);movie="http://www.youtube.com/v/"+b("v",images[p])+"?fs=1";if(c.autoplay)movie+="&autoplay=1";toInject=c.flash_markup.replace(/{width}/g,i["width"]).replace(/{height}/g,i["height"]).replace(/{wmode}/g,c.wmode).replace(/{path}/g,movie);break;case"vimeo":i=t(movie_width,movie_height);movie_id=images[p];movie="http://vimeo.com/moogaloop.swf?clip_id="+movie_id.replace("http://vimeo.com/","")+"&fullscreen=1";if(c.autoplay)movie+="&autoplay=1";toInject=c.flash_markup.replace(/{width}/g,i["width"]).replace(/{height}/g,i["height"]).replace(/{wmode}/g,c.wmode).replace(/{path}/g,movie);break;case"quicktime":i=t(movie_width,movie_height);i["height"]+=15;i["contentHeight"]+=15;i["containerHeight"]+=15;toInject=c.quicktime_markup.replace(/{width}/g,i["width"]).replace(/{height}/g,i["height"]).replace(/{wmode}/g,c.wmode).replace(/{path}/g,images[p]).replace(/{autoplay}/g,c.autoplay);break;case"flash":i=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,i["width"]).replace(/{height}/g,i["height"]).replace(/{wmode}/g,c.wmode).replace(/{path}/g,filename+"?"+flash_vars);break;case"flv":i=t(movie_width,movie_height);filename=images[p];if(filename.indexOf("?")!=-1)filename=filename.substring(0,filename.indexOf("?"));toInject=c.flv_markup.replace(/{width}/g,i["width"]).replace(/{height}/g,i["height"]).replace(/{path}/g,filename);break;case"iframe":i=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,i["width"]).replace(/{height}/g,i["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"));i=t(a(myClone).width(),a(myClone).height());a(myClone).remove();toInject=c.inline_markup.replace(/{content}/g,a(images[p]).html());break}if(!imgPreloader){d.find("#pp_full_res")[0].innerHTML=toInject;if(v(images[p])=="flv"){A(a("#flv_video"))}_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(!g)g=true;r(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);f.fadeOut(c.animationSpeed,function(){a("#pp_full_res").html("");d.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()});g=true};_showContent=function(){a(".pp_loaderIcon").hide();projectedTop=q["scrollTop"]+(n/2-i["containerHeight"]/2);if(projectedTop<0)projectedTop=0+e.height();d.find(".pp_content").animate({height:i["contentHeight"]},c.animationSpeed);d.animate({top:projectedTop,left:o/2-i["containerWidth"]/2,width:i["containerWidth"]},c.animationSpeed,function(){d.find(".pp_hoverContainer,#fullResImage").height(i["height"]).width(i["width"]);d.find(".pp_fade").fadeIn(c.animationSpeed);if(image_set&&v(images[p])=="image"){d.find(".pp_hoverContainer").show()}else{d.find(".pp_hoverContainer").hide()}if(c.showTitle&&hasTitle){e.css({top:d.offset().top-25,left:d.offset().left+20,display:"none"});e.fadeIn(c.animationSpeed)}if(i["resized"])a("a.pp_expand,a.pp_contract").fadeIn(c.animationSpeed);c.changepicturecallback()})};w();}})(jQuery)
