/* FUNCTIONS FOR SUBMENU - BEGIN */

function showSubmenu(s, w) {
	if(w == 0) {identifier = s.name.toLowerCase().replace(/ /g, "").replace(/_1/g, "");}
	if(w == 1) {identifier = s.id;}
	submenuMarginLeft = -7;
	var elements = document.getElementsByTagName('a');
	for (var i = 0; i < elements.length; i++) {
		if(elements[i].className == "menu_item") {
			if(w == 0) {
				if(elements[i].name == s.name) {
					break;
				}
			} else {
				if(elements[i].name.toLowerCase().replace(/ /g, "") == s.id) {
					break;
				}			
			}
			submenuMarginLeft += elements[i].offsetWidth;
		}
	}
	if(w == 0) {
		eval("if(document.getElementById('" + identifier + "')){document.getElementById('" + identifier + "').style.marginLeft = submenuMarginLeft;}");
	}
	eval("if(document.getElementById('" + identifier + "')){document.getElementById('" + identifier + "').style.display = 'block';}");
}

function hideSubmenu(s) {
	var elements = document.getElementsByTagName('div');
	for (var i = 0; i < elements.length; i++) {
		if(elements[i].className == "submenu") {
			elements[i].style.display = 'none';
		}
	}
}

/* END */




var menu_time;

function show_submenu(index) {
	for (var i=0;i<100;i++) 	
		if (document.getElementById('submenu_'+i)) {
			if (i==index) {
				document.getElementById('submenu_'+i).style.left=parseInt(getX(document.getElementById('menu_'+i)))+'px';
				document.getElementById('submenu_'+i).style.top=parseInt(getY(document.getElementById('menu_'+i))+document.getElementById('menu_'+i).offsetHeight)+'px';
				document.getElementById('submenu_'+i).style.display='block';
			} else {								
				document.getElementById('submenu_'+i).style.display='none';
			}
		}
}

function hide_submenu(i) {
	if (document.getElementById('submenu_'+i)) {
		document.getElementById('submenu_'+i).style.display='none';
	}
}

//leadmanager

function submit_form(id) {
	document.getElementById('form_'+id).command.value=id;
	document.getElementById('form_'+id).submit();
}

function send_this_article(id) {
	document.getElementById('form_'+id).command.value='send_article';
	document.getElementById('form_'+id).submit();
}

function area_limit(field,limit) {
	var n = field.value.length
	if (n > limit)
		field.value = field.value.substring(0, limit);
}

function set_command(form,value) {
	document.getElementById(form).command.value=value;
}

//leadmanager


//kennis
function open_cat_tree(i) {
	if (document.getElementById('cat_h_'+i)) {
		if (document.getElementById('cat_h_'+i).className=='no_disp') {
			document.getElementById('cat_h_'+i).className='disp';
			document.getElementById('cat_h_'+i).style.marginTop='10px';
			document.getElementById('sign_'+i).src=host+'/design/minus.png';
		} else {
			document.getElementById('cat_h_'+i).className='no_disp';
			document.getElementById('cat_h_'+i).style.marginTop='0px';
			document.getElementById('sign_'+i).src=host+'/design/plus.png';
		}
	}
}

function show_login_form() {
	document.getElementById('reg_holder').style.display='none';
	document.getElementById('login_holder').style.display='block';	
	remove_shadow('tt');
	add_wnd_shadow('tt');		
}

//logout
function logout(msg,url) {
	if (confirm(msg))
		window.location=url;
}

//
function getX(oElement) { var iReturnValue = 0; while(oElement!=null) { iReturnValue += oElement.offsetLeft; oElement = oElement.offsetParent; } return iReturnValue; };
function getY(oElement) { var iReturnValue = 0; while(oElement!= null) { iReturnValue += oElement.offsetTop; oElement = oElement.offsetParent; } return iReturnValue; };	

function getPageSizeWithScroll(direction)
{     
	if (window.innerHeight && window.scrollMaxY) 
	{
		// Firefox         
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;     
	} else if (document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac         
		yWithScroll = document.body.scrollHeight;         
		xWithScroll = document.body.scrollWidth;     
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari         
		yWithScroll = document.body.offsetHeight;         
		xWithScroll = document.body.offsetWidth;
	}     
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);     
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );     
	if (direction=='w')
		return xWithScroll;
	if (direction=='h')
		return yWithScroll;
}

function black_wall(visible) {
	if (parseInt(visible)==1) {
		page_height=getPageSizeWithScroll('h');
		page_width=getPageSizeWithScroll('w');
		document.getElementById('black_wall').className='black_wall_1';		
		document.getElementById('black_wall').style.height=page_height;	
		document.getElementById('black_wall').style.width=page_width;	
	} else {
		document.getElementById('black_wall').className='black_wall_0';	
	}
	
}

function show_article() {
	var tt = document.createElement("div");
	tt.id="wnd__";
	tt.style.width='711px';
	tt.style.position='absolute';
	var x=getPageSizeWithScroll('w');	
	tt.style.left=(x-711)/2;
	var y=getY(document.getElementById('follow_up_2'));
	tt.style.top=y-149;
	tt.style.paddingTop='10px';
	tt.style.border='0px';
	tt.style.color='#000000';
	tt.style.fontFamily='arial';
	tt.style.fontSize='12px';
	tt.style.zIndex=11000;
	tt.innerHTML="<table cellpadding=0 cellspacing=0 class=\"wnd___\"><tr><td class=\"lt\"></td><td class=\"t\"></td><td class=\"rt\"></td></tr><tr><td colspan=3 class=\"m\"><div class=\"back_btn\"><a href=\""+back_url+"\">sluiten</a></div>"+document.getElementById('follow_up_2').innerHTML+"</td></tr><tr><td class=\"lb\"></td><td class=\"b\"></td><td class=\"rb\"></td></tr></table>";
	var x_=document.getElementById('follow_up_2').offsetWidth;
	var y_=document.getElementById('follow_up_2').offsetHeight;
	document.getElementById('follow_up_2').style.width=x_;
	document.getElementById('follow_up_2').style.height=y_;
	document.getElementById('follow_up_2').innerHTML='';
	tt.id='tt';
	document.body.appendChild(tt);
	add_wnd_shadow(tt.id);
	
	black_wall(1);
}

function add_wnd_shadow(id) {
	var obj=document.getElementById(id);
	var x=getX(obj);
	var y=getY(obj);
	var w=obj.offsetWidth;
	var h=obj.offsetHeight;
	var start_t=y;
	var end_t=y+h;
	var start_l=x;		
	var end_l=x+w;		

	var img_lt = document.createElement("img");
	img_lt.id=id+'_lt';	
	img_lt.src='img/dialog_lt.png';
	img_lt.width=12;
	img_lt.height=12;
	img_lt.style.position='absolute';
	img_lt.style.top=start_t+10;
	img_lt.style.left=end_l-2;
	img_lt.style.border='0px';
	img_lt.style.zIndex=10000;
	document.body.appendChild(img_lt);
	
	var img_l = document.createElement("img");
	img_l.id=id+'_l';	
	img_l.src='img/dialog_l.png';
	img_l.width=12;
	img_l.height=parseInt(h-22-2);
	img_l.style.position='absolute';
	img_l.style.top=parseInt(start_t+22);
	img_l.style.left=end_l-2;
	img_l.style.border='0px';
	img_l.style.zIndex=10000;
	document.body.appendChild(img_l);	
	
	var img_lb = document.createElement("img");
	img_lb.id=id+'_lb';	
	img_lb.src='img/dialog_lb.png';
	img_lb.width=12;
	img_lb.height=17;
	img_lb.style.position='absolute';
	img_lb.style.top=end_t-3;
	img_lb.style.left=start_l+5;
	img_lb.style.zIndex=10000;
	img_lb.style.border='0px';
	document.body.appendChild(img_lb);			
	
	var img_rb = document.createElement("img");
	img_rb.id=id+'_rb';	
	img_rb.src='img/dialog_rb.png';
	img_rb.width=12;
	img_rb.height=17;
	img_rb.style.position='absolute';
	img_rb.style.top=end_t-2;
	img_rb.style.left=end_l-2;
	img_rb.style.border='0px';
	img_rb.style.zIndex=10000;
	document.body.appendChild(img_rb);		

	var img_b = document.createElement("img");
	img_b.id=id+'_b';	
	img_b.src='img/dialog_b.png';
	img_b.width=parseInt(w-19);
	img_b.height=17;
	img_b.style.position='absolute';
	img_b.style.top=end_t-3;
	img_b.style.border='0px';
	img_b.style.left=parseInt(start_l+17);
	img_b.style.zIndex=10000;
	document.body.appendChild(img_b);		
		
}

function remove_shadow(id) {
	clear_wnd(id+'_lt');
	clear_wnd(id+'_l');
	clear_wnd(id+'_lb');
	clear_wnd(id+'_rb');
	clear_wnd(id+'_b');	
}

function clear_wnd(id) {	
	if (document.getElementById(id))
		document.body.removeChild(document.getElementById(id));
}


function preloader(src) {
	heavyImage = new Image(); 
	heavyImage.src = src;
}