$(window).load(function()
{
    //alert("ready");
	resizeBackground();
});
$(window).resize(function()
{
    //alert("resize");
	resizeBackground();
});
function resizeBackground()
{
	var minWidth = 1024;
	var minHeight = 768;
	var imgBg = $(".background");
	var imgBgContainer = $(".background-container");
	
	var windowWidth = $(document).width();
	var windowHeight = $(document).height();
	
	var imageWidth = windowWidth;
	var imageHeight = windowHeight;
	
	
	
	if (windowWidth >  windowHeight)
	{
		imgBg.removeAttr("height");
		if (windowWidth < minWidth)
		{
			imageWidth = minWidth;
		} else
		{
			imageWidth = windowWidth;	
		}
		imgBg.attr("width",imageWidth);
		if (imgBg.height() < windowHeight)
		{
			imgBg.removeAttr("width");
			imgBg.attr("height",windowHeight);
		}
	} else
	{
		imgBg.removeAttr("width");
		if (windowHeight < minHeight)
		{
			imageHeight = minHeight;
		} else
		{
			imageHeight = windowHeight;	
		}
		imgBg.attr("height",imageHeight);
		if (imgBg.width() < windowWidth)
		{
			imgBg.removeAttr("height");
			imgBg.attr("width",windowWidth);
		}
	}
	
		
	/*if (windowHeight < minHeight)
	{
		imageHeight = minHeight;
	}*/
	
	//imgBg.attr("height",imageHeight-1);
	
	//imgBg.removeAttr("width");
	/*
	
	var imgWidth = imgBg.width()
	
	// var leftPos = 0-Math.floor(Math.sqrt(windowWidth - minWidth)*4);
	var leftPos = 0;// -((imgWidth-minWidth)/2);
	var containerWidth = windowWidth-leftPos;
	
	$("#background-container").css({left:leftPos,width:containerWidth});
	*/
}

