// CSS Patch 2006 by J.P.Jarolim
// If the Browser Window has to be scrolled, css div backgrounds
// are not scaled properly

css_patch_elementIdsArray = new Array('header','content','emotion','overlay');
css_patch_min_width = 1000;

function windowWidth() {
	if (window.innerWidth) {
		return window.innerWidth;
	} else if (document.body && document.body.offsetWidth) {
		return document.body.offsetWidth;
	} else {
		return 0;
	}
}

function css_patch(elementIdsArray) {

		for (var i=0, len=css_patch_elementIdsArray.length; i<len; i++) {
			var current = $(css_patch_elementIdsArray[i]);
			if (current) {
				if (windowWidth() < css_patch_min_width) {
					current.style.width = css_patch_min_width;
				} else {
					current.style.width = '100%';
				}
			}
		}
}

// The function should be called on every resize
Event.observe(
	window, 
	'resize', 
	function() { 
		css_patch(css_patch_elementIdsArray);
	}
);

// The function should be called onLoad
Event.observe(
	window, 
	'load', 
	function() { 
		css_patch(css_patch_elementIdsArray);
	}
);