var docwidth = 0;
var docheight = 0;
var resizeTimer = null;


function setBGSizes(width,height){
	tmpwidth 	= jQuery("#background img").css('width');
	tmpheight 	= jQuery("#background img").css('height');
	//if(((width == 'auto') && (tmpwidth != 'auto')) || ((height == 'auto') && (tmpheight != 'auto'))) { // only change if we need to
		jQuery("#background > *").css('width',width);
		jQuery("#background > *").css('height',height);
	//}
}

function resizeWin(bForce) {
		
	if (resizeTimer) {
		clearTimeout(resizeTimer);
	}	

	winwidth 	= jQuery(window).width(); 
	winheight 	= jQuery(window).height(); 
	 
	if ((winwidth != docwidth) || (winheight != docheight) || (bForce)) { // resize occured
		docwidth = winwidth;
		docheight = winheight;
				
		testheight 		= (docwidth/1920) * docheight;
		testwidth  		= (docheight/1120) * docwidth;
		

		if (docwidth > docheight) {
			testheightex  	= (docwidth/testwidth) * testheight;
			if ((testheight < docheight))  {
				if ((testwidth < docwidth) && (testheightex > docheight)) {
					setBGSizes('50%','auto');					
				} else {
					setBGSizes('auto','50%');
				}	
			} else {
				setBGSizes('50%','auto');						
			}	
		} else {
			setBGSizes('auto','50%');
		}
	}	
	
	resizeTimer = window.setTimeout('resizeWin(true)',200);
}
		
