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

	Altered to include "Order Prints" link for Halverson Images
------------------------------------------------------------------------- */
$(document).ready(function(){prettyPhoto.init()});prettyPhoto={options:{animationSpeed:"fast",padding:40,opacity:0.35,showTitle:true},init:function(){prettyPhoto.imagesArray=[];$("a[rel^='prettyOverlay'],a[rel^='prettyPhoto']").each(function(){prettyPhoto.imagesArray[prettyPhoto.imagesArray.length]=this;$(this).bind("click",function(){prettyPhoto.open(this);return false})});$(window).scroll(function(){prettyPhoto.centerPicture()});$(window).resize(function(){prettyPhoto.centerPicture();prettyPhoto.resizeOverlay()})},open:function(a){prettyPhoto.caller=a;theRel=$(a).attr("rel");galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);prettyPhoto.setCount=0;prettyPhoto.setPosition=0;prettyPhoto.arrayPosition=0;prettyPhoto.isSet=false;for(i=0;i<prettyPhoto.imagesArray.length;i++){if($(prettyPhoto.imagesArray[i]).attr("rel").indexOf(theGallery)!=-1){prettyPhoto.setCount++;if(prettyPhoto.setCount>1){prettyPhoto.isSet=true}if($(prettyPhoto.imagesArray[i]).attr("href")==$(a).attr("href")){prettyPhoto.setPosition=prettyPhoto.setCount;prettyPhoto.arrayPosition=i}}}prettyPhoto.buildOverlay(prettyPhoto.isSet);$("div.pictureHolder span.currentText").html("<span>"+prettyPhoto.setPosition+"</span>/"+prettyPhoto.setCount);prettyPhoto.centerPicture();$("div.pictureHolder #fullResImageContainer").hide();$(".loaderIcon").show();prettyPhoto.preload()},next:function(){prettyPhoto.arrayPosition++;prettyPhoto.setPosition++;$("div.pictureHolder #fullResImageContainer").fadeOut(prettyPhoto.options.animationSpeed,function(){$(".loaderIcon").show();prettyPhoto.preload()});prettyPhoto.hideTitle();$("div.pictureHolder .hoverContainer").fadeOut(prettyPhoto.options.animationSpeed);$("div.pictureHolder .details").fadeOut(prettyPhoto.options.animationSpeed,function(){prettyPhoto.checkPosition()})},previous:function(){prettyPhoto.arrayPosition--;prettyPhoto.setPosition--;$("div.pictureHolder #fullResImageContainer").fadeOut(prettyPhoto.options.animationSpeed,function(){$(".loaderIcon").show();prettyPhoto.preload()});prettyPhoto.hideTitle();$("div.pictureHolder .hoverContainer").fadeOut(prettyPhoto.options.animationSpeed);$("div.pictureHolder .details").fadeOut(prettyPhoto.options.animationSpeed,function(){prettyPhoto.checkPosition()})},checkPosition:function(){(prettyPhoto.setPosition==prettyPhoto.setCount)?$("div.pictureHolder a.next").hide():$("div.pictureHolder a.next").show();(prettyPhoto.setPosition==1)?$("div.pictureHolder a.previous").hide():$("div.pictureHolder a.previous").show();$("div.pictureHolder span.currentText span").text(prettyPhoto.setPosition);var b=$(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).attr("id");var a=$(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).hasClass("photobook");b=b.substr(3);if(a){$("div.pictureHolder #printLink").html('<a href="mailto:mike@halversonimages.com">Email to Order &raquo;</a>')}else{$("div.pictureHolder #printLink").html('<a href="order.php?add='+b+'">Order Prints &raquo;</a>')}if(prettyPhoto.isSet){if($(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).attr("title")){$("div.pictureHolder .description").html(unescape($(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).attr("title")))}else{$("div.pictureHolder .description").text("")}if($(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).find("img").attr("alt")&&prettyPhoto.options.showTitle){prettyPhoto.hasTitle=true;$("div.prettyPhotoTitle .prettyPhotoTitleContent").html(unescape($(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).find("img").attr("alt")))}else{prettyPhoto.hasTitle=false}}else{if($(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).attr("title")){$("div.pictureHolder .description").html(unescape($(prettyPhoto.caller).attr("title")))}else{$("div.pictureHolder .description").text("")}if($(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).find("img").attr("alt")&&prettyPhoto.options.showTitle){prettyPhoto.hasTitle=true;$("div.prettyPhotoTitle .prettyPhotoTitleContent").html(unescape($(prettyPhoto.caller).find("img").attr("alt")))}else{prettyPhoto.hasTitle=false}}},centerPicture:function(){if($("div.pictureHolder").size()>0){var a=prettyPhoto.getScroll();if($.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=$(window).height();windowWidth=$(window).width()}$("div.pictureHolder").css({top:(windowHeight/2)+a.scrollTop-($("div.pictureHolder").height()/2),left:(windowWidth/2)+a.scrollLeft-($("div.pictureHolder").width()/2)});$("div.prettyPhotoTitle").css({top:$("div.pictureHolder").offset().top-22,left:$("div.pictureHolder").offset().left+(prettyPhoto.options.padding/2)})}},preload:function(){prettyPhoto.checkPosition();imgPreloader=new Image();nextImage=new Image();if(prettyPhoto.isSet){nextImage.src=$(prettyPhoto.imagesArray[prettyPhoto.arrayPosition+1]).attr("href")}prevImage=new Image();if(prettyPhoto.isSet&&prettyPhoto.imagesArray[prettyPhoto.arrayPosition-1]){prevImage.src=$(prettyPhoto.imagesArray[prettyPhoto.arrayPosition-1]).attr("href")}$("div.pictureHolder .content").css("overflow","hidden");(prettyPhoto.isSet)?$("div.pictureHolder #fullResImage").attr("src",$(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).attr("href")):$("div.pictureHolder #fullResImage").attr("src",$(prettyPhoto.caller).attr("href"));imgPreloader.onload=function(){var a=prettyPhoto.resize(imgPreloader.width,imgPreloader.height);imgPreloader.width=a.width;imgPreloader.height=a.height;setTimeout("prettyPhoto.showimage(imgPreloader.width,imgPreloader.height,"+a.containerWidth+","+a.containerHeight+","+a.contentWidth+")",500)};(prettyPhoto.isSet)?imgPreloader.src=$(prettyPhoto.imagesArray[prettyPhoto.arrayPosition]).attr("href"):imgPreloader.src=$(prettyPhoto.caller).attr("href")},showimage:function(c,a,e,d,b){$(".loaderIcon").hide();$("div.pictureHolder .content").animate({height:contentHeight},prettyPhoto.options.animationSpeed);var f=prettyPhoto.getScroll();if($.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=$(window).height();windowWidth=$(window).width()}$("div.pictureHolder").animate({top:f.scrollTop+((windowHeight/2)-(d/2)),left:((windowWidth/2)-(e/2)),width:e},prettyPhoto.options.animationSpeed,function(){$("#fullResImage").attr({width:c,height:a});prettyPhoto.shownav();$("div.pictureHolder .hoverContainer").height(a).width(c);$("div.pictureHolder #fullResImageContainer").fadeIn(prettyPhoto.options.animationSpeed)})},shownav:function(){if(prettyPhoto.isSet){$("div.pictureHolder .hoverContainer").fadeIn(prettyPhoto.options.animationSpeed)}$("div.pictureHolder .details").fadeIn(prettyPhoto.options.animationSpeed);prettyPhoto.showTitle()},showTitle:function(){if(prettyPhoto.options.showTitle&&prettyPhoto.hasTitle){$("div.prettyPhotoTitle").css({top:$("div.pictureHolder").offset().top,left:$("div.pictureHolder").offset().left+(prettyPhoto.options.padding/2),display:"block"});$("div.prettyPhotoTitle div.prettyPhotoTitleContent").css("width","auto");if($("div.prettyPhotoTitle").width()>$("div.pictureHolder").width()){$("div.prettyPhotoTitle div.prettyPhotoTitleContent").css("width",$("div.pictureHolder").width()-(prettyPhoto.options.padding*2))}else{$("div.prettyPhotoTitle div.prettyPhotoTitleContent").css("width","")}$("div.prettyPhotoTitle").animate({top:($("div.pictureHolder").offset().top-22)},prettyPhoto.options.animationSpeed)}},hideTitle:function(){$("div.prettyPhotoTitle").animate({top:($("div.pictureHolder").offset().top)},prettyPhoto.options.animationSpeed,function(){$(this).css("display","none")})},buildOverlay:function(){backgroundDiv="<div class='prettyPhotoOverlay'></div>";$("body").append(backgroundDiv);$("div.prettyPhotoOverlay").css("height",$(document).height());$(".prettyPhotoOverlay").bind("click",function(){prettyPhoto.close()});pictureHolder='<div class="pictureHolder"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content"><div class="loaderIcon"></div><div class="hoverContainer"><a class="next" href="#">next</a><a class="previous" href="#">previous</a></div><div id="fullResImageContainer"><img id="fullResImage" src="" /></div><div class="details clearfix"><a class="close" href="#">Close</a><p class="description"></p><p class="currentTextHolder"><span class="currentText"><span>0</span>/<span class="total">0</span></span><span id="printLink"></span></p></div></div><div class="bottom"><div class="left"></div><div class="middle"></div><div class="right"></div></div></div>';titleHolder='<div class="prettyPhotoTitle"><div class="prettyPhotoTitleLeft"></div><div class="prettyPhotoTitleContent"></div><div class="prettyPhotoTitleRight"></div></div>';$("body").append(pictureHolder).append(titleHolder);$(".pictureHolder,.titleHolder").css({opacity:0});$("a.close").bind("click",function(){prettyPhoto.close();return false});$(".pictureHolder .previous").bind("click",function(){prettyPhoto.previous();return false});$(".pictureHolder .next").bind("click",function(){prettyPhoto.next();return false});$(".hoverContainer").css({"margin-left":prettyPhoto.options.padding/2,"margin-right":prettyPhoto.options.padding/2});if(!prettyPhoto.isSet){$(".hoverContainer").hide();$(".currentText").hide()}if($.browser.msie&&$.browser.version==6){$("select").css("visibility","hidden")}$("div.prettyPhotoOverlay").css("opacity",0);$("div.prettyPhotoOverlay").fadeTo(prettyPhoto.options.animationSpeed,prettyPhoto.options.opacity,function(){$("div.pictureHolder").fadeTo(prettyPhoto.options.animationSpeed,1,function(){$("div.pictureHolder").attr("style","left:"+$("div.pictureHolder").css("left")+";top:"+$("div.pictureHolder").css("top")+";")})})},resize:function(e,b){$("div.pictureHolder .details").width(e);$("div.pictureHolder .details p.description").width(e-parseFloat($("div.pictureHolder a.close").css("width")));contentHeight=parseFloat($("div.pictureHolder .details").height())+parseFloat($("div.pictureHolder .details").css("margin-top"))+parseFloat($("div.pictureHolder .details").css("margin-bottom"));containerHeight=contentHeight+parseFloat($("div.pictureHolder .top").height())+parseFloat($("div.pictureHolder .bottom").height());containerWidth=parseFloat($("div.pictureHolder .content").css("padding-left"))+parseFloat($("div.pictureHolder .content").css("padding-right"))+prettyPhoto.options.padding;var f=e;var d=b;if(prettyPhoto.options.showTitle){containerHeight-=22}if($.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=$(window).height();windowWidth=$(window).width()}if((containerWidth+e)>windowWidth||(containerHeight+b)>windowHeight){var c=(e+containerWidth+100)/windowWidth;var a=(b+containerHeight+100)/windowHeight;if(a>c){f=Math.round(e*(1/a));d=Math.round(b*(1/a))}else{f=Math.round(e*(1/c));d=Math.round(b*(1/c))}}containerHeight+=d;contentHeight+=d;containerWidth+=f;$("div.pictureHolder .details").width(f);$("div.pictureHolder .details p.description").width(f-parseFloat($("div.pictureHolder a.close").css("width")));return{width:f,height:d,containerHeight:containerHeight,containerWidth:containerWidth,contentHeight:contentHeight}},resizeOverlay:function(){$("div.prettyPhotoOverlay").css({height:$(document).height(),width:$(window).width()})},getScroll:function(){scrollTop=window.pageYOffset||document.documentElement.scrollTop||0;scrollLeft=window.pageXOffset||document.documentElement.scrollLeft||0;return{scrollTop:scrollTop,scrollLeft:scrollLeft}},close:function(){$("div.pictureHolder,div.prettyPhotoTitle").fadeTo(prettyPhoto.options.animationSpeed,0,function(){$("div.prettyPhotoOverlay").fadeTo(prettyPhoto.options.animationSpeed,0,function(){$("div.prettyPhotoOverlay").remove();$("div.pictureHolder").remove();if($.browser.msie&&$.browser.version==6){$("select").css("visibility","visible")}})})}};
