Event.observe(window, 'load', function(e) {
	checkBackgroundPosition();
	
	$$("#Nav .Subnav").each(function(item) {
		$(item.parentNode).onmouseover = function() {
		    $(item.parentNode).addClassName("On");
		}
		
		$(item.parentNode).onmouseout = function() {
			$(item.parentNode).removeClassName("On");
		}
	});
});

function checkBackgroundPosition() {
	var size = Position.windowSize();
	var width = size[0] - 1004;
	if (size[0] < 1004) { size[0] = 1004; }
	size[0] = size[0] - 16;
	var offset = (size[0] / 2) - 800;
	
	$$(".Pattern")[0].setStyle({ width: size[0] + "px", backgroundPosition: offset + "px 0px" });
	$$(".Top")[0].setStyle({ width: size[0] + "px", backgroundPosition: offset + "px 0px" });
	$$(".Bottom")[0].setStyle({ width: size[0] + "px", backgroundPosition: offset + "px bottom" });
	$$("#Footer")[0].setStyle({ width: size[0] + "px" });
}

Event.observe(window, 'resize', checkBackgroundPosition);
