/** shortcur for getElementById() **/
var $=function(id){return document.getElementById(id);};

/** onloadStack, allows for multiple events to happen onload **/
//var __onloadStack = new Array();

/*window.onload = function() {
	for (i in __onloadStack) {
		__onloadStack[i]();
	}
}*/

/** string **/
function lTrim(string) { var space = ' ';
	for (var i=0; i<string.length; i++) {if (string.charAt(i) != space) { return string.substring(i,string.length); } }
	return '';
}
function rTrim(string) {
	var space = ' ';
	for (var i=string.length; i>0; i--) { if (string.charAt(i-1) != space) { return string.substring(0,i); } }
	return '';
}
function trim(string) { return lTrim(rTrim(string)); }
function createRandomId(prefix) {
	if (!prefix) { prefix = 'rnd'; }
	var rnd = Math.ceil(10000*Math.random());
	var id = '' + prefix + rnd;
	while (document.getElementById(id)) {
		var rnd = 1000*Math.random();
		id = '' + prefix + rnd;
	}
	return id;
}
/** Dom helper **/
function element(type) { return document.createElement(type); }
function plainElement(type, text) { var e = element(type); e.appendChild(document.createTextNode(text)); return e; }
function createLabel(forid, text) {	var l = plainElement('label', text); l.setAttribute('for', forid); return l; }
function createInput(type, id, value) { i = document.createElement('input'); i.type=type; i.id=id; if (value.length) { i.value=value; }	return i; }
function createTextArea(id, value) { var t = plainElement('textarea', value); t.id = id; return t; }

function clearzoek(element){
	if(element.value=='Vul zoekterm in'|| element.value=='Enter search string'){
		element.value='';
	}
}

/************************************************************
Openen van een simpele window;
Argumenten: URL, titel window, breedte en hoogte.
Eigenschappen window:
	toolbar=no;
	location=no;
	directories=no;
	status=no;
	menubar=no;
	scrollbars=yes;
	resizable=no;
	copyhistory=no;
************************************************************/
function openWindowSimpel(strURL,strWindowName,intWidth,intHeight){
	intLeftPosition = (screen.width) ? (screen.width-intWidth)/2 : 0;
	intTopPosition = (screen.height) ? (screen.height-intHeight)/2 : 0;
	window.open(strURL,strWindowName,"top="+intTopPosition+",left="+intLeftPosition+",toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=" + intWidth + ", height=" + intHeight);
}

