(function(a){jQuery.fn.maxImage=function(d){var u={show:false,location:"before",message:"Original: ([w]w x [h]h)"};var n=jQuery.extend({wait:true,imageArray:[],maxFollows:"both",verticalOffset:0,horizontalOffset:0,leftSpace:0,topSpace:0,rightSpace:0,bottomSpace:0,position:"absolute",isBackground:false,zIndex:-10,verticalAlign:"bottom",horizontalAlign:"left",maxAtOrigImageSize:false,slideShow:false,slideDelay:5,slideShowTitle:true,loaderClass:"loader",resizeMsg:u},d);n.resizeMsg=jQuery.extend(u,d.resizeMsg);var f=this;function w(){t(this,f);return false}function t(y,x){if(n.slideShow){s(x)}else{if(n.isBackground){Background._setup_background(y)}else{Others._setup_others(y,n)}}}Others={_setup_others:function(y,x){$this=a(y);a(window).load(function(){c($this);m($this);Others._configure_css(y,x);a(window).resize(function(){m($this)})})},_configure_css:function(y,x){if(x.position=="absolute"){a(y).css({overflow:"hidden",left:x.leftSpace,top:x.topSpace,position:"absolute"});if(x.verticalAlign=="bottom"){a(y).css({bottom:x.bottomSpace})}if(x.horizontalAlign=="right"){a(y).css({right:x.rightSpace})}}else{a(y).css({"margin-top":x.topSpace,"margin-right":x.rightSpace,"margin-bottom":x.bottomSpace,"margin-left":x.leftSpace,position:"relative"})}}};Background={_setup_background:function(x){$this=a(x);$this.hide();Background._configure_css(x);a(window).load(function(){c($this);m($this);$this.show();a(window).resize(function(){m($this)})})},_configure_css:function(x){a(x).css({"z-index":n.zIndex});if(n.position=="absolute"){a(x).css({overflow:"hidden",left:n.leftSpace,top:n.topSpace,position:"absolute"});a("html").css({overflow:"hidden"});if(n.verticalAlign=="bottom"){a(x).css({bottom:n.bottomSpace})}if(n.horizontalAlign=="right"){a(x).css({right:n.rightSpace})}}else{a(x).css({"margin-top":n.topSpace,"margin-right":n.rightSpace,"margin-bottom":n.bottomSpace,"margin-left":n.leftSpace,position:"relative"})}}};function s(y){l(y);n.imageArray.length=0;if(y.length==1){n.imageArray.push(new Array(objClicked.getAttribute("src"),objClicked.getAttribute("title")))}else{for(var x=0;x<y.length;x++){n.imageArray.push(new Array(y[x].getAttribute("src"),y[x].getAttribute("title")));a(y[x]).attr("original",a(y[x]).attr("src")).attr("src","")}}v(0);h()}function l(){for(var x=0;x<f.length;x++){a(f[x]).addClass("slides slide-"+x).after('<div class="slideTitle">'+a(f[x]).attr("title")+"</div>")}a(".slideTitle").hide().css({padding:"10px",background:"#e0e0e0",position:"absolute",bottom:"0",right:"5%",opacity:"0.8"})}function v(z){var y=z;var x=new Image();x.onload=function(){a(".slide-"+y).attr("src",n.imageArray[y][0]);c(a(".slide-"+y));m(a(".slide-"+y));a(window).resize(function(){m(a(".slide-"+y))});if(y==0){k()}if(y<n.imageArray.length-1){y++;v(y)}};x.src=n.imageArray[y][0]}function k(){var y=0;h();a("."+n.loaderClass).hide();a(".slide-"+y).css({"z-index":n.zIndex}).fadeIn();if(n.slideShowTitle){a(".slide-"+y).next(".slideTitle").css({"z-index":n.zIndex+1}).fadeIn()}var x=setInterval(function(){if(y<n.imageArray.length-1){y++;lastSlide=y-1}else{y=0;lastSlide=n.imageArray.length-1}a(".slide-"+lastSlide).css({"z-index":n.zIndex-1}).fadeOut("slow");a(".slide-"+y).css({"z-index":n.zIndex}).fadeIn("slow");if(n.slideShowTitle){b(y,lastSlide)}},(n.slideDelay*1000))}function h(){for(i=0;i<n.imageArray.length;i++){if(n.position=="absolute"){a(".slide-"+i).css({position:"absolute",overflow:"hidden"});a("html").css({overflow:"hidden"});if(n.verticalAlign=="bottom"){a(".slide-"+i).css({bottom:n.bottomSpace})}else{a(".slide-"+i).css({top:n.topSpace})}if(n.horizontalAlign=="right"){a(".slide-"+i).css({right:n.rightSpace})}else{a(".slide-"+i).css({left:n.leftSpace})}}else{a(".slide-"+i).css({"margin-top":n.topSpace,"margin-right":n.rightSpace,"margin-bottom":n.bottomSpace,"margin-left":n.leftSpace,position:"relative"})}a(".slide-"+i).next(".slideTitle").css({position:"absolute",bottom:0,right:"5%"})}}function b(y,x){a(".slide-"+x).next(".slideTitle").fadeOut();a(".slide-"+y).next(".slideTitle").fadeIn()}function c(x){$this=x;$this.attr("origWidth",$this.width());$this.attr("origHeight",$this.height());$this.attr("ratio",p($this.width(),$this.height()))}function m(A){$this=A;var B=r($this.attr("origWidth"));var z=r($this.attr("origHeight"));var y=$this.attr("ratio");if(B==0||z==0){setTimeout(function(){c(A);m(A)},100);return}var x=[];x=j(B,z,y);$this.width(x[0]);$this.height(x[1]);g(B,z,A)}function g(A,y,z){if((r($this.width())!=A||r($this.height())!=y)&&n.resizeMsg.show){a(".maximage_resized").remove();n.resizeMsg.message=n.resizeMsg.message.replace("[w]",A).replace("[h]",y);var x='<div class="maximage_resized">'+n.resizeMsg.message+"</div>";if(n.resizeMsg.location.toLowerCase()=="before"){$this.before(x)}else{$this.after(x)}}}function j(B,A,y){var x=a(window).width()-n.horizontalOffset;var z=a(window).height()-n.verticalOffset;if(!n.isBackground){if(n.maxFollows=="both"){e(x,y);if(height>z){q(z,y)}}else{if(n.maxFollows=="width"){e(x,y)}else{if(n.maxFollows=="height"){q(z,y)}}}}else{width=x+40;height=width/y;if(height<z){height=z-(n.topSpace+n.bottomSpace);width=height*y}}if(n.maxAtOrigImageSize&&width>B){arrayImageSize=new Array(B,A)}else{arrayImageSize=new Array(width,height)}return arrayImageSize}function q(y,x){height=y-(n.topSpace+n.bottomSpace);width=height*x}function e(x,y){width=x-(n.leftSpace+n.rightSpace);height=width/y}function p(z,x){z=r(z);x=r(x);var y=z/x;y=y.toFixed(2);return y}function r(x){last=parseInt(x);return last}function o(x){if(window.console&&window.console.log){window.console.log(x)}}return this.each(w)}})(jQuery);