$.fn.prettyPhoto=function(u){var q=false;var r=0;var b=0;var y=0;var g=false;var p=0;var c=true;var n=[];$(window).scroll(function(){a()});$(window).resize(function(){a();s()});$(document).keyup(function(z){switch(z.keyCode){case 37:if(b==1){return}m("previous");break;case 39:if(b==r){return}m("next");break;case 27:l();break}});u=jQuery.extend({animationSpeed:"normal",padding:40,opacity:0.35,showTitle:true,allowresize:true,counter_separator_label:"/"},u);$(this).each(function(){n[n.length]=this;test=true;for(j=0;j<n.length-1;j++){if($(n[j]).attr("href")==$(this).attr("href")){test=false}}$(this).bind("click",function(){h(this);return false});if(test==true){}else{n.length=n.length-1}});function h(z){p=$(z);theRel=$(p).attr("rel");galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);contentType="image";if($(p).attr("href").indexOf(".swf")>0){g=false;contentType="flash"}q=false;r=0;for(i=0;i<n.length;i++){if($(n[i]).attr("rel").indexOf(theGallery)!=-1){r++;if(r>1){q=true}if($(n[i]).attr("href")==$(z).attr("href")){b=r;y=i}}}v(q);$("div.pictureHolder p.currentTextHolder").text(b+u.counter_separator_label+r);a();$("div.pictureHolder #fullResImageContainer").hide();$(".loaderIcon").show();(contentType=="image")?w():f()}showimage=function(C,z,F,E,D,A,B){$(".loaderIcon").hide();var G=e();if($.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=$(window).height();windowWidth=$(window).width()}$("div.pictureHolder .content").animate({height:D,width:F},u.animationSpeed);projectedTop=G.scrollTop+((windowHeight/2)-(E/2));if(projectedTop<0){projectedTop=0+$("div.prettyPhotoTitle").height()}$("div.pictureHolder").animate({top:projectedTop,left:((windowWidth/2)-(F/2)),width:F},u.animationSpeed,function(){$("#fullResImage").attr({width:C,height:z});$("div.pictureHolder").width(F);$("div.pictureHolder .hoverContainer").height(z).width(C);d();$("div.pictureHolder #fullResImageContainer").fadeIn(u.animationSpeed);if(B){$("a.expand,a.contract").fadeIn(u.animationSpeed)}})};function m(z){if(z=="previous"){y--;b--}else{y++;b++}if(!c){c=true}$("div.pictureHolder .hoverContainer,div.pictureHolder .details").fadeOut(u.animationSpeed);$("div.pictureHolder #fullResImageContainer").fadeOut(u.animationSpeed,function(){$(".loaderIcon").show();w()});x();$("a.expand,a.contract").fadeOut(u.animationSpeed,function(){$(this).removeClass("contract").addClass("expand")})}function l(){$("div.pictureHolder,div.prettyPhotoTitle").fadeOut(u.animationSpeed,function(){$("div.prettyPhotoOverlay").fadeOut(u.animationSpeed,function(){$("div.prettyPhotoOverlay,div.pictureHolder,div.prettyPhotoTitle").remove();if($.browser.msie&&$.browser.version==6){$("select").css("visibility","visible")}})})}function k(){if(b==r){$("div.pictureHolder a.next").css("visibility","hidden");$("div.pictureHolder a.arrow_next").addClass("disabled").css("visibility","hidden").unbind("click")}else{$("div.pictureHolder a.next").css("visibility","visible");$("div.pictureHolder a.arrow_next.disabled").css("visibility","visible").removeClass("disabled").bind("click",function(){m("next");return false})}if(b==1){$("div.pictureHolder a.previous").css("visibility","hidden");$("div.pictureHolder a.arrow_previous").css("visibility","hidden").addClass("disabled").unbind("click")}else{$("div.pictureHolder a.previous").css("visibility","visible");$("div.pictureHolder a.arrow_previous.disabled").css("visibility","visible").removeClass("disabled").bind("click",function(){m("previous");return false})}$("div.pictureHolder p.currentTextHolder").text(b+u.counter_separator_label+r);(q)?$c=$(n[y]):$c=$(p);if($c.attr("title")){$("div.pictureHolder .description").show().html(unescape($c.attr("title")))}else{$("div.pictureHolder .description").hide().text("")}if($c.find("img").attr("alt")&&u.showTitle){g=true;$("div.prettyPhotoTitle .prettyPhotoTitleContent").html(unescape($c.find("img").attr("alt")))}else{g=false}}function o(C,A){hasBeenResized=false;$("div.pictureHolder .details").width(C);$("div.pictureHolder .details p.description").width(C-parseFloat($("div.pictureHolder a.close").css("width")));contentHeight=A+parseFloat($("div.pictureHolder .details").height())+parseFloat($("div.pictureHolder .details").css("margin-top"))+parseFloat($("div.pictureHolder .details").css("margin-bottom"));contentWidth=C;containerHeight=A+parseFloat($("div.prettyPhotoTitle").height())+parseFloat($("div.pictureHolder .top").height())+parseFloat($("div.pictureHolder .bottom").height());containerWidth=C+u.padding;imageWidth=C;imageHeight=A;if($.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=$(window).height();windowWidth=$(window).width()}if(((containerWidth>windowWidth)||(containerHeight>windowHeight))&&c&&u.allowresize){hasBeenResized=true;if((containerWidth>windowWidth)&&(containerHeight>windowHeight)){var B=(containerWidth+200)/windowWidth;var z=(containerHeight+200)/windowHeight}else{var B=windowWidth/containerWidth;var z=windowHeight/containerHeight}if(z>B){imageWidth=Math.round(C*(1/z));imageHeight=Math.round(A*(1/z))}else{imageWidth=Math.round(C*(1/B));imageHeight=Math.round(A*(1/B))}contentHeight=imageHeight+parseFloat($("div.pictureHolder .details").height())+parseFloat($("div.pictureHolder .details").css("margin-top"))+parseFloat($("div.pictureHolder .details").css("margin-bottom"));contentWidth=imageWidth;containerHeight=imageHeight+parseFloat($("div.prettyPhotoTitle").height())+parseFloat($("div.pictureHolder .top").height())+parseFloat($("div.pictureHolder .bottom").height());containerWidth=imageWidth+u.padding;$("div.pictureHolder .details").width(contentWidth);$("div.pictureHolder .details p.description").width(contentWidth-parseFloat($("div.pictureHolder a.close").css("width")))}return{width:imageWidth,height:imageHeight,containerHeight:containerHeight,containerWidth:containerWidth,contentHeight:contentHeight,contentWidth:contentWidth,resized:hasBeenResized}}function a(){if($("div.pictureHolder").size()>0){var z=e();if($.browser.opera){windowHeight=window.innerHeight;windowWidth=window.innerWidth}else{windowHeight=$(window).height();windowWidth=$(window).width()}if(c){projectedTop=(windowHeight/2)+z.scrollTop-($("div.pictureHolder").height()/2);if(projectedTop<0){projectedTop=0+$("div.prettyPhotoTitle").height()}$("div.pictureHolder").css({top:projectedTop,left:(windowWidth/2)+z.scrollLeft-($("div.pictureHolder").width()/2)});$("div.prettyPhotoTitle").css({top:$("div.pictureHolder").offset().top-$("div.prettyPhotoTitle").height(),left:$("div.pictureHolder").offset().left+(u.padding/2)})}}}function d(){if(q){$("div.pictureHolder .hoverContainer").fadeIn(u.animationSpeed)}$("div.pictureHolder .details").fadeIn(u.animationSpeed);t()}function t(){if(u.showTitle&&g){$("div.prettyPhotoTitle").css({top:$("div.pictureHolder").offset().top,left:$("div.pictureHolder").offset().left+(u.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()-(u.padding*2))}else{$("div.prettyPhotoTitle div.prettyPhotoTitleContent").css("width","")}$("div.prettyPhotoTitle").animate({top:($("div.pictureHolder").offset().top-22)},u.animationSpeed)}}function x(){$("div.prettyPhotoTitle").animate({top:($("div.pictureHolder").offset().top)},u.animationSpeed,function(){$(this).css("display","none")})}function w(){k();imgPreloader=new Image();nextImage=new Image();if((q)&&((n.length)>(y+1))){nextImage.src=$(n[y+1]).attr("href")}prevImage=new Image();if(q&&n[y-1]){prevImage.src=$(n[y-1]).attr("href")}$("div.pictureHolder .content").css("overflow","hidden");if(q){$("div.pictureHolder #fullResImage").attr("src",$(n[y]).attr("href"))}else{$("div.pictureHolder #fullResImage").attr("src",$(p).attr("href"))}imgPreloader.onload=function(){var z=o(imgPreloader.width,imgPreloader.height);imgPreloader.width=z.width;imgPreloader.height=z.height;setTimeout("showimage(imgPreloader.width,imgPreloader.height,"+z.containerWidth+","+z.containerHeight+","+z.contentHeight+","+z.contentWidth+","+z.resized+")",500)};(q)?imgPreloader.src=$(n[y]).attr("href"):imgPreloader.src=$(p).attr("href")}function e(){scrollTop=window.pageYOffset||document.documentElement.scrollTop||0;scrollLeft=window.pageXOffset||document.documentElement.scrollLeft||0;return{scrollTop:scrollTop,scrollLeft:scrollLeft}}function s(){$("div.prettyPhotoOverlay").css({height:$(document).height(),width:$(window).width()})}function f(){flashParams=$(p).attr("rel").split(";");$(flashParams).each(function(z){if(flashParams[z].indexOf("width")>=0){flashWidth=flashParams[z].substring(flashParams[z].indexOf("width")+6,flashParams[z].length)}if(flashParams[z].indexOf("height")>=0){flashHeight=flashParams[z].substring(flashParams[z].indexOf("height")+7,flashParams[z].length)}if(flashParams[z].indexOf("flashvars")>=0){flashVars=flashParams[z].substring(flashParams[z].indexOf("flashvars")+10,flashParams[z].length)}});$(".pictureHolder #fullResImageContainer").append('<embed width="'+flashWidth+'" height="'+flashHeight+'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="opaque" name="prettyFlash" flashvars="'+flashVars+'" allowscriptaccess="always" bgcolor="#FFFFFF" quality="high" src="'+$(p).attr("href")+'"/>');$("#fullResImage").hide();contentHeight=parseFloat(flashHeight)+parseFloat($("div.pictureHolder .details").height())+parseFloat($("div.pictureHolder .details").css("margin-top"))+parseFloat($("div.pictureHolder .details").css("margin-bottom"));contentWidth=parseFloat(flashWidth)+parseFloat($("div.pictureHolder .details").width())+parseFloat($("div.pictureHolder .details").css("margin-left"))+parseFloat($("div.pictureHolder .details").css("margin-right"));containerHeight=contentHeight+parseFloat($("div.pictureHolder .top").height())+parseFloat($("div.pictureHolder .bottom").height());containerWidth=parseFloat(flashWidth)+parseFloat($("div.pictureHolder .content").css("padding-left"))+parseFloat($("div.pictureHolder .content").css("padding-right"))+u.padding;setTimeout("showimage("+flashWidth+","+flashHeight+","+containerWidth+","+containerHeight+","+contentHeight+","+contentWidth+")",500)}function v(){backgroundDiv="<div class='prettyPhotoOverlay'></div>";$("body").append(backgroundDiv);$("div.prettyPhotoOverlay").css("height",$(document).height()).bind("click",function(){l()});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="Bild vergr&ouml;&szlig;ern">Vergr&ouml;&szlig;ern</a><div class="loaderIcon"></div><div class="hoverContainer"><a class="next" href="#">weiter</a><a class="previous" href="#">zur&uuml;ck</a></div><div id="fullResImageContainer"><img id="fullResImage" src="../general/lightbox/images/transparent.gif" /></div><div class="details clearfix"><a class="close" href="#">Close</a><p class="description"></p><div class="nav"><a href="#" class="arrow_previous">zur&uuml;ck</a><p class="currentTextHolder">0'+u.counter_separator_label+'0</p><a href="#" class="arrow_next">weiter</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>';$("body").append(pictureHolder).append(titleHolder);$(".pictureHolder,.titleHolder").css({opacity:0});$("a.close").bind("click",function(){l();return false});$("a.expand").bind("click",function(){if($(this).hasClass("expand")){$(this).removeClass("expand").addClass("contract");c=false}else{$(this).removeClass("contract").addClass("expand");c=true}x();$("div.pictureHolder .hoverContainer,div.pictureHolder #fullResImageContainer").fadeOut(u.animationSpeed);$("div.pictureHolder .details").fadeOut(u.animationSpeed,function(){w()});return false});$(".pictureHolder .previous,.pictureHolder .arrow_previous").bind("click",function(){m("previous");return false});$(".pictureHolder .next,.pictureHolder .arrow_next").bind("click",function(){m("next");return false});$(".hoverContainer").css({"margin-left":u.padding/2});if(!q){$(".hoverContainer,.nav").hide()}if($.browser.msie&&$.browser.version==6){$("select").css("visibility","hidden")}$("div.prettyPhotoOverlay").css("opacity",0).fadeTo(u.animationSpeed,u.opacity,function(){$("div.pictureHolder").css("opacity",0).fadeIn(u.animationSpeed,function(){$("div.pictureHolder").attr("style","left:"+$("div.pictureHolder").css("left")+";top:"+$("div.pictureHolder").css("top")+";")})})}};
