// Newsletter validation

var errorText = "";

// function is calledon submit
function validate()
{
errorText = "Please fill in: \n\n";

// shortcut the document.input_form with x
x=document.contact

// recieve all the data from the form
firstname=x.firstname.value;
lastname=x.lastname.value;
country_id=x.country_id.value;
at=x.email.value.indexOf("@")

// default the submit action to true
submitOK="True"

  // firstname validation field.
if (firstname.length<1)
 {
  errorText = errorText + "Your first name" + "\n"
  x.firstname.focus()
  submitOK="False"
 }

 // lastname validation field.
if (lastname.length<1)
 {
  errorText = errorText + "Your last name" + "\n"
  x.lastname.focus()
  submitOK="False"
 }
 
 if (country_id==0)
 {
  errorText = errorText + "Your country" + "\n"
  x.country_id.focus()
  submitOK="False"
 }	
 
   // email validation field.
 if (at==-1) 
 {
 errorText = errorText + "A valid eMail address" + "\n"
 submitOK="False"
 x.email.focus()
 }
 // if any of the above validation sections have failed show the alert box with the errorText
if (submitOK=="False")
 {
 alert(errorText)
 // return false to stop the form submission
 return false
 }
}
