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

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

function validate_form(thisform,fullname)
{
  with (thisform)
  {
  if (validate_email(thisform["E-mail"],"Please fill in your E-mail address")==false)
    {thisform["E-mail"].focus();return;}
    
  if (validate_required(thisform["Phone"],"Please fill in your Phone No.","Phone")==false)
    {thisform["Phone"].focus();return;}
    
    if(fullname==true)
    {
  if (validate_required(thisform["Name"],"Please fill in your Name","Your Name")==false)
    {thisform["Name"].focus();return;}
    }    
    else
    {
  if (validate_required(thisform["First"],"Please fill in your Frist Name","Your Name")==false)
    {thisform["First"].focus();return;}
    }  
    thisform["country"].value = thisform["Nationality"].options[thisform["Nationality"].selectedIndex].text;
      
    thisform.submit();
  }
}

function validate_qmas_form(thisform,fullname)
{
  with (thisform)
  {
  if (validate_email(thisform["E-mail"],"Please fill in your E-mail address")==false)
    {thisform["E-mail"].focus();return;}
    
  if (validate_required(thisform["Phone"],"Please fill in your Phone No.","Phone")==false)
    {thisform["Phone"].focus();return;}
    
    if(fullname==true)
    {
  if (validate_required(thisform["Name"],"Please fill in your Name","Your Name")==false)
    {thisform["Name"].focus();return;}
    }    
    else
    {
  if (validate_required(thisform["First"],"Please fill in your Frist Name","Your Name")==false)
    {thisform["First"].focus();return;}
    }  
    thisform["ageval"].value = thisform["age"].options[thisform["age"].selectedIndex].text;
    thisform["childrenval"].value = thisform["children"].options[thisform["children"].selectedIndex].text;
    thisform["familyval"].value = thisform["family"].options[thisform["family"].selectedIndex].text;
    thisform["languageval"].value = thisform["language"].options[thisform["language"].selectedIndex].text;
    thisform["experienceval"].value = thisform["experience"].options[thisform["experience"].selectedIndex].text;
    thisform["qualificationsval"].value = thisform["qualifications"].options[thisform["qualifications"].selectedIndex].text;
      
    thisform.submit();
  }
}
