var bCheckLoad = false;
var bWidth = false;
jQuery.noConflict();
jQuery(document).ready(function(){
	jQuery(document).pngFix(); 
	jQuery("#background-image").load(function(){
				var eBGImg = document.getElementById("background-image");
		if(jQuery.browser.msie && jQuery.browser.version == "8.0")
		{
			if(eBGImg.width == 28 && eBGImg.height == 30)
			{
				checkImageLoad();
			}
			else
			{
				resizeBackground();
			}
		}
	});
	setTimeout("checkImageLoad()",500);
});
jQuery(window).resize(function(){
	resizeBackground();
});

function checkImageLoad()
{
	var eBGImg = document.getElementById("background-image");
	bgWidth = eBGImg.naturalWidth || eBGImg.width;
	if(bgWidth > 0)
	{
		resizeBackground();
	}
	else
	{
		setTimeout("checkImageLoad()",500);
	}
}

function resizeBackground()
{
	var sImgWidth, sImgHeight;

	var eBGImg = document.getElementById("background-image");

	var sRatioImageWidth = 2800;//eBGImg.naturalWidth || eBGImg.width;
	var sRatioImageHeight = 1300;//eBGImg.naturalHeight || eBGImg.height;
	var sImageAspectRatio = sRatioImageWidth / sRatioImageHeight;
	var sWidth = jQuery(window).width();
	var sHeight = jQuery(window).height();
	var sAspectRatio = sWidth / sHeight;
	
	sImgWidth = Math.ceil(sHeight * sImageAspectRatio);
	sImgHeight = sHeight;
	
	if(sWidth > 1000)
	{
		sLeft = Math.ceil((sWidth - 1000)/2);
	}
	else
	{
		sLeft = 0;
	}
	
	// top space = 0px; top menu = 30px; bottom bar = 30px;
	
	iScrollStart = 30;
	iScrollHeight = sHeight - 60;
	iBGHeight = sHeight - 30;
	
	jQuery('DIV.bgCon').css({visibility:"visible", display:"block", height: sHeight, width: sWidth});
	jQuery('IMG.bgImg').css({height: sImgHeight, width: sImgWidth});
	jQuery('div.contentwhole').css({top: iScrollStart, width: sWidth, height: iScrollHeight});
	if(document.getElementById("contentwidebg")){
		jQuery('div.contentwidebg').css({top: 0, height: iBGHeight});
	}
	if(document.getElementById("contentbg")){
		jQuery('div.contentbg').css({top: 0, height: iBGHeight});
	}
	jQuery('div.contentwide').css({top: 0, height: sHeight});
	bCheckLoad = true;
}
