// 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.info

// recieve all the data from the form
firstname=x.firstname.value;
lastname=x.lastname.value;
brand_store=x.brand_store.value;
city=x.city.value;
country=x.country.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"
 }
 
  // brand_store validation field.
if (brand_store.length<1)
 {
  errorText = errorText + "Your brand or store name" + "\n"
  x.brand_store.focus()
  submitOK="False"
 }
 
  // city validation field.
if (city.length<1)
 {
  errorText = errorText + "City" + "\n"
  x.city.focus()
  submitOK="False"
 }
 
  // country validation field.
if (country.length<1)
 {
  errorText = errorText + "Country" + "\n"
  x.country.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
 }
}
