
function NavigateToUrl(url)
{
	this.document.location.href= url;
	window.event.returnValue = false;  
}
function ShowDescriptionTable(text) {
	descriptionbox.style.visibility='visible';
	descriptionboxtext.style.visibility='visible';
	descriptionboxtext.innerHTML=text;
}
function HideDescriptionTable() {
	descriptionbox.style.visibility='hidden';
	descriptionboxtext.style.visibility='hidden';
	descriptionboxtext.innerHTML='';
}

/*----------------------
ENTER TOETS UITSCHAKELEN
----------------------*/
if(document.addEventListener)
	document.addEventListener("keypress", HandleEnterKey, true); 
else
	document.attachEvent("onkeypress", HandleEnterKey); 
// Handle the enter key for a section of a form, binding it to the provided submit buton 
function HandleEnterKey(event) { 
	var nav = window.Event ? true : false; 
	if (nav)
		return NetscapeEventHandler_KeyDown(event); 
	else
		return MicrosoftEventHandler_KeyDown(); 
} 
function NetscapeEventHandler_KeyDown(e) { 
	if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') {
		e.returnValue = false; 
		e.cancel = true; 
		e.preventDefault(); 
		var att = e.target.getAttribute('SubmitControl'); 
		if (att != null)
			CallSubmit(att);
		return false; 
	} 
	return true; 
} 
function MicrosoftEventHandler_KeyDown() { 
	if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit') { 
		event.returnValue = false; 
		event.cancel = true; 
		var att = event.srcElement.getAttribute('SubmitControl');
		if (att != null)
			CallSubmit(att);
		return false;
	} 
	return true; 
}
/*-------------------------------------------
CLASSES MET LOGICA VOOR CLIENT SIDED CONTROLS
-------------------------------------------*/
// Maak zoekbox voor gegeven textbox en displaybox.
function SearchBox(textbox, displaybox, itemselectedfunction) {
	//if (window.Event) window.captureEvents(Event.KEYPRESS);
	displaybox.tabIndex = -1;
	textbox.displaybox = displaybox;
	textbox.onkeyup = textboxKeyup;
	textbox.onfocus = textboxFocus;
	textbox.onblur = textboxBlur;
	textbox.itemselected = itemselectedfunction;
	textbox.data = new Array(displaybox.options.length);
	displaybox.textbox = textbox;
	displaybox.onchange = displayboxChange;
	// Vul data.
	for (i = 0; i < displaybox.options.length; i++)
		textbox.data[i] = displaybox.options[i];
}
function docopyvalue(textbox, displaybox) {
	if (displaybox.selectedIndex >= 0) {
		textbox.value = displaybox.options[displaybox.selectedIndex].text;
		textbox.itemselected();
		//doHide(displaybox);
	} else {
		//textbox.focus();
	}
}
function displayboxChange(e) {
	docopyvalue(this.textbox, this);
	this.textbox.select();
}
// Enter textbox.
function textboxFocus(e) {
	this.select();
}
// Leave textbox.
function textboxBlur(e) {
	docopyvalue(this, this.displaybox);
	doHide(this.displaybox);
}
// General.
function doShow(control) {
	control.style.visibility = 'visible';
	control.style.display = 'block';
}
// General.
function doHide(control) {
	control.style.visibility = 'hidden';
	control.style.display = 'none';
}
// General.
function populateList(displaybox, searchbox) {
	// Lijst leegmaken
	while(displaybox.options.length > 0)	
		displaybox.remove(0);
	// Items die matchen uit org. lijst kopieeren naar displaybox
	var search = new String(searchbox.value).toLowerCase();
	var option;
	for (i = 0; i < searchbox.data.length; i++) {
		option = searchbox.data[i];
		if (option.text.toLowerCase().indexOf(search, 0) >= 0)
			searchbox.displaybox.options.add(option);
	}
}
// Keyup textbox.
function textboxKeyup(e) {
	var code = window.Event ? e.which : window.event.keyCode;
	//alert(code);
	switch(code) {
		case 8:  // Backspace
			if(this.value.length < 3)
				doHide(this.displaybox);
			break;
		case 13: // Enter
			docopyvalue(this, this.displaybox);
			doHide(this.displaybox);
			this.select();
			break;
		case 38: // Key up
			if (this.displaybox.selectedIndex > 0)
				this.displaybox.selectedIndex--;
			break;
		case 40: // Key down
			if (this.displaybox.selectedIndex < this.displaybox.options.length - 1)
				this.displaybox.selectedIndex++;
			break;
		default:
			if(this.value.length > 2) {
				populateList(this.displaybox, this);
				doShow(this.displaybox);
				// Indien items gevonden, deze tonen, anders input ongedaan maken
				if (this.displaybox.options.length > 0) {
					this.displaybox.selectedIndex = 0;
				} else {
					this.value = this.value.substring(0, (this.value.length - 1));
					populateList(this.displaybox, this);
					if(this.displaybox.options.length == 0)
						doHide(this.displaybox);
				}
			}
	}
}
// Maak dropdownlist die gefilterd wordt obv gekozen waarde uit een andere control
function FilterBox(listtofilter, filtercriterium, filterfield) {
	// Properties toevoegen/zetten
	filtercriterium.listtofilter = listtofilter;
	listtofilter.datacopy = new Array(listtofilter.options.length);
	listtofilter.selectedValue = listtofilter.value;
	listtofilter.filterfield = filterfield;
	// Data kopieeren van options naar datacopy
	for (i = 0; i < listtofilter.options.length; i++)
		listtofilter.datacopy[i] = listtofilter.options[i];
	// Org. lijst leegmaken
	ClearSelect(listtofilter);
	// Koppel event
	filtercriterium.onchange = doFilterList;
	// Indien criterium gezet filtering toepassen
	if (filtercriterium.selectedIndex > 0)
		filtercriterium.onchange();
}
function doFilterList(e) {
	// Oude lijst legen
	ClearSelect(this.listtofilter);
	// Filter
	for (i = 0; i < this.listtofilter.datacopy.length; i++) {
		option = this.listtofilter.datacopy[i];
		if (option.getAttribute(this.listtofilter.filterfield) == this.value
			|| option.value == "-1")
			this.listtofilter.options.add(option);
	}
	// Herstel oorspronkelijke selectie...
	var selectedSet = false;
	if (this.listtofilter.selectedValue != null) {
		for (i = 0; i < this.listtofilter.options.length; i++) {
			if (this.listtofilter.selectedValue == this.listtofilter.options[i].value) {
				this.listtofilter.selectedIndex = i;
				selectedSet = true;
				break;
			}
		}
	}
	// ...of selecteer eerste
	if(selectedSet == false && this.listtofilter.length > 0)
		this.listtofilter.selectedIndex = 0;
	// Genereer change event op de gefilterde list.
	if (this.listtofilter.onchange != null)
		this.listtofilter.onchange();
}
// Maak gegeven select box leeg.
function ClearSelect(select) {
	while(select.options.length > 1)
		select.remove(1);
	if(select.options.length > 0)
		select.remove(0);
}

// MH: Functie voor popup (identiek aan Finance .Net en ASP Finance)
function LaunchPopup( sURL , sWidth, sHeight, sPopupName, bToolbars) {
  var dPerc;
  var sToolbars;

  sToolbars = ""
 
  if (!sPopupName)
	  sPopupName = 'wndPopup'

  if (!sWidth)
	sWidth = "400"
  else
	sWidth = sWidth.toString()
  if (!sHeight)
	sHeight = "300"
  else
	sHeight = sHeight.toString()

  if (bToolbars)
	sToolbars = ",location=yes,menubar=yes,status=yes,titlebar=yes,toolbar=yes"

  // % must be the last character if a percentage of the screen must be show
  if (sHeight.indexOf('%') == sHeight.length-1) {
		// Calculate relative height of screen with screensize as maximum
		dPerc = sHeight.substr(0,sHeight.length-1).valueOf() / 100.0;
		sHeight = window.screen.availHeight * dPerc;
  }
  if (sWidth.indexOf('%') == sWidth.length-1) {
		// Calculate relative width of screen with screensize as maximum
		dPerc = sWidth.substr(0,sWidth.length-1).valueOf() / 100.0;
		sWidth = window.screen.availWidth * dPerc;
  }
  //Centreer de offerte op het scherm
  var iTop, iLeft
  iLeft = (window.screen.availWidth - sWidth.valueOf()) / 2
  iTop = (window.screen.availHeight - sHeight.valueOf()) / 2
  
  window.open( sURL, sPopupName,'resizable=yes,scrollbars=yes,top=' + iTop +',left=' + iLeft +',width=' + sWidth + ',height=' + sHeight + sToolbars);
}