(function(g){g.fn.imgCenter=function(k){var h=g.extend({parentSteps:0,scaleToFit:!0,centerVertical:!0,complete:function(){},start:function(){},end:function(){}},k);h.start.call(this);var m=this.length-1;return this.each(function(j){function k(){f[0].complete&&(clearInterval(n),l(f))}function l(a){var b=parseInt(a.width()),c=parseInt(a.height()),f=b/c;if(d!=b||e!=c)i.css("overflow","hidden"),h.scaleToFit?(o>=1?(a.css({width:d+"px"}),b=d,c=Math.round(b/f),d/f<e&&(a.css({height:e+"px",width:"auto"}),
c=e,b=Math.round(c*f))):(a.css({height:e+"px"}),c=e,b=Math.round(c*f),e*f<d&&(a.css({width:d+"px",height:"auto"}),b=d,c=Math.round(b/f))),b>d&&a.css({"margin-left":"-"+Math.round((b-d)/2)+"px"}),c>e&&h.centerVertical&&a.css({"margin-top":"-"+Math.round((c-e)/2)+"px"})):(b>d?a.css({"margin-left":"-"+Math.round((b-d)/2)+"px"}):b<d&&(a.css({"margin-left":Math.round((d-b)/2)+"px"}),g.browser.msie&&g.browser.version.substr(0,1)==6&&a.css({"margin-left":Math.round((d-b)/2)/2+"px"})),c>e&&h.centerVertical?
(a.css({"margin-top":"-"+Math.round((c-e)/2)+"px"}),g.browser.msie&&g.browser.version.substr(0,1)==6&&a.css({"margin-top":"-"+Math.round((c-e)/2)/2+"px"})):c<e&&h.centerVertical&&(a.css({"margin-top":Math.round((e-c)/2)+"px"}),g.browser.msie&&g.browser.version.substr(0,1)==6&&a.css({"margin-top":"0px"}))),h.complete.call(this),p==m&&h.end.call(this);a.show()}var p=j,f=g(this);f.hide();for(var i=f,j=0;j<=h.parentSteps;j++)i=i.parent();var d=parseInt(i.width()),e=parseInt(i.height()),o=d/e;if(f[0].complete)l(f);
else var n=setInterval(k,500)})}})(jQuery);

