$(document).ready(function() {
	$(window).load(mensubHeight);
});

function mensubHeight() {
	var menu_sub = $("#menu_sub").height();
	var ht = "height: ";
	var content = ($("#content").height()+68);
	var content_sub = $("#content_sub").height();

	// if content_sub doesn't exist we need only compare menu_sub with content
	if (content_sub == null) {
		
		// If menu_sub is taller than content do nothing 
		if (menu_sub > content) {
			return;
		}
		else {
		// Set ht to the same as content
		ht = ht + content + "px;";
		}

	}
	else {
	
		// if content_sub does exist, check if it is taller than content
		if (content > content_sub) {
			
			// If menu_sub is taller than content do nothing 
			if (menu_sub > content) {
				return;
			}
			else {
			// Set ht to the same as content_sub
			ht = ht + content + "px;";
			}
		}
		else {
		// content_sub is taller than content
		
			// If menu_sub is taller than content_sub do nothing 
			if (menu_sub > content_sub) {
				return;
			}
			else {
			// Set ht to the same as content_sub
			ht = ht + content_sub + "px;";
			}
			
		}
	}
		
	// set CSS height of menu_sub
	$("#menu_sub").attr("style",ht);
	
}

