
function loadSubMenu(pageID) {
	$('submenu_container').innerHTML = '';
	//load current submenu into submenu-section
	if (!isNaN(pageID)) {	//check if pageID is numeric
		if ($('li'+pageID) != undefined) { //check if li exists
			var oMenu = $('li'+pageID);
			if (oMenu.childNodes.length > 1) { //check if menu has submenu
				var thisTitle = '<h1>' + oMenu.childNodes[0].innerHTML + '</h1>';
				var thisSubMenu = '<ul id=submenu>' + oMenu.childNodes[1].innerHTML + '</ul>';
				$('submenu_container').innerHTML = thisTitle + thisSubMenu;
			}
		}
	}
	return true;
}

// Resize window
function resizeWindow() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	var margintop = (myHeight  - 580)/2;
	if (margintop<1)margintop = 0;
  $("container").style.margin = margintop+"px auto 0px auto";
}


// verbeterde functie om eerste form-element te selecteren indien aanwezig
function focusFirst() {
	if ((typeof(document.forms[1]) != "undefined")) {
		if ((typeof(document.forms[1].elements[0]) != "undefined")) {
			document.forms[1].elements[0].focus();
		}
	}
}

//functie om pagina te openen via javascript
function go(paginaURL) {
	parent.location.href = paginaURL;
}



// event handling and $-function--------------------------------------------

function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}


function removeEvent( obj, type, fn )
{
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent)
	{
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}
function addLoadEvent(func) {
	var oldonload = window.onload;

	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
// -------------------------------------------------------------------------


// string manipulations ----------------------------------------------------
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function trim(str){   return str.replace(/^\s*|\s*$/g,"");}


// -------------------------------------------------------------------------

/* ================ Automatic Popup's ================ */
function setPopLinks() {
	var x = document.getElementsByTagName('a');
 	for (var i=0;i<x.length;i++) {
		if (x[i].className == 'popup' || x[i].className == 'popupNoImg') {
			x[i].onclick = function () {
				return pop(this.href)
			}
			x[i].title += ' (opent in nieuw venster)';
		}
	}
}

function pop(url) {
	newwindow=window.open(url);
	if (window.focus) {newwindow.focus()}
	return false;
}
// -------------------------------------------------------------------------	
