var js12 = true;

function ValidateEmail12(emailad)
{
  var re = /^[_a-zA-Z0-9\-\_\.]+(\.[_a-zA-A0-9\-\_\.]+)*@[a-zA-Z0-9-\.]+(\.[a-zA-Z-9\-\.]+)*(\.[a-zA-Z]{2,4})$/;
  if (re.test(emailad))
  {
return true;
  } else
  {
return false;
  }
}


function ValidateEmail(emailad)
{
  if (js12==true)
return ValidateEmail12(emailad)
  else
return ValidateEmailOld(emailad)
  return true;
}

function ValidateEmailOld(checkString)
{
  var newstr = "";
  var at = false;
  var dot = false;
  var dotpos = false;


  // IF EMAIL ADDRESS HAS A '@' CHARACTER
  if (checkString.indexOf("@") != -1) {
at = true;
  // IF EMAIL ADDRESS HAS A '.' CHARACTER
  } else if (checkString.indexOf(".") != -1) {
dot = true;
  }
  // IF EMAIL ADDRESS HAS A '.' AFTER a '@'
  if (checkString.lastIndexOf(".") > checkString.indexOf("@"))
  {
dotpos = true;
  }

  // PARSE REMAINDER OF STRING
  for (var i = 0; i < checkString.length; i++) {
  ch = checkString.substring(i, i + 1)
  if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
  || (ch == "@") || (ch == ".") || (ch == "_")
  || (ch == "-") || (ch >= "0" && ch <= "9")) {
  newstr += ch;
  if (ch == "@") {
  at=true;
  }
  if (ch == ".") {
  dot=true;
  }
  }
  }
  if ((at == true) && (dot == true) && (dotpos == true) && (newstr == checkString)) {
return true;

  }
  else {
return false;
  }
}

function CheckLogin()
    {
      frmCheck = document.login;

      res = true;

      if (frmCheck.username.value==''){
        window.alert("Je hebt nog geen gebruikersnaam ingevuld!");
        frmCheck.username.focus();
        res = false;
      } else if (frmCheck.password.value==''){
        window.alert("Je hebt nog geen wachtwoord ingevuld!");
        frmCheck.password.focus();
        res = false;
      }

      return res;
    }


function checkFormFull()
    {
      frmCheck = document.aanmelding;

      res = true;

      if (frmCheck.voornaam.value==''){
        window.alert("Je hebt je voornaam nog niet ingevuld.");
        frmCheck.voornaam.focus();
        res = false;
      } else if (frmCheck.achternaam.value==''){
        window.alert("Je hebt je achternaam nog niet ingevuld.");
        frmCheck.achternaam.focus();
        res = false;
      } else if (!ValidateEmail(frmCheck.email.value)){
        window.alert("Het e-mail adres is niet geldig.");
        frmCheck.email.focus();
        res = false;
      } else if (frmCheck.supermarkt.value=='0'){
        window.alert("Je hebt de supermarkt nog niet ingevuld.");
        frmCheck.supermarkt.focus();
        res = false;
	  }
	  
      
	///  if (res == true){
	//	  frmCheck.submit();
	  //}
	  
	  return res;
}

