// Some stuff we set later
window.params = {
	div: null,
	movie: null,
	footer: null,
	wrapper: null,
	scrollFixer: null,
	ADJUST: null,
	MINIMUM_WIDTH: 980,
	MINIMUM_HEIGHT: 600
}

// Some divs we need
jQuery(document).ready(function(){

	// Flash content
	window.params.div = document.getElementById("contained");
	window.params.footer = document.getElementById("footer");
	window.params.scrollFixer = document.getElementById("scrollFixer");
	window.params.wrapper = document.getElementById("wrapper");
	
	// Get flash movie
	window.params.movie = (jQuery.browser.msie) ? window["adidasClimacool"] : document["adidasClimacool"];
	
	// Determine combined height of header / footer
	window.params.ADJUST = window.params.footer.offsetHeight + window.params.wrapper.offsetHeight;

	// Unbind adidas stuff
	jQuery(window).unbind();
	window.onresize = onWindowResize;
	window.onresize();
});

/**
 * Runs when the window is resized
 * @param {Object} e
 */
function onWindowResize(e){
	resizeClimacool();
}

/**
 * Adjust size of the site
 * @param {Object} dontAskFlash
 */
function resizeClimacool(dontAskFlash){
	
	// Get page width and height
	var h = jQuery(window).height();
	var w = jQuery(window).width();
	var div = window.params.div;
	
	// Page is shorter than minimum height
	if (h < window.params.MINIMUM_HEIGHT) {
	
		// Set to min height - header/footer size
		div.style.height = (window.params.MINIMUM_HEIGHT - window.params.ADJUST) + "px";
		
	} else {
	
		// Set to full height - header/footer size
		div.style.height = (document.body.offsetHeight - window.params.ADJUST) + "px";
	}
	
	// Page is smaller tham minimum width
	if (w < window.params.MINIMUM_WIDTH) {
	
		// Set to minimum width
		div.style.width = window.params.MINIMUM_WIDTH + "px";
		
	} else {
	
		// Set to full width
		div.style.width = "100%";
	}
}
