(function($){var jqez={};$.fn.ezBgResize=function(options){jqez=options;if(!$.isArray(jqez.img)){var tmp_img=jqez.img;jqez.img=[tmp_img]}
$("<img/>").attr("src",jqez.img).load(function(){jqez.width=this.width;jqez.height=this.height;$("body").prepend('<div id="bg"></div>');$("#bg").html('<img src="'+ jqez.img[0]+'" width="'+ jqez.width+'" height="'+ jqez.height+'" border="0">');$("#bg").css("display","none");$("body").css({"overflow":"hidden"});resizeImage();});};$(window).bind("resize",function(){resizeImage();});function resizeImage(){$("#bg").css({"position":"fixed","top":"0px","left":"0px","z-index":jqez.index,"overflow":"hidden","width":$(window).width()+"px","height":$(window).height()+"px","opacity":jqez.opacity});$("#bg").children('img').css("position","relative");var iw=$("#bg").children('img').width();var ih=$("#bg").children('img').height();if($(window).width()>$(window).height()){if(iw>ih){var fRatio=iw/ih;$("#bg").children('img').css("width",$(window).width()+"px");$("#bg").children('img').css("height",Math.round($(window).width()*(1/fRatio)));var newIh=Math.round($(window).width()*(1/fRatio));if(newIh<$(window).height()){var fRatio=ih/iw;$("#bg").children('img').css("height",$(window).height());$("#bg").children('img').css("width",Math.round($(window).height()*(1/fRatio)));}}else{var fRatio=ih/iw;$("#bg").children('img').css("height",$(window).height());$("#bg").children('img').css("width",Math.round($(window).height()*(1/fRatio)));}}else{var fRatio=ih/iw;$("#bg").children('img').css("height",$(window).height());$("#bg").children('img').css("width",Math.round($(window).height()*(1/fRatio)));}
if(typeof(jqez.center)=='undefined'||jqez.center){if($("#bg").children('img').width()>$(window).width()){var this_left=($("#bg").children('img').width()- $(window).width())/2;$("#bg").children('img').css({"top":0,"left":-this_left});}
if($("#bg").children('img').height()>$(window).height()){var this_height=($("#bg").children('img').height()- $(window).height())/2;$("#bg").children('img').css({"left":0,"top":-this_height});}}
$("#bg").fadeIn(400);$("body").css({"overflow":"auto"});}})(jQuery);
