function ValidateEmail(email)

{

  var fEmailOK = true;

  var num = 0;



  for (var i = 0; i < email.length; ++i) {

    var ch = email.charAt(i);

    if (ch == "@") {

      num = num + 1;

    }

  }

  if (num != "1")

    return false;



  var num2 = 0;

  for (var i = 0; i<email.length; ++i) {

    var ch = email.substring(i,i+2);

    if ((ch == "..")||(ch == ".@")||(ch == "@.")) {

      return false;

    }

  }

  if (email.length < 4)

    return false;

  else if (email.lastIndexOf(' ') != -1)

    return false;

  else if ((email.substring(0,1) == ".")||(email.substring(0,1) == "@")) {

    return false;

  }

  else if (email.lastIndexOf('\'') != -1)

    return false;

  else if ((i = email.lastIndexOf('@')) == -1)

    return false;

  else { // Get substring

    var tail = email.substring(i+1, email.length);

    if (tail.length < 3)

      return false;

    else if ((i = tail.lastIndexOf('.')) == -1)

      return false;

    else {

      var tailend = tail.substring(i+1, tail.length);

      if (tailend.length == 0)

        return false;

    }

  }

  return true;

}


function checkinput()
{

if (document.getElementById("firstname").value == "") {
  alert("You need to enter in your name");
  document.getElementById("firstname").focus();
  return false;
} 

if (document.getElementById("Surname").value == "") {
  alert("You need to enter in your surname");
  document.getElementById("Surname").focus();
  return false;
} 

if (document.getElementById("email").value == "") {
  alert("You need to enter in your email");
  document.getElementById("email").focus();
  return false;
} 

if (ValidateEmail(document.getElementById("email").value) == false) {
 alert("You have entered in an invalid email address");
  document.getElementById("email").focus();
 return false;
} 

if (document.getElementById("telno").value == "") {
  alert("You need to enter in your contact number");
  document.getElementById("telno").focus();
  return false;
} 

if (document.getElementById("nationality").value == "") {
  alert("You need to select your nationality");
  document.getElementById("nationality").focus();
  return false;
} 


document.submitapp.submit();

}



function checkinputbasic()
{

if (document.getElementById("txtname").value == "") {
  alert("You need to enter in your name");
  document.getElementById("txtname").focus();
  return false;
} 

if (document.getElementById("txtemail").value == "") {
  alert("You need to enter in your email");
  document.getElementById("txtemail").focus();
  return false;
} 

if (ValidateEmail(document.getElementById("txtemail").value) == false) {
 alert("You have entered in an invalid email address");
  document.getElementById("txtemail").focus();
 return false;
} 

document.submitapp.submit();

}
