function doValidation(){

if (chkFields() == true){
document.getElementById("contactMotQ").action = "http://www.vajachoice.com/id/mkt/contacto.nsf/contactMotQ?CreateDocument";
document.getElementById("contactMotQ").submit();
}
}

function chkFields(){


if(Trim(document.getElementById("Nombre").value) == ""){
alert("Please complete your Name");
document.getElementById("Nombre").focus();
return(false);
}

if(Trim(document.getElementById("Apellido").value) == ""){
alert("Please complete your Last Name");
document.getElementById("Apellido").focus();
return(false);
}

if(Trim(document.getElementById("Email").value) == ""){
alert("Please complete your E-mail");
document.getElementById("Email").focus();
return(false);
}

if(Trim(document.getElementById("Pais").value) == "0"){
alert("Please complete your Country");
document.getElementById("Pais").focus();
return(false);
}

if(validateEmail(Trim(document.getElementById('Email').value),1,1)==false){
document.getElementById("Email").focus();
return(false)
}


return(true);
}

function Trim(s) 
{
  // Remove leading spaces and carriage returns
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Remove trailing spaces and carriage returns

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert('Invalid email address');
   return false;
}
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('Invalid email address');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("Invalid email address");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('Invalid email address');
   return false;
}
if (atPos == 0) {
   if (db) alert('Invalid email address');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('Invalid email address');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('Invalid email address');
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('Invalid email address');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('Invalid email address');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('Invalid email address');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('Invalid email address');
   return false;
}
return true;
}