
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false;}
else {return true;}
}
}

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}


function validate_form(thisform)
{
with (thisform)
{
if (validate_required(name,"Please, write your first name.")==false)
  {name.focus();return false;}
}
with (thisform)
{
if (validate_required(name2,"Please, write your last name.")==false)
  {name2.focus();return false;}
}
with (thisform)
{
if (validate_email(email,"Not a valid e-mail address!")==false)
  {email.focus();return false;}
}
with (thisform)
{
if (validate_required(country,"Please, select a country")==false)
  {country.focus();return false;}
}
with (thisform)
{
if (validate_required(comment,"You forgot to send us a comment!")==false)
  {comment.focus();return false;}
}

}

