/*
 * jQuery Backstretch
 * Version 1.2.5
 * http://srobbin.com/jquery-plugins/jquery-backstretch/
 *
 * Add a dynamically-resized background image to the page
 *
 * Copyright (c) 2011 Scott Robbin (srobbin.com)
 * Dual licensed under the MIT and GPL licenses.
*/
(function(a){a.backstretch=function(b,q,p){var l={centeredX:true,centeredY:true,speed:0,opacity:1},e=a("#backstretch"),g=e.data("settings")||l,h=e.data("settings"),c=("onorientationchange" in window)?a(document):a(window),f,d,k,j,o,n;if(q&&typeof q=="object"){a.extend(g,q)}if(q&&typeof q=="function"){p=q}a(document).ready(m);return this;function m(){if(b){var r;if(e.length==0){e=a("<div />").attr("id","backstretch").css({left:0,top:0,position:"fixed",overflow:"hidden",zIndex:-999999,margin:0,padding:0,height:"100%",width:"100%"})}else{e.find("img").addClass("deleteable")}r=a("<img />").css({position:"absolute",display:"none",margin:0,padding:0,border:"none",zIndex:-999999}).bind("load",function(v){var u=a(this),t,s;u.css({width:"auto",height:"auto",opacity:g.opacity,filter:"Alpha(opacity="+(g.opacity*100)+")"});t=this.width||a(v.target).width();s=this.height||a(v.target).height();f=t/s;i(function(){u.fadeIn(g.speed,function(){e.find(".deleteable").remove();if(typeof p=="function"){p()}})})}).appendTo(e);if(a("body #backstretch").length==0){a("body").append(e)}e.data("settings",g);r.attr("src",b);a(window).resize(i)}}function i(r){try{n={left:0,top:0};k=c.width();j=k/f;if(j>=c.height()){o=(j-c.height())/2;if(g.centeredY){a.extend(n,{top:"-"+o+"px"})}}else{j=c.height();k=j*f;o=(k-c.width())/2;if(g.centeredX){a.extend(n,{left:"-"+o+"px"})}}a("#backstretch, #backstretch img:not(.deleteable)").width(k).height(j).filter("img").css(n)}catch(s){}if(typeof r=="function"){r()}}}})(jQuery);
