function ValidateFields()
{
  if(trim(document._WebFeedback.FirstName.value)=="")
    {
      alert("The < First Name > field must have a value!");
       document._WebFeedback.FirstName.focus();
    } 
    else 
  if(trim(document._WebFeedback.LastName.value)=="")
    {
      alert("The < Last Name > field must have a value!"); 
      document._WebFeedback.LastName.focus();
    } 
    else 
 if(trim(document._WebFeedback.PostalCode.value)=="")
    {
      alert("The < PostalCode > field must have a value!"); 
      document._WebFeedback.PostalCode.focus();
    } 
    else
 if(trim(document._WebFeedback.Email.value)=="")
    {
      alert("The < Email > field must have a value!"); 
      document._WebFeedback.Email.focus();
    } 
    else
 if(trim(document._WebFeedback.Message.value)=="")
    {
      alert("The < Message > field must have a value!"); 
      document._WebFeedback.Message.focus();
    }
    //HIN003
    else
 if(trim(document._WebFeedback.Email.value) != "")
 {
    if (validateEmail(document._WebFeedback.Email.value))
    {
      document._WebFeedback.submit();
    }
    else
    {
      alert("Please double check your email address.");
      document._WebFeedback.Email.focus();
    }
 }
} 
 
function validateEmail(str) 
{
  var at="@";
  var dot=".";
  var lat=str.indexOf(at);
  var lstr=str.length;
  var ldot=str.indexOf(dot);
  if (str.indexOf(at)==-1)
  {
    return false;
  }

  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
  {
    return false
  }

  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
  {
    return false;
  }

   if (str.indexOf(at,(lat+1))!=-1)
   {
     return false;
   }
   
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
   {
     return false;
   }

   if (str.indexOf(dot,(lat+2))==-1)
   {
     return false;
   }

   if (str.indexOf(" ")!=-1)
   {
     return false;
   }

   return true;				
}
 
function ltrim ( s )
{
	return s.replace( /^\s*/, "" );
}

function rtrim ( s )
{
	return s.replace( /\s*$/, "" );
}

function trim ( s )
{
	return rtrim(ltrim(s));
}
