	// Checks if a string is empty
	function emptystr(string) {
		var x = 0;
		var chr;
		var empty = true;
		if (string.length) {
			do {
				chr = string.substring(x, x + 1);
				x++;
				empty = (chr == ' ' || chr == '\t' || chr == '\n' || chr == '\r');
			} while (empty && x < string.length);
		}
		return empty;
	} // function

	function showAlert(item, name) {
		if (emptystr(document.regform.elements[item].value)) {
			alert('U heeft het veld ' + name + ' vergeten in te vullen!');
			document.regform.elements[item].focus();
			return false;
		}
		else {
			return true;
		}
	} // function

	function checkEmail(item) {
		var pattern=/(^[\-_\.a-zA-Z0-9]+)@((([0-9]{1,3}\.){3}([0-9]{1,3})((:[0-9])*))|(([a-zA-Z0-9\-]+)(\.[a-zA-Z]{2,})+(\.[a-zA-Z]{2})?((:[0-9])*)))/;
		if (document.regform.elements[item].value.search(pattern) == -1) {
			alert('Geen geldig e-mail adres opgegeven.');
			document.regform.elements[item].focus();
			return false;
		}
		else	{
			return true;
		}
	} // function

	function checkForm() {
		return (
			showAlert('bedrijfsnaam','bedrijfsnaam') &&
			showAlert('adres', 'adres') &&
			showAlert('postcode', 'postcode') &&
			showAlert('plaats', 'plaats') &&
			showAlert('land', 'land') &&
			showAlert('tel', 'telefoonnummer') &&
			showAlert('kvk', 'KvK nummer') &&
			showAlert('btwnummer', 'BTW nummer') &&
			showAlert('email1', 'e-mail adres') &&
			showAlert('email2', 'e-mail adres (facturatie)') &&
			showAlert('functie', 'functie') &&
			showAlert('achternaam', 'achternaam') &&
			showAlert('voornaam', 'voornaam') &&
			showAlert('login', 'gebruikersnaam') &&
			showAlert('wachtwoord1', 'wachtwoord') &&
			showAlert('wachtwoord2', 'wachtwoord (ter controle)') &&
			checkEmail('email1') &&
			checkEmail('email2')
		);
	} // function
	
	// image preloader
	function MM_preloadImages() { //v3.0
  		var d = document;
		if (d.images) {
			if (!d.MM_p)
				d.MM_p = new Array();
    		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
			for (i = 0; i < a.length; i++)
				if (a[i].indexOf("#") != 0) {
					d.MM_p[j] = new Image;
					d.MM_p[j++].src = a[i];
				}
		}
	}
	
	function windowOpen(name,url,width,height) {
		LeftPosition = (screen.width) ? (screen.width - width) / 2 : 0;
		TopPosition = (screen.height) ? (screen.height - height) / 2 : 0;
		settings ='height=' + height + ',width=' + width + ',top=' + TopPosition + ',left=' + LeftPosition + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no'
		window_open = window.open(url,name, settings);
		window_open.focus();
	}