/* ------------------------------------------------------------------------
	Class: prettyPhoto
	Use: Lightbox clone for jQuery
	Author: Stephane Caron (http://www.no-margin-for-errors.com)
	Version: 2.5.3
------------------------------------------------------------------------- */

(function(a){function k(c,p){c=c.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var q=(new RegExp("[\\?&]"+c+"=([^&#]*)")).exec(p);return q==null?"":q[1]}a.prettyPhoto={version:"2.5.3"};a.fn.prettyPhoto=function(c){function p(){b.find("#pp_full_res object,#pp_full_res embed").css("visibility","hidden");b.find(".pp_hoverContainer,.pp_details").fadeOut(c.animationSpeed);b.find("#pp_full_res").fadeOut(c.animationSpeed,function(){a(".pp_loaderIcon").show()});i.fadeOut(c.animationSpeed)}function q(f){if(d== f-1){b.find("a.pp_next").css("visibility","hidden");b.find("a.pp_arrow_next").addClass("disabled").click(function(){return false})}else{b.find("a.pp_next").css("visibility","visible");b.find("a.pp_arrow_next.disabled").removeClass("disabled").bind("click",function(){a.prettyPhoto.changePage("next");return false})}if(d==0){b.find("a.pp_previous").css("visibility","hidden");b.find("a.pp_arrow_previous").addClass("disabled").click(function(){return false})}else{b.find("a.pp_previous").css("visibility", "visible");b.find("a.pp_arrow_previous.disabled").removeClass("disabled").bind("click",function(){a.prettyPhoto.changePage("previous");return false})}f>1?a(".pp_nav").show():a(".pp_nav").hide()}function t(f,h){hasBeenResized=false;u(f,h);imageWidth=f;imageHeight=h;windowHeight=a(window).height();windowWidth=a(window).width();if((m>windowWidth||n>windowHeight)&&j&&c.allowresize&&!v){for(notFitting=hasBeenResized=true;notFitting;){if(m>windowWidth){imageWidth=windowWidth-200;imageHeight=h/f*imageWidth}else if(n> windowHeight){imageHeight=windowHeight-200;imageWidth=f/h*imageHeight}else notFitting=false;n=imageHeight;m=imageWidth}u(imageWidth,imageHeight)}return{width:imageWidth,height:imageHeight,containerHeight:n,containerWidth:m,contentHeight:s,contentWidth:w,resized:hasBeenResized}}function u(f,h){b.find(".pp_details").width(f).find(".pp_description").width(f);s=h+b.find(".pp_details").height()+parseFloat(b.find(".pp_details").css("marginTop"))+parseFloat(b.find(".pp_details").css("marginBottom"));w=f; n=s+b.find(".ppt").height()+b.find(".pp_top").height()+b.find(".pp_bottom").height();m=f+c.padding}function B(f){g=f.match(/youtube\.com\/watch/i)?"youtube":f.indexOf("http://www.dailymotion.com")!=-1?"dailymotion":f.indexOf("vimeo.com")!=-1?"vimeo":f.indexOf("vids.myspace.com")!=-1?"myspace":f.indexOf(".mov")!=-1?"quicktime":f.indexOf(".swf")!=-1?"flash":f.indexOf("iframe")!=-1?"iframe":"image"}function x(){if(a.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight= a(window).height();windowWidth=a(window).width()}if(j){$pHeight=b.height();$pWidth=b.width();$tHeight=i.height();projectedTop=windowHeight/2+o.scrollTop-$pHeight/2;if(projectedTop<0)projectedTop=0+$tHeight;b.css({top:projectedTop,left:windowWidth/2+o.scrollLeft-$pWidth/2});i.css({top:projectedTop-$tHeight,left:windowWidth/2+o.scrollLeft-$pWidth/2+c.padding/2})}}function y(){if(self.pageYOffset){scrollTop=self.pageYOffset;scrollLeft=self.pageXOffset}else if(document.documentElement&&document.documentElement.scrollTop){scrollTop= document.documentElement.scrollTop;scrollLeft=document.documentElement.scrollLeft}else if(document.body){scrollTop=document.body.scrollTop;scrollLeft=document.body.scrollLeft}return{scrollTop:scrollTop,scrollLeft:scrollLeft}}function z(){a("div.pp_overlay").css({height:a(document).height(),width:a(window).width()})}function A(){toInject="";toInject+="<div class='pp_overlay'></div>";toInject+='<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"><a href="#" class="pp_expand" title="Expand the image">Expand</a><div class="pp_loaderIcon"></div><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"><p class="pp_description"></p><div class="pp_nav"><a href="#" class="pp_arrow_previous">Previous</a><p class="currentTextHolder">0'+ c.counter_separator_label+'0</p><a href="#" class="pp_arrow_next">Next</a></div><a class="pp_close" href="#">Close</a></div></div><div class="pp_bottom"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div></div>';toInject+='<div class="ppt"></div>';a("body").append(toInject);a("div.pp_overlay").css("opacity",0);b=a(".pp_pic_holder");i=a(".ppt");a("div.pp_overlay").css("height",a(document).height()).hide().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}p();b.find(".pp_hoverContainer, .pp_details").fadeOut(c.animationSpeed);b.find("#pp_full_res").fadeOut(c.animationSpeed,function(){a.prettyPhoto.open(images,titles,descriptions,d)});return false});b.find(".pp_previous, .pp_arrow_previous").bind("click", function(){a.prettyPhoto.changePage("previous");return false});b.find(".pp_next, .pp_arrow_next").bind("click",function(){a.prettyPhoto.changePage("next");return false});b.find(".pp_hoverContainer").css({"margin-left":c.padding/2})}c=jQuery.extend({animationSpeed:"normal",padding:40,opacity:0.8,showTitle:true,allowresize:true,counter_separator_label:"/",theme:"dark_rounded",hideflash:false,modal:false,changepicturecallback:function(){},callback:function(){}},c);if(a.browser.msie&&a.browser.version== 6)c.theme="dark_square";if(a(".pp_overlay").size()==0)A();else{b=a(".pp_pic_holder");i=a(".ppt")}var j=true,v=false,e,b,i,s,w,n,m,g="image",d=0,o=y();a(window).scroll(function(){o=y();z()});a(window).resize(function(){x();z()});a(document).keydown(function(f){if(b.is(":visible"))switch(f.keyCode){case 37:a.prettyPhoto.changePage("previous");break;case 39:a.prettyPhoto.changePage("next");break;case 27:c.modal||a.prettyPhoto.close();break}});a(this).each(function(){a(this).bind("click",function(){link= this;theRel=a(this).attr("rel");galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);var f=[],h=[],l=[];if(theGallery)a("a[rel*="+theGallery+"]").each(function(r){if(a(this)[0]===a(link)[0])d=r;f.push(a(this).attr("href"));h.push(a(this).find("img").attr("alt"));this.getElementsByTagName("img").length>0?l.push(a(this).attr("title")+a(this).find("img").attr("alt")):l.push(a(this).attr("title"))});else{f=a(this).attr("href");h=a(this).find("img").attr("alt")?a(this).find("img").attr("alt"): "";l=a(this).attr("title")?a(this).attr("title"):""}a.prettyPhoto.open(f,h,l);return false})});a.prettyPhoto.open=function(f,h,l,r){if(r!=undefined)d=r;a.browser.msie&&a.browser.version==6&&a("select").css("visibility","hidden");c.hideflash&&a("object,embed").css("visibility","hidden");images=a.makeArray(f);titles=a.makeArray(h);descriptions=a.makeArray(l);images[d]=images[d].replace(/&amp;/g,"&");if(a(".pp_overlay").size()==0)A();else{b=a(".pp_pic_holder");i=a(".ppt")}b.attr("class","pp_pic_holder "+ c.theme);isSet=a(images).size()>0?true:false;B(images[d]);x();q(a(images).size());a(".pp_loaderIcon").show();a("div.pp_overlay").show().fadeTo(c.animationSpeed,c.opacity,function(){b.fadeIn(c.animationSpeed,function(){b.find("p.currentTextHolder").text(d+1+c.counter_separator_label+a(images).size());if(descriptions[d]){descriptionHTML=descriptions[d].replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");b.find(".pp_description").show().html(descriptionHTML)}else b.find(".pp_description").hide().text(""); if(titles[d]&&c.showTitle){hasTitle=true;i.html(unescape(titles[d]))}else hasTitle=false;if(g=="image"){imgPreloader=new Image;nextImage=new Image;if(isSet&&d>a(images).size())nextImage.src=images[d+1];prevImage=new Image;if(isSet&&images[d-1])prevImage.src=images[d-1];pp_typeMarkup='<img id="fullResImage" src="" />';b.find("#pp_full_res")[0].innerHTML=pp_typeMarkup;b.find(".pp_content").css("overflow","hidden");b.find("#fullResImage").attr("src",images[d]);imgPreloader.onload=function(){e=t(imgPreloader.width, imgPreloader.height);_showContent()};imgPreloader.src=images[d]}else{movie_width=parseFloat(k("width",images[d]))?k("width",images[d]):"425";movie_height=parseFloat(k("height",images[d]))?k("height",images[d]):"344";if(movie_width.indexOf("%")!=-1||movie_height.indexOf("%")!=-1){movie_height=a(window).height()*parseFloat(movie_height)/100-100;movie_width=a(window).width()*parseFloat(movie_width)/100-100;v=true}movie_height=parseFloat(movie_height);movie_width=parseFloat(movie_width);if(g=="quicktime")movie_height+= 13;e=t(movie_width,movie_height);permalien=images[d];permalien=permalien.substring(0,images[d].indexOf("?width="));if(g=="youtube")pp_typeMarkup='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.youtube.com/v/'+k("v",images[d])+'" /><embed src="http://www.youtube.com/v/'+k("v",images[d])+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+ e.width+'" height="'+e.height+'"></embed></object>';else if(g=="myspace"){numVideoMyspace=permalien.substring(permalien.indexOf("videoid=")+8,permalien.length);pp_typeMarkup='<object width="'+e.width+'" height="'+e.height+'" ><param name="allowFullScreen" value="true"/><param name="wmode" value="transparent"/><param name="movie" value="http://mediaservices.myspace.com/services/media/embed.aspx/m='+numVideoMyspace+',t=1,mt=video"/><embed src="http://mediaservices.myspace.com/services/media/embed.aspx/m='+ numVideoMyspace+',t=1,mt=video" width="'+e.width+'" height="'+e.height+'" allowFullScreen="true" type="application/x-shockwave-flash" wmode="transparent"></embed></object>'}else if(g=="dailymotion"){numVideoDailymotion=permalien.substring(permalien.indexOf("/video/")+7,permalien.length);pp_typeMarkup='<object width="'+e.width+'" height="'+e.height+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="movie" value="http://www.dailymotion.com/swf/'+numVideoDailymotion+'"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/'+ numVideoDailymotion+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'" allowFullScreen="true" allowScriptAccess="always"></embed></object>'}else if(g=="vimeo"){numVideoVimeo=permalien.substring(permalien.indexOf("vimeo.com/")+10,permalien.length);pp_typeMarkup='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+ numVideoVimeo+'" /><embed src="http://vimeo.com/moogaloop.swf?clip_id='+numVideoVimeo+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+e.width+'" height="'+e.height+'"></embed></object>'}else if(g=="quicktime")pp_typeMarkup='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+e.height+'" width="'+e.width+'"><param name="src" value="'+images[d]+'"><param name="autoplay" value="true"><param name="type" value="video/quicktime"><embed src="'+ images[d]+'" height="'+e.height+'" width="'+e.width+'" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';else if(g=="flash"){flash_vars=images[d];flash_vars=flash_vars.substring(images[d].indexOf("flashvars")+10,images[d].length);filename=images[d];filename=filename.substring(0,filename.indexOf("?"));pp_typeMarkup='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="'+ filename+"?"+flash_vars+'" /><embed src="'+filename+"?"+flash_vars+'" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+e.width+'" height="'+e.height+'"></embed></object>'}else if(g=="iframe"){movie_url=images[d];movie_url=movie_url.substr(0,movie_url.indexOf("iframe")-1);pp_typeMarkup='<iframe src ="'+movie_url+'" width="'+(e.width-10)+'" height="'+(e.height-10)+'" frameborder="no"></iframe>'}_showContent()}})})};a.prettyPhoto.changePage=function(f){if(f== "previous"){d--;if(d<0){d=0;return}}else{if(a(".pp_arrow_next").is(".disabled"))return;d++}j||(j=true);p();a("a.pp_expand,a.pp_contract").fadeOut(c.animationSpeed,function(){a(this).removeClass("pp_contract").addClass("pp_expand");a.prettyPhoto.open(images,titles,descriptions,d)})};a.prettyPhoto.close=function(){b.find("object,embed").css("visibility","hidden");a("div.pp_pic_holder,div.ppt").fadeOut(c.animationSpeed);a("div.pp_overlay").fadeOut(c.animationSpeed,function(){a("div.pp_overlay,div.pp_pic_holder,div.ppt").remove(); a.browser.msie&&a.browser.version==6&&a("select").css("visibility","visible");c.hideflash&&a("object,embed").css("visibility","visible");d=0;g!="image"&&c.callback()});j=true};_showContent=function(){a(".pp_loaderIcon").hide();if(a.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=a(window).height();windowWidth=a(window).width()}projectedTop=o.scrollTop+(windowHeight/2-e.containerHeight/2);if(projectedTop<0)projectedTop=0+b.find(".ppt").height();b.find(".pp_content").animate({height:e.contentHeight}, c.animationSpeed);b.animate({top:projectedTop,left:windowWidth/2-e.containerWidth/2,width:e.containerWidth},c.animationSpeed,function(){b.width(e.containerWidth);b.find(".pp_hoverContainer,#fullResImage").height(e.height).width(e.width);b.find("#pp_full_res").fadeIn(c.animationSpeed);isSet&&g=="image"?b.find(".pp_hoverContainer").fadeIn(c.animationSpeed):b.find(".pp_hoverContainer").hide();b.find(".pp_details").fadeIn(c.animationSpeed);if(c.showTitle&&hasTitle){i.css({top:b.offset().top-20,left:b.offset().left+ c.padding/2,display:"none"});i.fadeIn(c.animationSpeed)}if(g!="image")b.find("#pp_full_res")[0].innerHTML=pp_typeMarkup;g!="image"&&c.changepicturecallback()})}}})(jQuery); 