up_distance-=40;

if (!document.all) alert("Deze site is geschikt gemaakt voor IE5.5 en hoger. Mogelijk worden pagina's niet of slechts gedeeltelijk weergegeven. Onze excuses hiervoor.");

function mn_par() {
	this.move_state=0;
	this.showState=false;
	this.init_pos_x=0;
	this.init_pos_y=0;
	this.move_dist_y=0;
	this.moved_dist=0;
	this.pic_height=0;
	this.pic_width=0;
	this.wd=0;
}

function set_styles(){
	return true;
}

function get_menu_index(menu_str){
	var val_str;
	if (-1!=menu_str.indexOf('menutext')){
		val_str=menu_str.replace('menutext','');
	}else if (-1!=menu_str.indexOf('menu')){
		if (-1!=menu_str.indexOf('_')){
			dsh_pos=menu_str.indexOf('_');
			menu_str=menu_str.substr(0,dsh_pos);
		}
		val_str=menu_str.replace('menu','');
	}else{
		val_str=String("0");
	}
	return parseInt(val_str);
}

function move_down(mn_num,stp){
//alert('.');
	var menu_name='menu'+mn_num;
	var obb=menu_params[mn_num];
	var mn=document.getElementById(menu_name);

	if (!obb.moved_dist){
		mn.style.posTop=obb.init_pos_y-obb.move_dist_y;
		mn.style.visibility='visible';
	}
	mn.style.posTop+=stp;
	obb.moved_dist+=stp;
	mn.style.clip="rect("+(obb.move_dist_y-(obb.moved_dist+stp))+","+obb.wd+","+obb.move_dist_y+",0)";
}

function move_up(mn_num,stp){
	var menu_name='menu'+mn_num;
	var obb=menu_params[mn_num];
	var mn=document.getElementById(menu_name);
	mn.style.posTop-=stp;
	obb.moved_dist-=stp;
	if (obb.moved_dist<=0) mn.style.visibility='hidden';
	mn.style.clip="rect("+(obb.move_dist_y-obb.moved_dist)+","+obb.wd+","+obb.move_dist_y+",0)"; 			
}

function roll_out_menu(menu_num){
	var obb=menu_params[menu_num];
	if (obb.move_state==1){
		if (obb.moved_dist<up_distance){
			obb.moved_dist+=move_step;
		}else{
			obb.moved_dist=0;
			obb.move_state=2;
		}
	}else if (obb.move_state==2){
		if (obb.moved_dist<obb.move_dist_y)	move_down(menu_num,move_step);
			else obb.move_state=0;
	}
	
	if (obb.move_state>0) window.setTimeout("roll_out_menu("+menu_num+");",move_timeout);
		else if (obb.move_state==0)	obb.showState=true;
}

function roll_in_menu(menu_num){
	var obb=menu_params[menu_num];
	if (obb.move_state==-1){
		if (obb.moved_dist>0){
			move_up(menu_num,move_step);
		}else{
			obb.moved_dist=0;
			obb.move_state=-2;
		}	
	}else if (obb.move_state==-2){
		if (obb.moved_dist<up_distance){
			obb.moved_dist+=move_step;
		}else{
			obb.moved_dist=0;
			obb.move_state=0;
		}
	}
	if (obb.move_state<0) window.setTimeout("roll_in_menu("+menu_num+");",move_timeout);
		else if (obb.move_state==0)	obb.move_state=0;
}

function turn_off_current_div(menu_num) {
	var curr_num=get_menu_index(currentSpanElement);
	if (curr_num==menu_num)	{
		eItemOld = eval("document.getElementById('" + currentSpanElement + "')");
		currentSpanElement="";
	}
}

function roll_in_all(){
	for (var vj=0;vj<menu_params.length;vj++){
		t_ob=menu_params[vj];
		if (t_ob && (t_ob.move_state>0 || t_ob.showState)){
			t_ob.move_state=-1;
			t_ob.showState=false;
			turn_off_current_div(vj);
			roll_in_menu(vj);
		}
	}
}

function startIt(menu,thisItem,level,x_offs,y_offs) { //menu = menu to display,thisItem=coordinates of item to use,level=current depth of menus
//alert(menu_params.length);
	var menu_num=get_menu_index(menu);
	for (var vj=0;vj<menu_params.length;vj++){
		t_ob=menu_params[vj];
		if (t_ob && vj!=menu_num && (t_ob.move_state>0 || t_ob.showState)){
			t_ob.move_state=-1;
			t_ob.showState=false;
			roll_in_menu(vj);
		}
	}
	var obb=menu_params[menu_num];
	if (!obb) return;
		else if (!obb.showState && obb.move_state<=0){
			if (obb.move_state==0) obb.move_state=1;
				else if (obb.move_state==-1) obb.move_state=2;
			roll_out_menu(menu_num,0)
		}
		return;
}

function stateChange(menu,thisItem,level){
	var mn_num=get_menu_index(String(thisItem.id));	
	var obb=menu_params[mn_num];
	
	if (!obb.showState)	return;
		
	if (currentSpanElement != thisItem.Id) {		//Only hit this if they changed span elements	
		if (currentSpanElement == "") currentSpanElement = thisItem.Id;	//Used 1st time through only	

		eItemOld = document.all(currentSpanElement);
		eItemNew = thisItem;
		eItemNew.style.color=hil_col;
		eItemOld.style.color=mnu_col;
		
		eParent = eItemNew.parentNode;
		currentSpanElement = thisItem.id;		//Track where the last mouseover came from
	}
	
	if (menu != "") {
		eMenu = document.getElementById(menu);			
		eItem =thisItem;				//Used for x,y coordinates
		hideDiv(level);
		menuArray[menuArray.length] = menu;		//Tracks open menus	
		
		var positionX =  eItem.parentNode.offsetLeft + offsetMenuX + document.body.scrollLeft;
		var positionY =   eItem.parentNode.offsetTop + eItem.offsetTop + offsetMenuY;// + document.body.scrollTop;
		
		//If screen isn't wide enough to fit menu, bump menu back to the left some
		if ((positionX + eMenu.offsetWidth) >= document.body.clientWidth) {
			positionX -= (eMenu.offsetWidth * 1.3);
			positionY += 15;
		}
		//If the menu is too far to the left to display, bump it to the right some
		if ((positionX + eMenu.offsetWidth) <= eMenu.offsetWidth) {
			positionX += (eMenu.offsetWidth * 1.3);
		}
		//If the menu is too far down, bump the menu up to the bottom equals the body clientHeight property
		if ((positionY + eMenu.offsetHeight) >= document.body.clientHeight) {
			if (started != true) positionY = document.body.clientHeight - eMenu.offsetHeight;
		}
		
		eMenu.style.left = positionX;
		eMenu.style.top = positionY-5;
		eMenu.style.zIndex = level;			//Only use this if we don't reverse the arrays in the ASP/XML Script
		eMenu.style.visibility='visible';
	}
}


function hideDiv(currentLevel) {
	for (var i=currentLevel;i<menuArray.length;i++) {
		var arrayString = new String(menuArray[i]);
		if (arrayString == "undefined") continue;
		eval("document.getElementById('" + menuArray[i] + "').style.visibility='hidden'");
	}
	menuArray.length = currentLevel;
}

function hide_sub_divs(){
	for (var i=0;i<menuArray.length;i++) {
		var arrayString = new String(menuArray[i]);
		if (arrayString == "undefined") continue;
		var mn=document.getElementById(menuArray[i]);
		mn.style.visibility = "hidden";
		mn.style.left = 0;
		mn.style.top = 0;
	}
}

function set_init_vars(){
	for (var rg=1;rg<50;rg++){
	  var mn;
		if ((mn=document.getElementById("menu"+rg))!=null){
			obj_var=new mn_par();
			obj_var.move_dist_y=mn.offsetHeight;
			obj_var.init_pos_y=mn.parentNode.scrollHeight-up_distance;
			obj_var.wd=mn.offsetWidth;
			menu_params[rg] = obj_var;
		}
	}
}

function CheckMenuOver(){
	var cr_elem=document.elementFromPoint(event.x,event.y);
	if (cr_elem.className=='clsMenu' || cr_elem.className=='cellOff' || cr_elem.className=='menubgcls' || cr_elem.className=='menutxtcls'){	
		return true;
	}else{	
		return false;	
	}
}

function CheckOutState(out_elem){

	if (!out_elem && !CheckMenuOver()){
		return;
	}else if (out_elem && !CheckMenuOver()){
	  	out_elem.style.color=mnu_col;
		var mn_nm=get_menu_index(out_elem.id);
		var obb=menu_params[mn_nm];
		if (obb.move_state>=0){
			obb.move_state=-1;
			obb.showState=false;
			hide_sub_divs();
			turn_off_current_div(mn_nm);
			roll_in_menu(mn_nm);
		}
	}else if (out_elem){
		stateChange('',out_elem,'');
	}
}

document.onclick = roll_in_all;	
