schedule("window", initForm);
 
 
 

function initForm()
{
 var downloadForm = document.getElementById("downloadForm");
 
 downloadForm.onsubmit = checkForm;
};
 
 
 

function checkForm()
{
 //1
 var firstName = document.getElementById("firstName");
 //2
 var lastName = document.getElementById("lastName");
 //3
 var address = document.getElementById("address");
 //4
 var town = document.getElementById("town");
 //5
 var state = document.getElementById("state");
 //6
// var country = document.getElementById("country");
//7
 var postcode = document.getElementById("postcode");
 //8
 var homePhone = document.getElementById("homePhone");
 //9
 var email = document.getElementById("email");
 //10
 var driversLicence = document.getElementById("driverslic");

 //13
 var eligible = document.getElementById("eligible"); 
 //14
 var previouslyEmployed = document.getElementById("previouslyemp");
 //15
 var qualifications = document.getElementById("qualifications");
 //16
 //var yearFrom = document.getElementById("yearFrom");
 //17
// var courseStudied = document.getElementById("courseStudied");
 //18
 //var qualificationAttained = document.getElementById("qualificationAttained");
 //19
var nametrade = document.getElementById("nametrade");
 //20
 //var nameemployer = document.getElementById("nameemployer");
 //21
 //var refereename = document.getElementById("refereename");
 //22
 //var company = document.getElementById("company");
 //23
 //var refereeposition = document.getElementById("refereeposition");
  //24
//var current = document.getElementById("current");
  //25
 var conditions = document.getElementById("conditions");

 
 

 
 
 // set up the new variable to return code
 var ret = true; // default the value to be successful
 
 

//1
 if (firstName.value == "")
 {
  firstName.focus();
  alert("Please fill in your first name");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
 //2
 if (lastName.value == "")
 {
  lastName.focus();
  alert("Please fill in your last name");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
  //3
 if (address.value == "")
 {
  address.focus();
  alert("Please fill in your address");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
   //4
 if (town.value == "")
 {
  town.focus();
  alert("Please fill in your town");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
  //5
 if (state.value == "")
 {
  state.focus();
  alert("Please fill in your state");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
     //6
 //if (country.value == "")
 //{
  //country.focus();
  //alert("Please fill in your country");
  //ret = false; // now there is an error, so set the ret variable to be false;
 //}
     //7
 if (postcode.value == "")
 {
  postcode.focus();
  alert("Please fill in your postcode");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
 //8
 if (homePhone.value == "")
 {
  homePhone.focus();
  alert("Please fill in your home phone");
  ret = false; // now there is an error, so set the ret variable to be false;
 }

      //9
 if (email.value == "")
 {
  email.focus();
  alert("Please fill in your email");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
       //10
 if (driversLicence.value == "")
 {
  driversLicence.focus();
  alert("Please fill in your drivers licence");
  ret = false; // now there is an error, so set the ret variable to be false;
 }

         //13
 if (eligible.value == "")
 {
  eligible.focus();
  alert("Please fill if you are eligible to work in Australia");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
         //14
 if (previouslyEmployed.value == "")
 {
  previouslyEmployed.focus();
  alert("Please fill if you previously worked for Anderson Mine Services/Anderson Industries");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
         //15
 if (qualifications.value == "")
 {
  qualifications.focus();
  alert("Please fill in your qualifications");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
         /*
		 //16
 if (yearFrom.value == "")
 {
  yearFrom.focus();
  alert("Please fill if out the year from for qualifications");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
         //17
 if (courseStudied.value == "")
 {
  courseStudied.focus();
  alert("Please fill if out the course studied");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
            //18
 if (qualificationAttained.value == "")
 {
  qualificationAttained.focus();
  alert("Please fill if out qualification attained");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
 */
             //19
 if (nametrade.value == "")
 {
  nametrade.focus();
  alert("Please fill if out Name of Trade");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
   /*       
   //20
 if (nameemployer.value == "")
 {
  nameemployer.focus();
  alert("Please fill if out name of employer with whom you served your apprenticeship");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
 
              //21
 if (refereename.value == "")
 {
  refereename.focus();
  alert("Please fill if out Referee Name");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
 */
 /*
               //22
 if (company.value == "")
 {
  company.focus();
  alert("Please fill if out company name of referee");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
                //23
 if (refereeposition.value == "")
 {
  refereeposition.focus();
  alert("Please fill if out the referee's position");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
                 //24
 if (current.value == "")
 {
  current.focus();
  alert("Please fill if out the referee's current contact phone number");
  ret = false; // now there is an error, so set the ret variable to be false;
 }
 */
                 //25
 if (conditions.value == "")
 {
  conditions.focus();
  alert("Please tick that you have read the terms and conditions");
  ret = false; // now there is an error, so set the ret variable to be false;
 }

 // now you can check if the funtion has been successful or not... if it has been then we can send it
 if (ret == true)
  send_mail();
 
 // now return the functions success value
 return ret;
};
