 function checkInschrijving() {
   // the variables below are assigned to each
   // form input
   var gname, gemail, gpasswoord, gmessage;

 with(window.document.Inschrijfform) {
      gname      = txtName;
      glidnr     = txtLidnr;
      gpasswoord = txtPassword;
      gemail     = txtEmail;
   }

   // if name is empty alert the visitor
   if(trim(gname.value) == '') {
      alert('U heeft geen naam opgegeven');
      gname.focus();
      return false;
   }
   if(trim(glidnr.value) == '') {
     alert('U heeft geen lidnr opgegeven');
     glidnr.focus();
     return false;
   } 
   // if password is empty alert the visitor
   if(trim(gpasswoord.value) == '') {
      alert('U heeft geen wachtwoord opgegeven');
      gpasswoord.focus();
      return false;
   }
   // alert the visitor if email is empty or
   // if the format is not correct

   if(trim(gemail.value) == '') {
     alert('U heeft geen e-mail opgegeven');
     gemail.focus();
     return false;
   } 
   
   if (trim(gemail.value) != '' && !isEmail(trim(gemail.value))) {
     alert('U heeft geen geldig e-mail adres opgegeven');
     gemail.focus();
     return false;
   }
   // alert the visitor if message is empty
   
   // when all input are correct
   // return true so the form will submit
   return true;
}

 function checkform() {
   // the variables below are assigned to each
   // form input
   var gname, gemail, gpasswoord, gmessage;

   with(window.document.prikbordform)
   {
      gname      = txtName;
      gemail     = txtEmail;
      gmessage   = mtxMessage;
      gpasswoord = txtPassword;
   }

   // if name is empty alert the visitor
   if(trim(gname.value) == '') {
      alert('U heeft geen naam opgegeven');
      gname.focus();
      return false;
   }
   // if password is empty alert the visitor
   if(trim(gpasswoord.value) == '') {
      alert('U heeft geen wachtwoord opgegeven');
      gpasswoord.focus();
      return false;
   }
   // alert the visitor if email is empty or
   // if the format is not correct
   if(trim(gemail.value) == '') {
     alert('U heeft geen e-mail opgegeven');
     gemial.focus();
     return false;
   } 
   
   if (trim(gemail.value) != '' && !isEmail(trim(gemail.value))) {
     alert('U heeft geen geldig e-mail adres opgegeven');
     gemail.focus();
     return false;
   }
   // alert the visitor if message is empty
   
   if(trim(gmessage.value) == '') {
    alert('U heeft geen melding opgegeven');
    gmessage.focus();
    return false;
   } 
   // when all input are correct
   // return true so the form will submit
   return true;
}

/*
Strip whitespace from the beginning and end of a string
*/
function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
//   return str;
}

/*
   Check if a string is in valid email format.
*/
/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function isEmail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Ongeldige e-mail")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Ongeldige e-mail")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Ongeldige e-mail")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Ongeldige e-mail")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Ongeldige e-mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Ongeldige e-mail")
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
		    alert("Ongeldige e-mail")
		    return false
		 }

 		 return true
	}

