/* ------------------------------------------------------------------------
	Class: prettyPhoto
	Use: Lightbox clone for jQuery
	Author: Stephane Caron (http://www.no-margin-for-errors.com)
	Version: 2.2.3
------------------------------------------------------------------------- */
var $ = JQ;
(function(A){A.fn.prettyPhoto=function(H){var C=0;var J=true;var E=[];A(window).scroll(function(){O();});A(window).resize(function(){O();R();});A(document).keyup(function(S){switch(S.keyCode){case 37:if(setPosition==1){return ;}G("previous");break;case 39:if(setPosition==setCount){return ;}G("next");break;case 27:P();break;}});H=jQuery.extend({animationSpeed:"normal",padding:40,opacity:0.35,showTitle:true,allowresize:true,counter_separator_label:"/",theme:"light_rounded"},H);A(this).each(function(){var V=false;var U=false;var W=0;var T=0;var S=0;E[E.length]=this;A(this).bind("click",function(){K(this);return false;});});function K(S){C=A(S);theRel=A(C).attr("rel");galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);isSet=false;setCount=0;for(i=0;i<E.length;i++){if(A(E[i]).attr("rel").indexOf(theGallery)!=-1){setCount++;if(setCount>1){isSet=true;}if(A(E[i]).attr("href")==A(S).attr("href")){setPosition=setCount;arrayPosition=i;}}}Q(isSet);A("div.pictureHolder p.currentTextHolder").text(setPosition+H.counter_separator_label+setCount);O();A("div.pictureHolder #fullResImageContainer").hide();A(".loaderIcon").show();L();}showimage=function(V,S,Y,X,W,T,U){A(".loaderIcon").hide();var Z=F();if(A.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth;}else{windowHeight=A(window).height();windowWidth=A(window).width();}A("div.pictureHolder .content").animate({"height":W,"width":Y},H.animationSpeed);projectedTop=Z["scrollTop"]+((windowHeight/2)-(X/2));if(projectedTop<0){projectedTop=0+A("div.prettyPhotoTitle").height();}A("div.pictureHolder").animate({"top":projectedTop,"left":((windowWidth/2)-(Y/2)),"width":Y},H.animationSpeed,function(){A("#fullResImage").attr({"width":V,"height":S});A("div.pictureHolder").width(Y);A("div.pictureHolder .hoverContainer").height(S).width(V);A("div.pictureHolder #fullResImageContainer").fadeIn(H.animationSpeed);M();if(U){A("a.expand,a.contract").fadeIn(H.animationSpeed);}});};function G(S){if(S=="previous"){arrayPosition--;setPosition--;}else{arrayPosition++;setPosition++;}if(!J){J=true;}A("div.pictureHolder .hoverContainer,div.pictureHolder .details").fadeOut(H.animationSpeed);A("div.pictureHolder #fullResImageContainer").fadeOut(H.animationSpeed,function(){A(".loaderIcon").show();L();});N();A("a.expand,a.contract").fadeOut(H.animationSpeed,function(){A(this).removeClass("contract").addClass("expand");});}function P(){A("div.pictureHolder,div.prettyPhotoTitle").fadeOut(H.animationSpeed,function(){A("div.prettyPhotoOverlay").fadeOut(H.animationSpeed,function(){A("div.prettyPhotoOverlay,div.pictureHolder,div.prettyPhotoTitle").remove();if(A.browser.msie&&A.browser.version==6){A("select").css("visibility","visible");}});});}function D(){if(setPosition==setCount){A("div.pictureHolder a.next").css("visibility","hidden");A("div.pictureHolder a.arrow_next").addClass("disabled").unbind("click");}else{A("div.pictureHolder a.next").css("visibility","visible");A("div.pictureHolder a.arrow_next.disabled").removeClass("disabled").bind("click",function(){G("next");return false;});}if(setPosition==1){A("div.pictureHolder a.previous").css("visibility","hidden");A("div.pictureHolder a.arrow_previous").addClass("disabled").unbind("click");}else{A("div.pictureHolder a.previous").css("visibility","visible");A("div.pictureHolder a.arrow_previous.disabled").removeClass("disabled").bind("click",function(){G("previous");return false;});}A("div.pictureHolder p.currentTextHolder").text(setPosition+H.counter_separator_label+setCount);var S=(isSet)?A(E[arrayPosition]):A(C);if(S.attr("title")){A("div.pictureHolder .description").show().html(unescape(S.attr("title")));}else{A("div.pictureHolder .description").hide().text("");}if(S.find("img").attr("alt")&&H.showTitle){hasTitle=true;A("div.prettyPhotoTitle .prettyPhotoTitleContent").html(unescape(S.find("img").attr("alt")));}else{hasTitle=false;}}function B(V,T){hasBeenResized=false;A("div.pictureHolder .details").width(V);A("div.pictureHolder .details p.description").width(V-parseFloat(A("div.pictureHolder a.close").css("width")));contentHeight=T+parseFloat(A("div.pictureHolder .details").height())+parseFloat(A("div.pictureHolder .details").css("margin-top"))+parseFloat(A("div.pictureHolder .details").css("margin-bottom"));contentWidth=V;containerHeight=T+parseFloat(A("div.prettyPhotoTitle").height())+parseFloat(A("div.pictureHolder .top").height())+parseFloat(A("div.pictureHolder .bottom").height());containerWidth=V+H.padding;imageWidth=V;imageHeight=T;if(A.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth;}else{windowHeight=A(window).height();windowWidth=A(window).width();}if(((containerWidth>windowWidth)||(containerHeight>windowHeight))&&J&&H.allowresize){hasBeenResized=true;if((containerWidth>windowWidth)&&(containerHeight>windowHeight)){var U=(containerWidth+200)/windowWidth;var S=(containerHeight+200)/windowHeight;}else{var U=windowWidth/containerWidth;var S=windowHeight/containerHeight;}if(S<U){imageWidth=Math.round(V*S*0.9);imageHeight=Math.round(T*S*0.9);}else{imageWidth=Math.round(V*U*0.9);imageHeight=Math.round(T*U*0.9);}contentHeight=imageHeight+parseFloat(A("div.pictureHolder .details").height())+parseFloat(A("div.pictureHolder .details").css("margin-top"))+parseFloat(A("div.pictureHolder .details").css("margin-bottom"));contentWidth=imageWidth;containerHeight=imageHeight+parseFloat(A("div.prettyPhotoTitle").height())+parseFloat(A("div.pictureHolder .top").height())+parseFloat(A("div.pictureHolder .bottom").height());containerWidth=imageWidth+H.padding;A("div.pictureHolder .details").width(contentWidth);A("div.pictureHolder .details p.description").width(contentWidth-parseFloat(A("div.pictureHolder a.close").css("width")));}return{width:imageWidth,height:imageHeight,containerHeight:containerHeight,containerWidth:containerWidth,contentHeight:contentHeight,contentWidth:contentWidth,resized:hasBeenResized};}function O(){if(A("div.pictureHolder").size()>0){var S=F();if(A.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth;}else{windowHeight=A(window).height();windowWidth=A(window).width();}if(J){projectedTop=(windowHeight/2)+S["scrollTop"]-(A("div.pictureHolder").height()/2);if(projectedTop<0){projectedTop=0+A("div.prettyPhotoTitle").height();}A("div.pictureHolder").css({"top":projectedTop,"left":(windowWidth/2)+S["scrollLeft"]-(A("div.pictureHolder").width()/2)});A("div.prettyPhotoTitle").css({"top":A("div.pictureHolder").offset().top-A("div.prettyPhotoTitle").height(),"left":A("div.pictureHolder").offset().left+(H.padding/2)});}}}function M(){if(isSet){A("div.pictureHolder .hoverContainer").fadeIn(H.animationSpeed);}A("div.pictureHolder .details").fadeIn(H.animationSpeed);I();}function I(){if(H.showTitle&&hasTitle){A("div.prettyPhotoTitle").css({"top":A("div.pictureHolder").offset().top-22,"left":A("div.pictureHolder").offset().left+(H.padding/2),"display":"none"});A("div.prettyPhotoTitle div.prettyPhotoTitleContent").css("width","auto");if(A("div.prettyPhotoTitle").width()>A("div.pictureHolder").width()){A("div.prettyPhotoTitle div.prettyPhotoTitleContent").css("width",A("div.pictureHolder").width()-(H.padding*2));}else{A("div.prettyPhotoTitle div.prettyPhotoTitleContent").css("width","");}A("div.prettyPhotoTitle").fadeIn(H.animationSpeed);}}function N(){A("div.prettyPhotoTitle").fadeOut(H.animationSpeed);}function L(){D();imgPreloader=new Image();nextImage=new Image();if(isSet&&setPosition>setCount){nextImage.src=A(E[arrayPosition+1]).attr("href");}prevImage=new Image();if(isSet&&E[arrayPosition-1]){prevImage.src=A(E[arrayPosition-1]).attr("href");}A("div.pictureHolder .content").css("overflow","hidden");if(isSet){A("div.pictureHolder #fullResImage").attr("src",A(E[arrayPosition]).attr("href"));}else{A("div.pictureHolder #fullResImage").attr("src",A(C).attr("href"));}imgPreloader.onload=function(){var S=B(imgPreloader.width,imgPreloader.height);imgPreloader.width=S["width"];imgPreloader.height=S["height"];setTimeout("showimage(imgPreloader.width,imgPreloader.height,"+S["containerWidth"]+","+S["containerHeight"]+","+S["contentHeight"]+","+S["contentWidth"]+","+S["resized"]+")",500);};(isSet)?imgPreloader.src=A(E[arrayPosition]).attr("href"):imgPreloader.src=A(C).attr("href");}function F(){scrollTop=window.pageYOffset||document.documentElement.scrollTop||0;scrollLeft=window.pageXOffset||document.documentElement.scrollLeft||0;return{scrollTop:scrollTop,scrollLeft:scrollLeft};}function R(){A("div.prettyPhotoOverlay").css({"height":A(document).height(),"width":A(window).width()});}function Q(){backgroundDiv="<div class='prettyPhotoOverlay'></div>";A("body").append(backgroundDiv);A("div.prettyPhotoOverlay").css("height",A(document).height()).bind("click",function(){P();});pictureHolder='<div class="pictureHolder"><div class="top"><div class="left"></div><div class="middle"></div><div class="right"></div></div><div class="content"><a href="#" class="expand" title="Expand the image">Expand</a><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><div class="nav"><a href="#" class="arrow_previous">Previous</a><p class="currentTextHolder">0'+H.counter_separator_label+'0</p><a href="#" class="arrow_next">Next</a></div></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>';A("body").append(pictureHolder).append(titleHolder);A(".pictureHolder,.titleHolder").css({"opacity":0});A(".pictureHolder,.prettyPhotoTitle").addClass(H.theme);A("a.close").bind("click",function(){P();return false;});A("a.expand").bind("click",function(){if(A(this).hasClass("expand")){A(this).removeClass("expand").addClass("contract");J=false;}else{A(this).removeClass("contract").addClass("expand");J=true;}N();A("div.pictureHolder .hoverContainer,div.pictureHolder #fullResImageContainer").fadeOut(H.animationSpeed);A("div.pictureHolder .details").fadeOut(H.animationSpeed,function(){L();});return false;});A(".pictureHolder .previous,.pictureHolder .arrow_previous").bind("click",function(){G("previous");return false;});A(".pictureHolder .next,.pictureHolder .arrow_next").bind("click",function(){G("next");return false;});A(".hoverContainer").css({"margin-left":H.padding/2});if(!isSet){A(".hoverContainer,.nav").hide();}if(A.browser.msie&&A.browser.version==6){A("body").addClass("ie6");A("select").css("visibility","hidden");}A("div.prettyPhotoOverlay").css("opacity",0).fadeTo(H.animationSpeed,H.opacity,function(){A("div.pictureHolder").css("opacity",0).fadeIn(H.animationSpeed,function(){A("div.pictureHolder").attr("style","left:"+A("div.pictureHolder").css("left")+";top:"+A("div.pictureHolder").css("top")+";");});});}};})(jQuery);

