// JavaScript for Visualminimal template

	var layoutChange = 0;

	function setHeight() {
	
		// To find the proper height for the body_container <div>
		var contentHeight = document.getElementById('contents').offsetHeight;
		var leftHeight = document.getElementById('mod_left').offsetHeight;
		var rightHeight = document.getElementById('mod_right').offsetHeight;	
	
		var newHeight = Math.max(contentHeight, leftHeight, rightHeight); //Find the tallest div
		
		//alert('ModLeft: '+leftHeight+', NewHeight: '+newHeight);
		
		if(newHeight) {
			
			if( (leftHeight > contentHeight) || (rightHeight > contentHeight) ) {
				var modHeight = newHeight;
				newHeight = newHeight + 28;
 			 } else {
				 var modHeight = newHeight - 28;  // minus 28px to the module height so that the vertical lines will not exceed length of body.
			 }
			 
			document.getElementById('body_container').style.height = newHeight +'px'; // Assign tallest height to body_container tag
			document.getElementById('mod_left').style.height = modHeight +'px';
			document.getElementById('mod_right').style.height = modHeight +'px';
		}
	}
	
	function toggleLayout() {
	
		if(layoutChange == 0) {
			document.getElementById('mod_right').style.visibility = 'hidden';
			document.getElementById('mod_right').style.display = 'none';
			document.getElementById('contents').style.width = '600px';
			layoutChange = 1;
		} else if(layoutChange == 1) {
			document.getElementById('mod_right').style.visibility = 'visible';
			document.getElementById('mod_right').style.display = 'inline';
			document.getElementById('contents').style.width = '466px';
			layoutChange = 0;
		}
	}
	
	window.onload = function() {
		setHeight();
	}
	
	window.onresize = function() {
		location.reload();
	}