var homeImgLoaded = 0;
var arrPageSizes;
var pageWidth;
var pageHeight;
var windowHeight;
var windowWidth;

$(document).ready(
	function(){
		$(window).resize(function() {
			sizeHome();
		});
		$('#content .images img').load(
			function (){
				homeImgLoaded = 1;
				sizeHome();
			}
		);
		$('#container').css({ 'overflow' : 'hidden' });
	}
);

function sizeHome(){
	$('#content .text, #content, #content .images').css({ 'height' : 'auto' });
	$('#content .images').css({ 'width' : 'auto' });
	
	textHeight = $('#content .text').outerHeight() - 75;
	
	arrPageSizes = ___getPageSize();
	pageWidth = arrPageSizes[0];
	pageHeight = arrPageSizes[1];
	windowWidth = arrPageSizes[2];
	windowHeight = arrPageSizes[3];
	
	textHeight = Math.max(textHeight, windowHeight-200-75);
	contentHeight = textHeight + 200 + 75;
	$('#content .text').css({ 'height' : textHeight });
	$('#content').css({ 'height' : contentHeight });
	
	imgsWinWidth = windowWidth-350;
	imgsWinHeight = contentHeight;
	$('#content .images').css({ 'width' : imgsWinWidth, 'height' : imgsWinHeight });
	
	if (homeImgLoaded == 1) {
		imgWidth = $('#content .images img').innerWidth();
		imgHeight = $('#content .images img').innerHeight();
		
		newImgWH = stretchDimOver(imgWidth, imgHeight, imgsWinWidth, imgsWinHeight);
		
		$('#content .images img').css({ 
			'width' : newImgWH['width'], 
			'height' : newImgWH['height'], 
			'margin-left' : (imgsWinWidth-newImgWH['width'])/2, 
			'margin-top' : (imgsWinHeight-newImgWH['height'])/2
		});
	}
}
