function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {

		ext = new Array('.ac', '.ad', '.ae', '.af', '.ag', '.ai', '.al', '.am', '.an', '.ao', '.aq', '.ar', '.arpa', '.as', '.at', '.au', '.aw', '.az', '.ba', '.bb', '.bd', '.be', '.bf', '.bg', '.bh', '.bi', '.bj', '.bm', '.bn', '.bo', '.br', '.bs', '.bt', '.bv', '.bw', '.by', '.bz', '.ca', '.cc', '.cf', '.cg', '.ch', '.ci', '.ck', '.cl', '.cm', '.cn', '.co', '.com', '.cr', '.cs', '.cu', '.cv', '.cx', '.cy', '.cz', '.de', '.dj', '.dk', '.dm', '.do', '.dz', '.ec', '.edu', '.ee', '.eg', '.eh', '.er', '.es', '.et', '.eu', '.fi', '.firm', '.fj', '.fk', '.fm', '.fo', '.fr', '.fx', '.ga', '.gb', '.gd', '.ge', '.gf', '.gh', '.gi', '.gl', '.gm', '.gn', '.gov', '.gp', '.gq', '.gr', '.gs', '.gt', '.gu', '.gw', '.gy', '.hk', '.hm', '.hn', '.hr', '.ht', '.hu', '.id', '.ie', '.il', '.in', '.int', '.io', '.iq', '.ir', '.is', '.it', '.jm', '.jo', '.jp', '.ke', '.kg', '.kh', '.ki', '.km', '.kn', '.kp', '.kr', '.kw', '.ky', '.kz', '.la', '.lb', '.lc', '.li', '.lk', '.lr', '.ls', '.lt', '.lu', '.lv', '.ly', '.ma', '.mc', '.md', '.mg', '.mh', '.mil', '.mk', '.ml', '.mm', '.mn', '.mo', '.mp', '.mq', '.mr', '.ms', '.mt', '.mu', '.mv', '.mw', '.mx', '.my', '.mz', '.na', '.nato', '.nc', '.ne', '.net', '.nf', '.ng', '.ni', '.nl', '.no', '.nom', '.np', '.nr', '.nt', '.nu', '.nz', '.om', '.org', '.pa', '.pe', '.pf', '.pg', '.ph', '.pk', '.pl', '.pm', '.pn', '.pr', '.pt', '.pw', '.py', '.qa', '.re', '.ro', '.ru', '.rw', '.sa', '.sb', '.sc', '.sd', '.se', '.sg', '.sh', '.si', '.sj', '.sk', '.sl', '.sm', '.sn', '.so', '.sr', '.st', '.store', '.su', '.sv', '.sy', '.sz', '.tc', '.td', '.tf', '.tg', '.th', '.tj', '.tk', '.tm', '.tn', '.to', '.tp', '.tr', '.tt', '.tv', '.tw', '.tz', '.ua', '.ug', '.uk', '.um', '.us', '.uy','.uz', '.va', '.vc', '.ve', '.vg', '.vi', '.vn', '.vu', '.web', '.wf', '.ws', '.ye', '.yt', '.yu', '.za', '.zm', '.zr', '.zw');
		
		for (s = 0; s < ext.length; s++) {
			thisEntry = ext[s].toString();
			if (string.search(thisEntry) != -1) {
				return true;
			}
		}
	}
	return false;
}

function checkForm(formname) {
	elems = $(formname).elements;
	checkradio = false;
	r = 0;
	radiofields = new Array();
	tel= 0;
	for(i = 0; i < elems.length; i++) {
		element = null;
		element = document.getElementById(elems[i].name + '_');
		if (element) {
			element.style.display = 'none';
			if (elems[i].value == '' || elems[i].value == ' ' || elems[i].value == '  ') {
				tel = tel + 1;
				if(elems[i].className.indexOf('_req') == -1) {
					elems[i].className = elems[i].className+'_req';
				}
			} else {
				if (elems[i].type == 'checkbox') {
					if (elems[i].checked == false) {
						tel = tel + 1;
						if(elems[i].className.indexOf('_req') == -1) {
							elems[i].className = elems[i].className+'_req';
						}
					} else {	}
				}
				
				if (elems[i].type == 'radio') {
					checkradio = true;
					radiofields[r] = elems[i].name;
					r++;
				}
				if (elems[i].name.substr(0,5) == 'email' || elems[i].name.substr(0,6) == 'remail') {
					if (!isEmail(elems[i].value)) {
						tel = tel + 1;
						elems[i].value = $('emailfout').value;
						if(elems[i].className.indexOf('_req') == -1) {
							elems[i].className = elems[i].className+'_req';
						}
					}
				}
				if (elems[i].name.indexOf('eind') != -1 || elems[i].name.indexOf('start') != -1) {
					if(elems[i].value.indexOf(':') == -1) {
						elems[i].value = elems[i].value.substr(0,2) + ':' + elems[i].value.substr(2,2);
					}
					var tijden = elems[i].value.split(":");
					for (j=0; j<tijden.length; j++) {
						if(	isNaN(tijden[j]) || 
								tijden[j] < 0 || 
								(j == 0 && tijden[j] > 23) || 
								(j == 1 && tijden[j] > 59)
							) {
							tel = tel + 1;
							if(elems[i].className.indexOf('_req') == -1) {
								elems[i].className = elems[i].className+'_req';
							}
						}
					}
				}
			}
		}
	}
	
	if(checkradio) {
		testfield = '';
		for(i=0; i < radiofields.length ; i++) {
			if(radiofields[i] != testfield) {
				testfield = radiofields[i];
				elem = document[formname][testfield];
				controle = false;
				for (j=0;j<elem.length;j++){
					if (elem[j].checked==true) {
						controle = true;
					}
				}
				
				element = document.getElementById(radiofields[i] + '_');
				if (controle) {						
				} else {
					tel = tel + 1;
					if(elems[i].className.indexOf('_req') == -1) {
						elems[i].className = elems[i].className+'_req';
					}
				}
			}
		}		
	}
	
	passerror = 0;
	if (document[formname].p_wachtwoord && document[formname].p_wachtwoord_herhaal) {
		if (document[formname].p_wachtwoord.value != document[formname].p_wachtwoord_herhaal.value) {
			passerror = 1;
			tel = tel + 1;
			document.$('p_wachtwoord_').style.display = '';
			document.$('p_wachtwoord_herhaal_').style.display = '';
		}
	}
	element = document.getElementById('showcheck');
	if (tel == 0) {
		document[formname].submit();
		return true;
	} else {
		if (passerror == 0) {
			element.innerHTML = '<font color="#76b50e"><b>* '+$('verplichtveld').value+' [' + tel + ']</b></font>';
		} else {
			element.innerHTML = '<font color="203590"><b>* '+$('wachtwoordfout').value+'</b></font>';
		}
		return false;
	}
}