function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_confirm(field)
{
with (field)
{
if (value==null||value==""){return false}
else {return true}
}
}

function validate_length(field,l,alerttxt)
{
with (field)
{
if (value.length>l)
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_email(field,alerttxt){
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
with (field)
{
  if(value.match(emailExp))
    {return true;}
  else
    {alert(alerttxt);return false;}
}
}

function validate_form(thisform)
{
with (thisform)
{
if (validate_required(name, "Please fill the Name field.")==false)
  {name.focus();return false}
if (validate_required(firstName, "Please fill the First name field.")==false)
  {firstName.focus();return false}
if (validate_required(position, "Please make selection for the Position field.")==false)
  {position.focus();return false}
if (validate_required(researchArea, "Please fill the Research area field.")==false)
  {researchArea.focus();return false}
if (validate_required(institution, "Please fill the Institution field.")==false)
  {institution.focus();return false}
if (validate_required(town, "Please fill the Institution field.")==false)
  {town.focus();return false}
if (validate_required(country, "Please fill the Country field.")==false)
  {country.focus();return false}
if (validate_required(email, "Please fill the E-mail address field.")==false)
  {email.focus();return false}  
if (validate_email(email, "Not a valid e-mail address.")==false)
  {email.focus();return false}
if (validate_required(mail, "Please fill the Mailing address field.")==false)
  {mail.focus();return false}
if (validate_required(participation, "Please make selection for the Participation field.")==false)
  {participation.focus();return false} 
if (validate_length(abstract, 600, "Your abstract is too long. Only 500 characters are allowed.")==false)
  {abstract.focus();return false}
if (validate_required(registrationType, "Please make selection for the Registration  field.")==false)
  {registrationType.focus();return false}
if (validate_confirm(title) == false)
  {if (!confirm("The Title of talk field is empty. Do you want to submit anyway?")) 
  {title.focus();return false;}}
if (validate_confirm(abstract) == false)
  {if (!confirm("The Abstract field is empty. Do you want to submit anyway?")) 
  {abstract.focus();return false;}}
}
}
