/*
 * jQuery Backstretch
 * Version 1.1.3
 * http://srobbin.com/jquery-plugins/jquery-backstretch/
 *
 * Add a dynamically-resized background image to the page
 *
 * Copyright (c) 2010 Scott Robbin (srobbin.com)
 * Dual licensed under the MIT and GPL licenses.
*/
(function(a){a.backstretch=function(b,n,m){if(a.isArray(b)){b=b[Math.floor(Math.random()*b.length)]}var f={centeredX:true,centeredY:true,speed:0},c=("onorientationchange" in window)?a(document):a(window),e,d,i,h,l,k;if(n&&typeof n=="object"){a.extend(f,n)}a(document).ready(j);return this;function j(){if(b){var o=a("<div />").attr("id","backstretch").css({left:0,top:0,position:"fixed",overflow:"hidden",zIndex:-9999}),p=a("<img />").css({position:"relative",display:"none"}).bind("load",function(r){var q=a(this);e=a(r.target).width()/a(r.target).height();g(function(){q.fadeIn(f.speed,function(){if(typeof m=="function"){m()}})})}).appendTo(o);a("body").prepend(o);p.attr("src",b);a(window).resize(g)}}function g(o){try{k={left:0,top:0};i=c.width();h=i/e;if(h>=c.height()){l=(h-c.height())/2;if(f.centeredY){a.extend(k,{top:"-"+l+"px"})}}else{h=c.height();i=h*e;l=(i-c.width())/2;if(f.centeredX){a.extend(k,{left:"-"+l+"px"})}}a("#backstretch img").width(i).height(h).css(k)}catch(p){}if(typeof o=="function"){o()}}}})(jQuery);
