//--------------------------------------------------
// Author: Chris Lock
// Copyright (c) 2009
//--------------------------------------------------
function resize(){var bgRatio=1.5;var minWidth=980;var pageHeight=$("div#page").height();var bgWidth=1680;var bgHeight=1120;var winWidth=$(window).width();var winHeight=$(window).height();if(winHeight<bgHeight){if(pageHeight>winHeight)$("div#bg").css("height",pageHeight);else $("div#bg").css("height",winHeight);if(winWidth<minWidth){$("div#bg").css("width",minWidth);$("img#resize").css("width",bgWidth).css("height",bgHeight).css("left",(minWidth-bgWidth)/2)}else{$("div#bg").css("width",winWidth);
if(winWidth>bgWidth)$("img#resize").css("width",winWidth).css("height",winWidth/bgRatio).css("left",0);else $("img#resize").css("width",bgWidth).css("height",bgHeight).css("left",(winWidth-bgWidth)/2)}}else if(winWidth<minWidth){var newWidth=winHeight*bgRatio;$("div#bg").css("width",minWidth).css("height",winHeight);$("img#resize").css("width",newWidth).css("height",winHeight).css("left",(minWidth-newWidth)/2)}else{$("div#bg").css("width",winWidth).css("height",winHeight);if(winWidth/winHeight>bgRatio)$("img#resize").css("width",
winWidth).css("height",winWidth/bgRatio).css("left",0);else{var newWidth=winHeight*bgRatio;$("img#resize").css("width",newWidth).css("height",winHeight).css("left",(winWidth-newWidth)/2)}}}function fadeBg(){$("img#resize").load(function(){$("div#bg").fadeIn(1500)})}function showBg(){$("img#resize").load(function(){$("div#bg").show()})}$(document).ready(function(){if($('div#bg').css('display')=='none'){$("div#bg").append('<img id="resize" src="images/bg.jpg" />');fadeBg();resize();$(window).bind("resize",function(){resize()})}});