//<SCRIPT LANGUAGE="javascript">
<!--


function newstr(str2)	{
	if(str2 == null)	str2 = "";
	str = ""
	for(j = 0; j < str2.length; j++)	{
		if(str2.charAt(j) == "\"")	str += "&quot;";
		else	{if (str2.charAt(j) == "'")	str += "`";
		else	{if (str2.charAt(j) == "|")	str += "!";
		else	str += str2.charAt(j);}}
	}
	return str;
}

function Validator(theForm)
{
  var str = "";

  if (theForm.Name.value == "")
  {
    alert("Please enter Name correctly.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Name.value.length < 1)
  {
    alert("Please enter Name correctly.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Address.value == "")
  {
    alert("Please enter Address correctly.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.Address.value.length < 1)
  {
    alert("Please enter Address correctly.");
    theForm.Address.focus();
    return (false);
  }

  if (theForm.PostalCode.value == "")
  {
    alert("Please enter Postal Code correctly.");
    theForm.PostalCode.focus();
    return (false);
  }

  if (theForm.PostalCode.value.length < 1)
  {
    alert("Please enter Postal Code correctly.");
    theForm.PostalCode.focus();
    return (false);
  }

  if (theForm.City.value == "")
  {
    alert("Please enter City correctly.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.City.value.length < 1)
  {
    alert("Please enter City correctly.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.Country.value == "")
  {
    alert("Please enter Country correctly.");
    theForm.Country.focus();
    return (false);
  }

  if (theForm.Country.value.length < 1)
  {
    alert("Please enter Country correctly.");
    theForm.Country.focus();
    return (false);
  }

  if (theForm.Phone.value == "")
  {
    alert("Please enter Phone Number correctly.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length < 10)
  {
    alert("Please enter Phone Number correctly.");
    theForm.Phone.focus();
    return (false);
  }

  var checkOK = "0123456789-+ ";
  var checkStr = theForm.Phone.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
	    alert("Please enter Phone Number correctly (only digits, +, -)");
	    theForm.Phone.focus();
	    return (false);
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter Phone Number correctly (only digits, +, -)");
    theForm.Phone.focus();
    return (false);
  }

  if ((theForm.Fax.value != "") && (theForm.Fax.value.length <10))
  {
    alert("Please enter Fax Number correctly.");
    theForm.Fax.focus();
    return (false);
  }

  var checkOK = "0123456789-+ ";
  var checkStr = theForm.Fax.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter Fax Number correctly (only digits, +, -)");
    theForm.Fax.focus();
    return (false);
  }

  if (theForm.email.value == "")
  {
    alert("Please enter E-mail correctly.");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.length < 1)
  {
    alert("Please enter E-mail correctly.");
    theForm.email.focus();
    return (false);
  }

var eersteaapje = theForm.email.value.indexOf('@');
var laatsteaapje = theForm.email.value.lastIndexOf('@');
var punt = theForm.email.value.lastIndexOf('.');
    if (eersteaapje < 1 || eersteaapje != laatsteaapje || punt <= eersteaapje + 1 || punt >= theForm.email.value.length -1) {
         alert("Please enter E-mail correctly."
   +" Check the format.");
         theForm.email.focus();
         return (false);
     }

	theForm.Company.value = newstr(theForm.Bedrijf.value);
	theForm.Address.value = newstr(theForm.Adres.value);
	theForm.PostalCode.value = newstr(theForm.Postcode.value);
	theForm.City.value = newstr(theForm.Plaats.value);
	theForm.Name.value = newstr(theForm.Naam.value);
	theForm.Phone.value = newstr(theForm.Telefoon.value);
	theForm.Fax.value = newstr(theForm.Fax.value);
	theForm.email.value = newstr(theForm.email.value);
  return (true);
}


//-->
//</SCRIPT>
