
// Set the min-width style property of the <body> tag 
// according to the total width of the menu items.
function calculateWidth() {
  
	// mainmenu
	var menuItems = document.getElementById("sectionsmenu").firstChild.childNodes;
	var  menuWidth = 0;
	for (var i=0; i<menuItems.length; i++) {
		menuWidth += menuItems[i].offsetWidth;
	}
  
	// submenu
	var subMenuWidth = 0;
	if (document.getElementById("submenu") != null) {
		var subMenuItems = document.getElementById("submenu").firstChild.childNodes;
		for (var i=0; i<subMenuItems.length; i++) {
			subMenuWidth += subMenuItems[i].offsetWidth;
		}
	}
	
	var maxMenuWidth = Math.max(menuWidth + 242 + 10, subMenuWidth + 10);
  
        if (maxMenuWidth < 792) maxMenuWidth = 792;
	
	document.body.style.minWidth = (maxMenuWidth) + "px";
  
}

window.onload = calculateWidth;
