// Newsletter validation

var errorText = "";

// function is calledon submit
function validate()
{
errorText = "Please enter: \n\n";

// shortcut the document.input_form with x
x=document.request

// recieve all the data from the form
firstname=x.firstname.value;
lastname=x.lastname.value;
os0=x.os0.value;
at=x.email.value.indexOf("@");
shipping_destinations=x.shipping_destinations.value;

// 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"
 }
 
// email validation field.
 if (at==-1) 
 {
 errorText = errorText + "- a valid eMail address" + "\n"
 submitOK="False"
 x.email.focus()
 }
 
 // country validation field.
if (shipping_destinations.length<1)
 {
  errorText = errorText + "- your country" + "\n"
  x.shipping_destinations.focus()
  submitOK="False"
 }
  
// Color/Size DropDown.
if (os0==0)
 {
  errorText = errorText + "- color/size request" + "\n"
  x.os0.focus()
  submitOK="False"
 }
 
if (os0==99)
 {
  errorText = errorText + "- THIS ITEM IS SOLD OUT" + "\n"
  x.shipping_destinations.focus()
  submitOK="False"
 }
 
 // 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
 }
 return true;
}
