/*---------------------------------------------------------------------------*\
	S T A N D A A R D
\*---------------------------------------------------------------------------*/

function gotoURL(url)
{
	document.location.href = url;
}

function popUp(url)
{
	var window_object = window.open(url, '', 'directories = no, height = 500, left = 190, location = no, menubar = no, resizable = no, status = no, titlebar = no, toolbar = no, top = 220, width = 600');
}

function popUpCustom(url, size)
{
	var screen_height = screen.height;
	var screen_width = screen.width;
	
	var left_pos = (screen_width - size) / 2;
	var top_pos  = (screen_height - size) / 2;
	
	var window_object = window.open(url, '', 'directories = no, height = ' + size + ', left = ' + left_pos + ', location = no, menubar = no, scrollbars = yes, resizable = no, status = no, titlebar = no, toolbar = no, top = ' + top_pos + ', width = ' + size);	
}

function popUpMinimal(url)
{
	var screen_height = screen.height;
	var screen_width = screen.width;
	
	var left_pos = (screen_width - 200) / 2;
	var top_pos  = (screen_height - 200) / 2;
	
	var window_object = window.open(url, '', 'directories = no, height = 200, left = ' + left_pos + ', location = no, menubar = no, resizable = no, status = no, titlebar = no, toolbar = no, top = ' + top_pos + ', width = 200');
}

/*---------------------------------------------------------------------------*\
	M E N U
\*---------------------------------------------------------------------------*/

var menu_delay       = 1000; //in ms
var start_position_x = 10;//(((Screen.Width - 800) / 2) + 21)
//var start_position_x = 21; //in px
//start_position_x     = ((Screen.Width - 800) / 2) + start_position_x;
var start_position_y = 0; //in px

//pos correction for non IE browsers
var browser_type = navigator.userAgent.toLowerCase();

if(!browser_type.match("ie"))
{

		var start_position_x = 241;
		var start_position_y = 172;
}

var step_x           = 170; //in px
var step_y           = 27;  //in px
var margin_x         = 0;  //in px
var margin_y         = 5;   //in px

function generateHTMLMenu(menu_array)
{
	//generate menu
	generateMenu(menu_array, "1", 0, 0);
}

function generateMenu(menu_array, id, depth, row)
{
	if(menu_array.length > 0)
	{	
		//generate new (sub)menu
		generateMenuHeader(id, depth, row); //menu header	
		
		for(var i = (depth > 0 ? 1 : 0); i < menu_array.length; i++)
		{
			generateMenuItem(menu_array[i], (id + "_" + i), depth);
		}	
		generateMenuFooter(); //menu footer
	}
	
	//generate submenu(s) of this menu
	for(var si = (depth > 0 ? 1 : 0); si < menu_array.length; si++)
	{
		if(typeof(menu_array[si][1]) == "object")
		{
			generateMenu(menu_array[si], (id + "_" + si), (depth + 1), ((row + si) - (depth > 0 ? 1 : 0)), row);
		}
	}
}

function generateMenuHeader(id, depth, row)
{
	if(depth > 0)
	{
		//iframe must be used with IE
		var browser_type = navigator.userAgent.toLowerCase();
		
		if(browser_type.match("ie"))
		{
			document.write("<iframe frameborder=\"0\" id=\"iframe_"+ id +"\" style=\"height: 0px; left: "+ ((start_position_x + (depth * step_x)) + (depth > 0 ? (margin_x * depth) : 0)) +"px; position: absolute; top: "+ ((start_position_y + (row * step_y)) + (depth > 0 ? (margin_y * depth) : 0)) +"px; visibility: "+ (depth > 0 ? "hidden" : "visible") +"; width: "+ (depth > 0 ? "0px" : (step_x + "px")) +"; z-index: 10;\"></iframe>");
		}
	}

	document.write("<div id=\""+ id +"\" style=\"left: "+ ((start_position_x + (depth * step_x)) + (depth > 0 ? (margin_x * depth) : 0)) +"px; position: absolute; top: "+ ((start_position_y + (row * step_y)) + (depth > 0 ? (margin_y * depth) : 0)) +"px; visibility: "+ (depth > 0 ? "hidden" : "visible") +"; width: "+ step_x +"px; z-index: 10;\">"+
								 "	<table cellpadding=\"0\" cellspacing=\"0\" id=\""+ (depth == 0 ? "main" : "sub") +"menu\">");
}

function generateMenuItem(menu_array, id, depth, row)
{
	var menu_type = "" + (depth == 0 ? "main" : "sub") + "menu_" + (typeof(menu_array[1]) == "string" ? "" : "sub") + "item";
	
	document.write("		<tr id=\""+ menu_type +"\""+ (typeof(menu_array[1]) == "string" ? " onClick=\"gotoURL('"+ menu_array[1] +"');\"" : "") +" onMouseOver=\"this.id = '"+ menu_type +"_mouseover'; showMenuDelayed('"+ id +"');\" onMouseOut=\"this.id = '"+ menu_type +"'; hideMenuDelayed('"+ id +"');\">"+
								 "			<td id=\""+ menu_type +"\">"+
								 "				"+ menu_array[0] +""+
								 "			</td>"+
								 "		</tr>");
}

function generateMenuFooter()
{
	document.write("	</table>"+
								 "</div>");
}

/*###########################################################################*\
	Functions used by the JavaScript menu for hiding and displaying submenu(s):
\*###########################################################################*/

/*---------------------------------------------------------------------------*\
	show menu:
\*---------------------------------------------------------------------------*/

var last_show_string = "0";
var menu_delay_obj   = null;
var menu_delay_obj2  = null;

function showMenuDelayed(string)
{					
	if(menu_delay_obj != null){ clearTimeout(menu_delay_obj); }
	hideMenu(last_show_string);
	showMenu(string);
}

function showMenu(string)
{
	var menu = giveMenus(string);
	for(var i = 1; i < menu.length; i++)
	{
		var object = document.getElementById(menu[i]);
		if(object != null){ object.style.visibility = 'visible'; }
		var iframe = document.getElementById("iframe_" + menu[i]);
		if(iframe != null)
		{			
			iframe.style.width = object.offsetWidth;
			iframe.style.height = object.offsetHeight;
			iframe.style.visibility = 'visible';
		}
	}
	last_show_string = string
}

/*---------------------------------------------------------------------------*\
	hide menu:
\*---------------------------------------------------------------------------*/

function hideMenuDelayed(string)
{
	last_show_string = string;
	var task = "hideMenu('"+ string +"');";
	menu_delay_obj2 = menu_delay_obj;
	menu_delay_obj = setTimeout(task, menu_delay);
}

function hideMenu(string)
{	
	var menu = giveMenus(string);
	for(var i = menu.length - 1; i > 0; i--)	
	{
		var object = document.getElementById(menu[i]);
		if(object != null){ object.style.visibility = 'hidden'; }
		var iframe = document.getElementById("iframe_" + menu[i]);
		if(iframe != null)
		{
			iframe.style.visibility = 'hidden';
			iframe.style.width = 0;
			iframe.style.height = 0;
		}
	}
}

/*---------------------------------------------------------------------------*\
	util:
\*---------------------------------------------------------------------------*/

function giveMenus(string)
{
	if(string == null){ string = "0"; }
	
	var menus = new Array();
	var m_item = 0;
	for(var i = 0; i < string.length; i++)
	{
		if(string.charAt(i) == '_'){ m_item++; }
		else
		{
			if(menus[m_item] == null){ if(m_item == 0){ menus[m_item] = ""; } else{ menus[m_item] = menus[m_item - 1] + "_"; } }
			menus[m_item] = menus[m_item] + string.charAt(i);
		}
	}
	return menus;
}

/*---------------------------------------------------------------------------*\
	B E R I C H T
\*---------------------------------------------------------------------------*/

function displayText()
{
	var key_code = window.event.keyCode;
	var shift_pressed = window.event.shiftKey;
	var chr = "";
	
	//cijfers
	if(key_code == 48){ chr = "0"; }
	if(key_code == 49){ chr = "1"; }
	if(key_code == 50){ chr = "2"; }
	if(key_code == 51){ chr = "3"; }
	if(key_code == 52){ chr = "4"; }
	if(key_code == 53){ chr = "5"; }
	if(key_code == 54){ chr = "6"; }
	if(key_code == 55){ chr = "7"; }
	if(key_code == 56){ chr = "8"; }
	if(key_code == 57){ chr = "9"; }
	
	//(kleine) letters
	if(key_code == 65 && !shift_pressed){ chr = "a"; }
	if(key_code == 66 && !shift_pressed){ chr = "b"; }
	if(key_code == 67 && !shift_pressed){ chr = "c"; }
	if(key_code == 68 && !shift_pressed){ chr = "d"; }
	if(key_code == 69 && !shift_pressed){ chr = "e"; }
	if(key_code == 70 && !shift_pressed){ chr = "f"; }
	if(key_code == 71 && !shift_pressed){ chr = "g"; }
	if(key_code == 72 && !shift_pressed){ chr = "h"; }
	if(key_code == 73 && !shift_pressed){ chr = "i"; }
	if(key_code == 74 && !shift_pressed){ chr = "j"; }
	if(key_code == 75 && !shift_pressed){ chr = "k"; }
	if(key_code == 76 && !shift_pressed){ chr = "l"; }
	if(key_code == 77 && !shift_pressed){ chr = "m"; }
	if(key_code == 78 && !shift_pressed){ chr = "n"; }
	if(key_code == 79 && !shift_pressed){ chr = "o"; }
	if(key_code == 80 && !shift_pressed){ chr = "p"; }
	if(key_code == 81 && !shift_pressed){ chr = "q"; }
	if(key_code == 82 && !shift_pressed){ chr = "r"; }
	if(key_code == 83 && !shift_pressed){ chr = "s"; }
	if(key_code == 84 && !shift_pressed){ chr = "t"; }
	if(key_code == 85 && !shift_pressed){ chr = "u"; }
	if(key_code == 86 && !shift_pressed){ chr = "v"; }
	if(key_code == 87 && !shift_pressed){ chr = "w"; }
	if(key_code == 88 && !shift_pressed){ chr = "x"; }
	if(key_code == 89 && !shift_pressed){ chr = "y"; }
	if(key_code == 90 && !shift_pressed){ chr = "z"; }

	//(hoofd) letters
	if(key_code == 65 && shift_pressed){ chr = "<b>A</a>"; }
	if(key_code == 66 && shift_pressed){ chr = "B"; }
	if(key_code == 67 && shift_pressed){ chr = "C"; }
	if(key_code == 68 && shift_pressed){ chr = "D"; }
	if(key_code == 69 && shift_pressed){ chr = "E"; }
	if(key_code == 70 && shift_pressed){ chr = "F"; }
	if(key_code == 71 && shift_pressed){ chr = "G"; }
	if(key_code == 72 && shift_pressed){ chr = "H"; }
	if(key_code == 73 && shift_pressed){ chr = "I"; }
	if(key_code == 74 && shift_pressed){ chr = "J"; }
	if(key_code == 75 && shift_pressed){ chr = "K"; }
	if(key_code == 76 && shift_pressed){ chr = "L"; }
	if(key_code == 77 && shift_pressed){ chr = "M"; }
	if(key_code == 78 && shift_pressed){ chr = "N"; }
	if(key_code == 79 && shift_pressed){ chr = "O"; }
	if(key_code == 80 && shift_pressed){ chr = "P"; }
	if(key_code == 81 && shift_pressed){ chr = "Q"; }
	if(key_code == 82 && shift_pressed){ chr = "R"; }
	if(key_code == 83 && shift_pressed){ chr = "S"; }
	if(key_code == 84 && shift_pressed){ chr = "T"; }
	if(key_code == 85 && shift_pressed){ chr = "U"; }
	if(key_code == 86 && shift_pressed){ chr = "V"; }
	if(key_code == 87 && shift_pressed){ chr = "W"; }
	if(key_code == 88 && shift_pressed){ chr = "X"; }
	if(key_code == 89 && shift_pressed){ chr = "Y"; }
	if(key_code == 90 && shift_pressed){ chr = "Z"; }

  var front_text = document.getElementById("front_text"); //div
	var current_message = front_text.innerHTML + "";
	current_message = current_message + chr;
	front_text.innerHTML = current_message;
}