var headerHeight = 120;
var footerHeight = 274;
var contentMargin = 20;
var contentWidth = 918;

$(document).ready(function(){
	setTemplate();
	setTimeout("setTemplate()", 100);
});
$(window).resize(function() {
	setTemplate();
	setTimeout("setTemplate()", 100);
});

function setTemplate(){
	// Fix bodybackground
	var contentHeight = $('#body').height() + contentMargin;
	var windowHeight = $(window).height();
	var setHeight =  windowHeight -headerHeight -footerHeight
	
	if(setHeight > contentHeight){
		$('#body_bg').height(setHeight);
		$('#body_wrapper').height(setHeight);
	} else {
		$('#body_bg').height(contentHeight);
		$('#body_wrapper').height(contentHeight);
	}
	
	// Fix bodywidth for IE
	var windowWidth = $(window).width();
	var setWidth = contentWidth+((windowWidth -contentWidth) / 2);
	if(setWidth > contentWidth){
		$('#body_bg').width(setWidth);
		$('#body_bg').css({left : '50%', marginLeft : '-460px'});
	} else {
		$('#body_bg').width(contentWidth);
		$('#body_bg').css({left : '0px', marginLeft : '0px'});
	}
	trace(setWidth);
}

function trace(msg){
	$('#debugger').text(msg);
}
