/* ------------------------------------------------------------------------
	Class: prettyPhoto
	Use: Lightbox clone for jQuery
	Author: Stephane Caron (http://www.no-margin-for-errors.com)
	Version: 2.2.6
------------------------------------------------------------------------- */

(function(jQuery) { jQuery.fn.prettyPhoto = function(P) { var M = 0; var D = true; var K = []; var C = 0; jQuery(window).scroll(function() { B(); }); jQuery(window).resize(function() { B(); N(); }); jQuery(document).keyup(function(T) { switch (T.keyCode) { case 37: if (C == 1) { return; } J("previous"); break; case 39: if (C == setCount) { return; } J("next"); break; case 27: I(); break; } }); P = jQuery.extend({ animationSpeed: "normal", padding: 40, opacity: 0.35, showTitle: true, allowresize: true, counter_separator_label: "/", theme: "light_rounded" }, P); jQuery(this).each(function() { var V = false; var U = false; var W = 0; var T = 0; K[K.length] = this; jQuery(this).bind("click", function(event) { G(this); event.preventDefault(); return false; }); }); function G(T) { M = jQuery(T); theRel = jQuery(M).attr("rel"); galleryRegExp = /\[(?:.*)\]/; theGallery = galleryRegExp.exec(theRel); isSet = false; setCount = 0; for (i = 0; i < K.length; i++) { if (jQuery(K[i]).attr("rel").indexOf(theGallery) != -1) { setCount++; if (setCount > 1) { isSet = true; } if (jQuery(K[i]).attr("href") == jQuery(T).attr("href")) { C = setCount; arrayPosition = i; } } } Q(isSet); jQuery("div.pp_pic_holder p.currentTextHolder").text(C + P.counter_separator_label + setCount); B(); jQuery("div.pp_pic_holder #full_res").hide(); jQuery(".pp_loaderIcon").show(); R(); } showimage = function(W, T, Z, Y, X, U, V) { jQuery(".pp_loaderIcon").hide(); var a = F(); if (jQuery.browser.opera) { windowHeight = window.innerHeight; windowWidth = window.innerWidth; } else { windowHeight = jQuery(window).height(); windowWidth = jQuery(window).width(); } jQuery("div.pp_pic_holder .pp_content").animate({ height: X, width: Z }, P.animationSpeed); projectedTop = a.scrollTop + ((windowHeight / 2) - (Y / 2)); if (projectedTop < 0) { projectedTop = 0 + jQuery("div.ppt").height(); } jQuery("div.pp_pic_holder").animate({ top: projectedTop, left: ((windowWidth / 2) - (Z / 2)), width: Z }, P.animationSpeed, function() { jQuery("#fullResImage").attr({ width: W, height: T }); jQuery("div.pp_pic_holder").width(Z); jQuery("div.pp_pic_holder .hoverContainer").height(T).width(W); jQuery("div.pp_pic_holder #full_res").fadeIn(P.animationSpeed); E(); if (V) { jQuery("a.pp_expand,a.pp_contract").fadeIn(P.animationSpeed); } }); }; function J(T) { if (T == "previous") { arrayPosition--; C--; } else { arrayPosition++; C++; } if (!D) { D = true; } jQuery("div.pp_pic_holder .hoverContainer,div.pp_pic_holder .pp_details").fadeOut(P.animationSpeed); jQuery("div.pp_pic_holder #full_res").fadeOut(P.animationSpeed, function() { jQuery(".pp_loaderIcon").show(); R(); }); S(); jQuery("a.pp_expand,a.pp_contract").fadeOut(P.animationSpeed, function() { jQuery(this).removeClass("pp_contract").addClass("pp_expand"); }); } function I() { jQuery("div.pp_pic_holder,div.ppt").fadeOut(P.animationSpeed, function() { jQuery("div.pp_overlay").fadeOut(P.animationSpeed, function() { jQuery("div.pp_overlay,div.pp_pic_holder,div.ppt").remove(); if (jQuery.browser.msie && jQuery.browser.version == 6) { jQuery("select").css("visibility", "visible"); } }); }); D = true; } function H() { if (C == setCount) { jQuery("div.pp_pic_holder a.pp_next").css("visibility", "hidden"); jQuery("div.pp_pic_holder a.pp_arrow_next").addClass("disabled").unbind("click"); } else { jQuery("div.pp_pic_holder a.pp_next").css("visibility", "visible"); jQuery("div.pp_pic_holder a.pp_arrow_next.disabled").removeClass("disabled").bind("click", function(event) { J("next"); event.preventDefault(); return false; }); } if (C == 1) { jQuery("div.pp_pic_holder a.pp_previous").css("visibility", "hidden"); jQuery("div.pp_pic_holder a.pp_arrow_previous").addClass("disabled").unbind("click"); } else { jQuery("div.pp_pic_holder a.pp_previous").css("visibility", "visible"); jQuery("div.pp_pic_holder a.pp_arrow_previous.disabled").removeClass("disabled").bind("click", function(event) { J("previous"); event.PreventDefault(); return false; }); } jQuery("div.pp_pic_holder p.currentTextHolder").text(C + P.counter_separator_label + setCount); var T = (isSet) ? jQuery(K[arrayPosition]) : jQuery(M); if (T.attr("title")) { jQuery("div.pp_pic_holder .pp_description").show().html(unescape(T.attr("title"))); } else { jQuery("div.pp_pic_holder .pp_description").hide().text(""); } if (T.find("img").attr("alt") && P.showTitle) { hasTitle = true; jQuery("div.ppt .ppt_content").html(unescape(T.find("img").attr("alt"))); } else { hasTitle = false; } } function L(U, T) { hasBeenResized = false; jQuery("div.pp_pic_holder .pp_details").width(U); jQuery("div.pp_pic_holder .pp_details p.pp_description").width(U - parseFloat(jQuery("div.pp_pic_holder a.pp_close").css("width"))); contentHeight = T + parseFloat(jQuery("div.pp_pic_holder .pp_details").height()) + parseFloat(jQuery("div.pp_pic_holder .pp_details").css("margin-top")) + parseFloat(jQuery("div.pp_pic_holder .pp_details").css("margin-bottom")); contentWidth = U; containerHeight = T + parseFloat(jQuery("div.ppt").height()) + parseFloat(jQuery("div.pp_pic_holder .pp_top").height()) + parseFloat(jQuery("div.pp_pic_holder .pp_bottom").height()); containerWidth = U + P.padding; imageWidth = U; imageHeight = T; windowHeight = jQuery(window).height(); windowWidth = jQuery(window).width(); if (((containerWidth > windowWidth) || (containerHeight > windowHeight)) && D && P.allowresize) { hasBeenResized = true; notFitting = true; while (notFitting) { if ((containerWidth > windowWidth)) { imageWidth = (windowWidth - 200); imageHeight = (T / U) * imageWidth; } else { if ((containerHeight > windowHeight)) { imageHeight = (windowHeight - 200); imageWidth = (U / T) * imageHeight; } else { notFitting = false; } } containerHeight = imageHeight; containerWidth = imageWidth; } contentHeight = imageHeight + parseFloat(jQuery("div.pp_pic_holder .pp_details").height()) + parseFloat(jQuery("div.pp_pic_holder .pp_details").css("margin-top")) + parseFloat(jQuery("div.pp_pic_holder .pp_details").css("margin-bottom")); contentWidth = imageWidth; containerHeight = imageHeight + parseFloat(jQuery("div.ppt").height()) + parseFloat(jQuery("div.pp_pic_holder .pp_top").height()) + parseFloat(jQuery("div.pp_pic_holder .pp_bottom").height()); containerWidth = imageWidth + P.padding; jQuery("div.pp_pic_holder .pp_details").width(contentWidth); jQuery("div.pp_pic_holder .pp_details p.pp_description").width(contentWidth - parseFloat(jQuery("div.pp_pic_holder a.pp_close").css("width"))); } return { width: imageWidth, height: imageHeight, containerHeight: containerHeight, containerWidth: containerWidth, contentHeight: contentHeight, contentWidth: contentWidth, resized: hasBeenResized }; } function B() { if (jQuery("div.pp_pic_holder").size() > 0) { var T = F(); if (jQuery.browser.opera) { windowHeight = window.innerHeight; windowWidth = window.innerWidth; } else { windowHeight = jQuery(window).height(); windowWidth = jQuery(window).width(); } if (D) { projectedTop = (windowHeight / 2) + T.scrollTop - (jQuery("div.pp_pic_holder").height() / 2); if (projectedTop < 0) { projectedTop = 0 + jQuery("div.ppt").height(); } jQuery("div.pp_pic_holder").css({ top: projectedTop, left: (windowWidth / 2) + T.scrollLeft - (jQuery("div.pp_pic_holder").width() / 2) }); jQuery("div.ppt").css({ top: jQuery("div.pp_pic_holder").offset().top - jQuery("div.ppt").height(), left: jQuery("div.pp_pic_holder").offset().left + (P.padding / 2) }); } } } function E() { if (isSet) { jQuery("div.pp_pic_holder .hoverContainer").fadeIn(P.animationSpeed); } jQuery("div.pp_pic_holder .pp_details").fadeIn(P.animationSpeed); O(); } function O() { if (P.showTitle && hasTitle) { jQuery("div.ppt").css({ top: jQuery("div.pp_pic_holder").offset().top - 22, left: jQuery("div.pp_pic_holder").offset().left + (P.padding / 2), display: "none" }); jQuery("div.ppt div.ppt_content").css("width", "auto"); if (jQuery("div.ppt").width() > jQuery("div.pp_pic_holder").width()) { jQuery("div.ppt div.ppt_content").css("width", jQuery("div.pp_pic_holder").width() - (P.padding * 2)); } else { jQuery("div.ppt div.ppt_content").css("width", ""); } jQuery("div.ppt").fadeIn(P.animationSpeed); } } function S() { jQuery("div.ppt").fadeOut(P.animationSpeed); } function R() { H(); imgPreloader = new Image(); nextImage = new Image(); if (isSet && C > setCount) { nextImage.src = jQuery(K[arrayPosition + 1]).attr("href"); } prevImage = new Image(); if (isSet && K[arrayPosition - 1]) { prevImage.src = jQuery(K[arrayPosition - 1]).attr("href"); } jQuery("div.pp_pic_holder .pp_content").css("overflow", "hidden"); if (isSet) { jQuery("div.pp_pic_holder #fullResImage").attr("src", jQuery(K[arrayPosition]).attr("href")); } else { jQuery("div.pp_pic_holder #fullResImage").attr("src", jQuery(M).attr("href")); } imgPreloader.onload = function() { var T = L(imgPreloader.width, imgPreloader.height); imgPreloader.width = T.width; imgPreloader.height = T.height; setTimeout("showimage(imgPreloader.width,imgPreloader.height," + T.containerWidth + "," + T.containerHeight + "," + T.contentHeight + "," + T.contentWidth + "," + T.resized + ")", 500); }; (isSet) ? imgPreloader.src = jQuery(K[arrayPosition]).attr("href") : imgPreloader.src = jQuery(M).attr("href"); } function F() { scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0; scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || 0; return { scrollTop: scrollTop, scrollLeft: scrollLeft }; } function N() { jQuery("div.pp_overlay").css({ height: jQuery(document).height(), width: jQuery(window).width() }); } function Q() { backgroundDiv = "<div class='pp_overlay'></div>"; jQuery("body").append(backgroundDiv); jQuery("div.pp_overlay").css("height", jQuery(document).height()).bind("click", function(event) { I(); }); pictureHolder = '<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="hoverContainer"><a class="pp_next" href="#">next</a><a class="pp_previous" href="#">previous</a></div><div id="full_res"><img id="fullResImage" src="/Winter.jpg" /></div><div class="pp_details clearfix"><a class="pp_close" href="#">Close</a><p class="pp_description"></p><div class="pp_nav"><a href="#" class="pp_arrow_previous">Previous</a><p class="currentTextHolder">0' + P.counter_separator_label + '0</p><a href="#" class="pp_arrow_next">Next</a></div></div></div><div class="pp_bottom"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div></div>'; titleHolder = '<div class="ppt"><div class="ppt_left"></div><div class="ppt_content"></div><div class="ppt_right"></div></div>'; jQuery("body").append(pictureHolder).append(titleHolder); jQuery(".pp_pic_holder,.titleHolder").css({ opacity: 0 }); jQuery(".pp_pic_holder,.ppt").addClass(P.theme); jQuery("a.pp_close").bind("click", function(event) { I(); event.preventDefault(); return false; }); jQuery("a.pp_expand").bind("click", function(event) { event.preventDefault(); if (jQuery(this).hasClass("pp_expand")) { jQuery(this).removeClass("pp_expand").addClass("pp_contract"); D = false; } else { jQuery(this).removeClass("pp_contract").addClass("pp_expand"); D = true; } S(); jQuery("div.pp_pic_holder .hoverContainer,div.pp_pic_holder #full_res").fadeOut(P.animationSpeed); jQuery("div.pp_pic_holder .pp_details").fadeOut(P.animationSpeed, function() { R(); }); return false; }); jQuery(".pp_pic_holder .pp_previous,.pp_pic_holder .pp_arrow_previous").bind("click", function(event) { J("previous"); event.preventDefault(); return false; }); jQuery(".pp_pic_holder .pp_next,.pp_pic_holder .pp_arrow_next").bind("click", function(event) { J("next"); event.preventDefault(); return false; }); jQuery(".hoverContainer").css({ "margin-left": P.padding / 2 }); if (!isSet) { jQuery(".hoverContainer,.pp_nav").hide(); } if (jQuery.browser.msie && jQuery.browser.version == 6) { jQuery("body").addClass("ie6"); jQuery("select").css("visibility", "hidden"); } jQuery("div.pp_overlay").css("opacity", 0).fadeTo(P.animationSpeed, P.opacity, function() { jQuery("div.pp_pic_holder").css("opacity", 0).fadeIn(P.animationSpeed, function() { jQuery("div.pp_pic_holder").attr("style", "left:" + jQuery("div.pp_pic_holder").css("left") + ";top:" + jQuery("div.pp_pic_holder").css("top") + ";"); }); }); } }; })(jQueryCS);

