(function(b){b.backstretch=function(n,p,c){function a(e){try{s={left:0,top:0};u=t.width();v=u/o;if(v>=t.height()){r=(v-t.height())/2;q.centeredY&&b.extend(s,{top:"-"+r+"px"})}else{v=t.height();u=v*o;r=(u-t.width())/2;q.centeredX&&b.extend(s,{left:"-"+r+"px"})}b("#backstretch img").width(u).height(v).css(s)}catch(d){}typeof e=="function"&&e()}var q={centeredX:true,centeredY:true,speed:0},t="onorientationchange" in window?b(document):b(window),o,u,v,r,s;p&&typeof p=="object"&&b.extend(q,p);b(document).ready(function(){if(n){var e=b("<div />").attr("id","backstretch").css({left:0,top:0,position:"fixed",overflow:"hidden",zIndex:-9999}),d=b("<img />").css({position:"relative",display:"none"}).bind("load",function(g){var f=b(this);o=b(g.target).width()/b(g.target).height();a(function(){f.fadeIn(q.speed,function(){typeof c=="function"&&c()})})}).appendTo(e);b("body").prepend(e);d.attr("src",n);b(window).resize(a)}});return this}})(jQuery);
