function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else 
		countfield.value = maxlimit - field.value.length;
}

function validateForm(theForm) {
      var why = "";
      why += isEmpty(theForm.naam.value);
      if (why == ""){
        why += isEmpty(theForm.reactie.value);
        }
      why += checkEmail(theForm.email.value);
      
      if (theForm.website.value != "") {
        why += isWebsite(theForm.website.value);
        }
      


      if (why != "") {
         alert(why);
         return false;
      }

  return true;
  }

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "Je hebt geen emailadres ingevuld.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Je hebt geen geldig emailadres ingevuld.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "Het mailadres bevat een ongeldige character.\n";
       }
    }
return error;    
}

function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Niet alle velden zijn ingevuld.\n"
  }
return error;	  
}

function isWebsite(strng){
  var error = "";
  if ((strng == "") || (strng.indexOf("http://") == -1) || (strng.indexOf(".") == -1)){
    error = "Het adres van uw internetpagina is ongeldig\n";
    }
  return error;
  }
  

function Vote(Poll){
    window.location = 'stemmen.php?poll=' + Poll + '';
}