//function to eliminate white space
function ltrim (s1)
 {
  return s1.replace( /^\s*/, "" )
 }
function rtrim (s2)
 {
  return s2.replace( /\s*$/, "" );
 }
function trimming(s3)
 {
  return rtrim(ltrim(s3));
 }
 
function ValidateEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}
function VerifyData()
{	
   var form = document.form1;      
   var returnValue = false;
   var varEmail = trimming(form.email.value); 	

  if (trimming(form.nome.value) == "")
   {
      alert("Inserire il proprio nome");
      form.nome.focus();
   }
   else if (trimming(form.telefono.value) == "")
   {
      alert("Inserire il telefono");
      form.telefono.focus();
   }
   else if (trimming(form.interesse.value) == "-")
   {
      alert("Inserire la tipologia di servizio");
      form.interesse.focus();
   }
   else if (varEmail == "")
   {
      alert("Inserire una email valida");
      form.email.focus();
   }
   else if (ValidateEmail(varEmail) == false)
   {
      alert("Inserire una email valida");
      form.email.focus();
   }
   else if (trimming(form.www.value) == "")
   {
      alert("Insierisci un indirizzo valido");
      form.www.focus();
   }
   else
   {
      returnValue = true;
   }

   return returnValue;
}

