function isEmail(emailAddress){
emailAddressValue=emailAddress.value.toLowerCase();
var countryTLDs=/^(ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|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|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|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|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|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|wf|ws|ye|yt|yu|za|zm|zw)$/;
var gTLDs=/^(aero|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|jobs)$/;
var basicAddress=/^(.+)@(.+)$/;
var specialChars='\\(\\)><@,;:\\\\\\\"\\.\\[\\]';
var validChars='\[^\\s'+specialChars+'\]';
var validCharset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\'-_.';
var quotedUser='(\"[^\"]*\")';
var atom=validChars+'+';
var word='('+atom+'|'+quotedUser+')';
var validUser=new RegExp('^'+word+'(\.'+word+')*$');
var symDomain=new RegExp('^'+atom+'(\.'+atom+')*$');
var matchArray=emailAddressValue.match(basicAddress);
if(emailAddress.value==''||emailAddress==null){
return true;
}
if(matchArray==null){
alert('Het emailadres klopt niet, controleer of er een @ in staat.');
emailAddress.focus();
return false;
}else{
var user=matchArray[1];
var domain=matchArray[2];
for(i=0;i<user.length;i++){
if(validCharset.indexOf(user.charAt(i))==-1){
alert('Het emailadres bevat ongeldige karakters, controleer de naam.');
emailAddress.focus();
return false;
}
}
for(i=0;i<domain.length;i++){
if(validCharset.indexOf(domain.charAt(i))==-1){
alert('Het emailadres bevat ongeldige karakters, controleer het domein.');
emailAddress.focus();
return false;
}
}
if(user.match(validUser)==null){
alert('Het emailadres klopt niet, controleer de naam.');
emailAddress.focus();
return false;
}
var atomPat=new RegExp('^'+atom+'$');
var domArr=domain.split('.');
var len=domArr.length;
for(i=0;i<len;i++){
if(domArr[i].search(atomPat)==-1){
alert('Het emailadres klopt niet, controleer het domein.');
emailAddress.focus();
return false;
}
}
if((domArr[domArr.length-1].length==2)&&(domArr[domArr.length-1].search(countryTLDs)==-1)){
alert('Het emailadres klopt niet, controleer het domein.');
emailAddress.focus();
return false;
}
if((domArr[domArr.length-1].length>2)&&(domArr[domArr.length-1].search(gTLDs)==-1)){
alert('Het emailadres klopt niet, controleer het domein.');
emailAddress.focus();
return false;
}
if((domArr[domArr.length-1].length<2)||(domArr[domArr.length-1].length>6)){
alert('Het emailadres klopt niet, controleer het domein.');
emailAddress.focus();
return false;
}
if(len<2){
alert('Het emailadres klopt niet, Zou je aub de ontbrekende hostnaam willen nakijken?.');
emailAddress.focus();
return false;
}
}
return true;
}
String.prototype.trim = function() { return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");	}
function mandatoryText(input,fieldName){
if(input.value.trim()==''||input==null){
alert(''+fieldName+' is verplicht.');
input.focus();
return false;
} else {
return true;
}
}

function validForm(){
if(!mandatoryText(document.getElementById('uid1'), 'Naam')) return;
if(!mandatoryText(document.getElementById('uid2'), 'E-mail')) return;
if(!isEmail(document.getElementById('uid2'))) return;
if(!mandatoryText(document.getElementById('uid3'), 'Telefoon')) return;
document.getElementById('afspraak').submit();
}

/*
function validateForm(){

if(!mandatoryText(document.getElementById('mailformNaam'), 'Naam')) return false;
if(!mandatoryText(document.getElementById('mailformEmail'), 'E-mail')) return false;
if(!isEmail(document.getElementById('mailformEmail'))) return false;
//document.getElementById('mailform').submit();

// Submitting the form
//var url = window.location.protocol + "/" + window.location.host + "/" + window.location.pathname;
var url = window.location.protocol + "/" + window.location.pathname;
var query = '?Taalversies='+document.getElementById('mailformtaalversies').value+'&webpaginas/taalversie='+document.getElementById('mailformwebpaginas').value+'&Diepteniveau_boomstructuur='+document.getElementById('mailformboomstructuur').value+'&CMS='+document.getElementById('mailformcms').value+'&Aantal_producten='+document.getElementById('mailformaantal_producten').value+'&Aantal_productcategorieën='+document.getElementById('mailformaantal_productcategorien').value+'&mod_nieuwsbrief='+document.getElementById('mailformmodule_nieuwsbrief').checked+'&mod_calendar='+document.getElementById('mailformmodule_calendar').checked+'&mod_webshop='+document.getElementById('mailformmodule_shop').checked+'&mod_downloads='+document.getElementById('mailformmodule_downloads').checked+'&mod_blog='+document.getElementById('mailformmodule_blog').checked+'&mod_login='+document.getElementById('mailformmodule_login').checked+'&mod_sitemap='+document.getElementById('mailformmodule_sitemap').checked+'&mod_news='+document.getElementById('mailformmodule_news').checked+'&mod_vacatures='+document.getElementById('mailformmodule_vacatures').checked+'&mod_google_maps='+document.getElementById('mailformmodule_gmaps').checked+'&mod_forum='+document.getElementById('mailformmodule_forum').checked+'&mod_poll='+document.getElementById('mailformmodule_poll').checked+'&mod_search='+document.getElementById('mailformmodule_search').checked+'&andere_modules='+document.getElementById('mailformmodule_andere').checked+'&Email='+document.getElementById('mailformEmail').value+'&Naam='+document.getElementById('mailformNaam').value+'&Telefoon='+document.getElementById('mailformTelefoon').value+'&Zelf_invullen='+document.getElementById('mailformcontentinvulling').value+'&Extra='+document.getElementById('mailformextra').value+'&subject='+document.getElementById('mailformsubject').value+'&page='+url;

sendmail(query);

//alert(document.mailform.optin.checked);

document.getElementById('offerte').style.height='auto';

//	$("#quote p").load("http://test2.mia.be/typo3conf/ext/scripts/script.php",{
//					email: $("#mailformEmail").val()
//	});
}
*/



function validateForm2(){
	if(!mandatoryText(document.getElementById('mailformNaam'), 'Naam')) return false;
	if(!mandatoryText(document.getElementById('mailformEmail'), 'E-mail')) return false;
	if(!isEmail(document.getElementById('mailformEmail'))) return false;
	
	
	for (var i=0; i < document.mailform.Beheer.length; i++){
		if (document.mailform.Beheer[i].checked){
			var beheer = document.mailform.Beheer[i].value;
		}
   	}
	
	for (var j=0; j < document.mailform.Oplossing.length; j++){
		if (document.mailform.Oplossing[j].checked){
			var oplossing = document.mailform.Oplossing[j].value;
		}
   	}
	
	for (var k=0; k < document.mailform.db.length; k++){
		if (document.mailform.db[k].checked){
			var db = document.mailform.db[k].value;
		}
   	}
	
	
	var url = "http://interactive.mia.be" + window.location.pathname;
	var query = '?Email='+document.getElementById('mailformEmail').value+'&Naam='+document.getElementById('mailformNaam').value+'&Telefoon='+document.getElementById('mailformTelefoon').value+'&Beheer='+beheer+'&Oplossing='+oplossing+'&Databank='+db+'&Adressen='+document.getElementById('mailformAdressen').value+'&Extra='+document.getElementById('mailformextra').value+'&subject='+document.getElementById('mailformsubject').value+'&page='+url;
	
	sendmail(query);

	document.getElementById('offerte').style.height='auto';
}



function validateForm3(){
	if(!mandatoryText(document.getElementById('mailformNaam'), 'Naam')) return false;
	if(!mandatoryText(document.getElementById('mailformEmail'), 'E-mail')) return false;
	if(!isEmail(document.getElementById('mailformEmail'))) return false;
		
	
	var url = "http://interactive.mia.be" + window.location.pathname;
	var query = '?Naam='+document.getElementById('mailformNaam').value+'&Email='+document.getElementById('mailformEmail').value+'&Telefoon='+document.getElementById('mailformTelefoon').value+'&Aantal_deelnemers='+document.getElementById('mailformDeelnemers').value+'&Opleiding='+document.getElementById('mailformOpleiding').value+'&Extra='+document.getElementById('mailformextra').value+'&subject='+document.getElementById('mailformsubject').value+'&page='+url;
	
	sendmail(query);

	document.getElementById('offerte').style.height='auto';
}


function ccmdvalidForm(){
	//if(!mandatoryText(document.getElementById('optin'), 'E-mail')) return;
	if(!mandatoryText(document.getElementById('EMAIL_FIELD'), 'E-mail')) return;
	if(!isEmail(document.getElementById('EMAIL_FIELD'))) return false;
	document.getElementById('emvForm').submit();
}