(function(a){a.fn.scaleImage=function(c){var d=a.extend({parent:false,scale:"fill",center:true,fade:0},c);return this.each(function(){var g=a(this);var h=d.parent?g.parents(d.parent):g.parent();h.css({opacity:0,overflow:"hidden"});if(h.length>0){g.removeAttr("height").removeAttr("width");if(this.complete){f(g,h)}else{g.load(function(){f(g,h)})}}});function f(h,k){var r=b(h),s=r.width,j=r.height,t=k.width(),m=k.height(),u=parseInt(h.css("borderLeftWidth"),10)+parseInt(h.css("borderRightWidth"),10),n=parseInt(h.css("borderTopWidth"),10)+parseInt(h.css("borderBottomWidth"),10),q,o,p,l,g;if(m===0||t===0){var i=e(k);t=i.width;m=i.height}u=isNaN(u)?0:u;n=isNaN(n)?0:n;q=t/s;o=m/j;if(d.scale==="fit"){p=qo?q:o}}l=parseInt(s*p,10)-u;g=parseInt(j*p,10)-n;h.css({width:l,height:g}).attr({width:l,height:g});if(d.center){h.css("margin-left",Math.floor((t-l)/2));h.css("margin-top",Math.floor((m-g)/2))}if(d.fade>0){k.animate({opacity:1},d.fade)}else{k.css("opacity",1)}}function b(h){var g=new Image();g.src=h.attr("src");return{width:g.width,height:g.height}}function e(h){var i=h.clone().css({visibility:"hidden",display:"block",position:"absolute"});a("body").append(i);var g={width:i.width(),height:i.height()};i.remove();return g}}})(jQuery);