// Registration validation

var errorText = "";
var qualifying_heat="";

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

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

// recieve all the data from the form
band_name=x.band_name.value;
first_name=x.first_name.value;
last_name=x.last_name.value;
address_1=x.address_1.value;
zip=x.zip.value;
city=x.city.value;
registration_country=x.registration_country.value;
phone=x.phone.value;
qualifying_heat=x.qualifying_heat.value;
at=x.email.value.indexOf("@");
accept_rules=x.accept_rules.checked;

// default the submit action to true
submitOK="True"

   // qualifying_heat checkbox
if (qualifying_heat == "")
 {
  errorText = errorText + "- a qualifying heat " + "\n"
  x.qualifying_heat.focus()
  submitOK="False"
 }

  // band name validation field.
if (band_name.length<1)
 {
  errorText = errorText + "- your band name" + "\n"
  x.band_name.focus()
  submitOK="False"
 }

  // first name validation field.
if (first_name.length<1)
 {
  errorText = errorText + "- your first name" + "\n"
  x.first_name.focus()
  submitOK="False"
 }

  // last name validation field.
if (last_name.length<1)
 {
  errorText = errorText + "- your last name" + "\n"
  x.last_name.focus()
  submitOK="False"
 }

  // address validation field.
if (address_1.length<1)
 {
  errorText = errorText + "- your address" + "\n"
  x.address_1.focus()
  submitOK="False"
 }

  // zip validation field.
if (zip.length<1)
 {
  errorText = errorText + "- your post/zip code" + "\n"
  x.zip.focus()
  submitOK="False"
 }

  // city validation field.
if (city.length<1)
 {
  errorText = errorText + "- your city" + "\n"
  x.city.focus()
  submitOK="False"
 }

  // country validation field.
if (registration_country.length<1)
 {
  errorText = errorText + "- your country" + "\n"
  x.registration_country.focus()
  submitOK="False"
 }

  // phone validation field.
if (phone.length<1)
 {
  errorText = errorText + "- your phone number" + "\n"
  x.phone.focus()
  submitOK="False"
 }

 
// email validation field.
 if (at==-1) 
 {
 errorText = errorText + "- a valid eMail address" + "\n"
 submitOK="False"
 x.email.focus()
 }
 
   // accept_rules checkbox
if (accept_rules == false)
 {
  errorText = errorText + "- acknowledge and accept the rules & regulations" + "\n"
  x.accept_rules.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;
}
