function checkContact() {
    var f_tmp = xhtmlReq('xmlCheckEmail.asp?E=' + document.contactform.mail.value)

	if (document.contactform.voornaam.value == "") {
		alert("Vul uw voornaam of -letters in")
		document.contactform.voornaam.focus()
		return false
	} else if (document.contactform.achternaam.value == "") {
		alert("Vul uw achternaam in")
		document.contactform.achternaam.focus()
		return false
	} else if (document.contactform.mail.value == "") {
		alert("Vul uw e-mailadres in")
		document.contactform.mail.focus()
		return false
	} else if (!checkEmail(document.contactform.mail.value)) {
		alert("Het is door u ingevulde e-mailadres in onjuist")
		document.contactform.mail.focus()
		return false
    } else if (f_tmp != '') {
        alert('Het opgegeven e-mailadres komt al voor.')
        document.contactform.mail.focus()
        return false
	} else if (document.contactform.codeI.value == "") {
		alert("Vul de code in")
		document.contactform.codeI.focus()
		return false
	} else
		document.contactform.submit()
}

function checkEmail(strEmail) {
	strtmpEmail = String(strEmail)

	// Er moet een @ en een . voorkomen in een emailadres
	if (strtmpEmail.indexOf("@")== -1 || strtmpEmail.indexOf(".")== -1) {
		return false
	}

	nAt = strtmpEmail.indexOf("@")

	if (nAt > 0) {
		strCheck = strtmpEmail.slice(nAt + 1)
		// De @ komt voor de .  xxx.ppibv@nl, maar tim@ppibv.nl moet ook kunnen
		// Indien de . direct na de @ komt is dat ook fout  tim@.nl
		if (strCheck.indexOf(".") <= 0 ) {
			return false
		} else {
			// Na de punt minimaal 2 tekens tim@ppibv.n
			return ((parseInt(strCheck.length) -1) - parseInt(strCheck.indexOf("."))  > 1 )
		}
	} else
		return false
}

function xhtmlReq(f_sUrl) {
	var oXMLHTTP

	if (window.XMLHttpRequest) {
		oXMLHTTP = new XMLHttpRequest()
		oXMLHTTP.open("GET", f_sUrl, false)
		try {
			oXMLHTTP.send(null)
			return oXMLHTTP.responseText
		} catch(e) {
			alert('mislukt: ' + e)
		}
	} else if (window.ActiveXObject) {
		oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP")
		if (oXMLHTTP) {
			oXMLHTTP.open("GET", f_sUrl, false)
			try  {
				oXMLHTTP.send()
				return oXMLHTTP.responseText
			} catch (e) {
				alert('mislukt: ' + e)
			}
		}
	}
}
