function calculate_menu_overflow(){
	setTimeout("calculate_menu()",200);
}

function calculate_menu(){
var menuElem = document.getElementById('menu');
var menu_textElem = document.getElementById('menu_text_container');

	 var differenz = menuElem.offsetHeight - menu_textElem.offsetHeight;
  
  	var menunavt = document.getElementById('menu_navigator_top');
  	var menunavb = document.getElementById('menu_navigator_bottom');
  if(differenz < 1){
  	menunavt.style.visibility = "visible";
  	menunavb.style.visibility = "visible";
  }else{
  	menunavt.style.visibility = "hidden";
  	menunavb.style.visibility = "hidden";
  	document.getElementById('navit').style.setProperty("margin-top", "0px","");
  }
  
  return differenz;
}



function expandingMenu(num,killa,killb) {
	var speed_out = 200;
	var speed_in = 200;
	
	var search_for = "#menu ul";
	//var search_for = "#menu ul li .sectiontitle ";
	
	var item_title = $(search_for).eq(num).children(":first");
	var items = $(search_for).eq(num).children().filter(function (index) { return index > 0; });
	var killa_title = $(search_for).eq(killa).children(":first");
	var killa_it = $(search_for).eq(killa).children().filter(function (index) { return index > 0; });
	var killb_title = $(search_for).eq(killb).children(":first");
	var killb_it = $(search_for).eq(killb).children().filter(function (index) { return index > 0; });
	
	var index_title = $(search_for).eq(0).children(":first");
	var index_it = $(search_for).eq(0).children().filter(function (index) { return index > 0; });

	
	/* hide items if not active */
	if (items.is(".active") == false) {
		items.hide();
	}

	/* add click functions + pointer to title */
	item_title.css({cursor:"pointer"}).toggle(
		function () {
			
			killa_it.hide(speed_out);
			killb_it.hide(speed_out);
			items.show(speed_in);
			calculate_menu_overflow();
			reset_menu_nav(num);
			
			
			
		}, function () {
			items.hide(speed_out);
			//index_it.show(speed_in);			
			calculate_menu_overflow();
			reset_menu_nav(num);
		}
	)
	
}


function expandingChildMenu(num,numchild,killa,killb) {
	var speed_out = 200;
	var speed_in = 200;
	
	var search_for = "#menu ul";
	//var search_for = "#menu ul li .sectiontitle ";
	
	var item_title = $(search_for).eq(num).children(":first");
	var items = $(search_for).eq(num).children().filter(function (index) { return index > 0; });
	var killa_it = $(search_for).eq(killa).children().filter(function (index) { return index > 0; });
	var killb_title = $(search_for).eq(killb).children(":first");
	var killb_it = $(search_for).eq(killb).children().filter(function (index) { return index > 0; });
	
	var elem = 0;
		
	var index_title = $(search_for).eq(0).children(":first");
	var index_it = $(search_for).eq(0).children().filter(function (index) { return index > 0; });

	
	/* hide items if not active */
	if (items.is(".active") == false) {
		items.hide();
	}

	/* add click functions + pointer to title */
	item_title.css({cursor:"pointer"}).toggle(
		function () {
			killa_it.hide(speed_out);
			killb_it.hide(speed_out);
			for(i=0;i<numchild;i++){
				elem = num + 1 + i;
				killer = $(search_for).eq(elem).children().filter(function (index) { return index > 0; });
				killer.hide(0);
			}
			items.show(speed_in);
			
			
		}, function () {
			items.hide(speed_out);
			//index_it.show(speed_in);			
		}
	)
}



function activeChildMenu(num,numchild) {
	var speed_out = 200;
	var speed_in = 200;

	var item_title = $(search_for).eq(num).children(":first");
	var items = $(search_for).eq(num).children().filter(function (index) { return index > 0; });

	
	var search_for = "#menu ul";
	//var search_for = "#menu ul li .sectiontitle ";
	var elem = 0;
	/* hide items if not active */
	if (items.is(".active") == false) {
		items.hide();
	}
	/* add click functions + pointer to title */
	item_title.css({cursor:"pointer"}).toggle(
		function () {

			for(i=0;i<numchild;i++){
				elem = num + 1 + i;
				if(elem == num){
					killer = $(search_for).eq(elem).children().filter(function (index) { return index > 0; });
					killer.show(speed_in);
				}else{
					killer = $(search_for).eq(elem).children().filter(function (index) { return index > 0; });
					killer.hide(0);
				}
			}
			
			
		}, function () {
			items.hide(speed_out);
			//index_it.show(speed_in);			
		}
	)
}



