// JavaScript Document
function isEmailAddr (s){ 
	var rv = false
	if ((s == null) || (s.length == 0)) 
       rv = false;
  else {
		var reEmail =/([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		//reEmail = /.+\@.+\..+$/
		
		rv = reEmail.test(s)
    }
	if(rv){
	return rv
	}else{
		alert('Sorry "'+ s +'" is not a valid email address')	
		return false
	}
}
 
 function EmailValidator(theForm){
 
  if (theForm.Name_of_school.value == ""){
    alert("Please enter the name of your school.");
    theForm.Name_of_school.focus();
    return (false);
  }
  if (theForm.loginName.value == ""){
    alert("Please enter a login name.");
    theForm.loginName.focus();
    return (false);
  }
  if (theForm.Address.value == ""){
    alert("Please enter the school address.");
    theForm.Address.focus();
    return (false);
  }
  if (theForm.Phone_no.value == ""){
    alert("Please enter the school's phone number.");
    theForm.Phone_no.focus();
    return (false);
  }
  if (theForm.Fax_no.value == ""){
    alert("Please enter the school's fax number.");
    theForm.Fax_no.focus();
    return (false);
  }
  
  if (!isEmailAddr(theForm.email_from.value)){
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.email_from.focus();
    return (false);
  }
 
  if (theForm.Name_of_principal.value == ""){
    alert("Please enter the name of the Principal.");
    theForm.Name_of_principal.focus();
    return (false);
  }
    if (theForm.Key_contacts_name.value == ""){
    alert("Please enter the key contact's name.");
    theForm.Key_contacts_name.focus();
    return (false);
  }
    if (theForm.Key_contacts_position.value == ""){
    alert("Please enter the key contact's postition.");
    theForm.Key_contacts_position.focus();
    return (false);
  }
    if (theForm.Name_Health_Coordinator.value == ""){
    alert("Please enter the name of the Health Co-ordinator.");
    theForm.Name_Health_Coordinator.focus();
    return (false);
  }
    if (theForm.Name_Food_Service_Manager.value == ""){
    alert("Please enter the name of the Food Service Manager.");
    theForm.Name_Food_Service_Manager.focus();
    return (false);
  }
    if (theForm.School_roll.value == ""){
    alert("Please enter School Roll numbers.");
    theForm.School_roll.focus();
    return (false);
  }
      if (theForm.Canteen_Lunch_Order.value == ''){
    alert("Please enter if you have a canteen or lunch order.");
    //theForm.Canteen_Lunch_Order.focus();
    return (false);
  }
      if (theForm.No_students_regularly_buying_lunch.value == ""){
    alert("Please enter the number of students regularly buying lunch.");
    theForm.No_students_regularly_buying_lunch.focus();
    return (false);
  }
      if (theForm.Sandwiches_rolls.value == ""){
    alert("Please enter the amount of Sandwiches and rolls you sell a day.");
    theForm.Sandwiches_rolls.focus();
    return (false);
  }
      if (theForm.Muffins_scones_pikelets_plain_fruit_buns.value == ""){
    alert("Please enter the amount of Muffins, scones, pikelets, plain fruit and buns you sell a day.");
    theForm.Muffins_scones_pikelets_plain_fruit_buns.focus();
    return (false);
  }
      if (theForm.Cakes_slices_cookies.value == ""){
    alert("Please enter the amount of Cakes, slices and cookies you sell a day.");
    theForm.Cakes_slices_cookies.focus();
    return (false);
  }
      if (theForm.Doughnuts_cream_buns.value == ""){
    alert("Please enter the amount of Doughnuts and cream buns you sell a day.");
    theForm.Doughnuts_cream_buns.focus();
    return (false);
  }
        if (theForm.Meat_pies_sausage_rolls.value == ""){
    alert("Please enter the amount of Meat pies and sausage rolls you sell a day.");
    theForm.Meat_pies_sausage_rolls.focus();
    return (false);
  }
        if (theForm.Low_fat_pies.value == ""){
    alert("Please enter the amount of Low fat pies you sell a day.");
    theForm.Low_fat_pies.focus();
    return (false);
  }      
  if (theForm.American_hot_dogs.value == ""){
    alert("Please enter the amount of American hot dogs you sell a day.");
    theForm.American_hot_dogs.focus();
    return (false);
  }      
  if (theForm.Toasted_sandwiches_grilled_buns_pizzas.value == ""){
    alert("Please enter the amount of Toasted sandwiches, grilled buns and pizzas you sell a day.");
    theForm.Toasted_sandwiches_grilled_buns_pizzas.focus();
    return (false);
  }      
  if (theForm.Hot_chips.value == ""){
    alert("Please enter the amount of Hot chips you sell a day.");
    theForm.Hot_chips.focus();
    return (false);
  }      
  if (theForm.Oven_baked_chips_wedges.value == ""){
    alert("Please enter the amount of Oven baked chips and wedges you sell a day.");
    theForm.Oven_baked_chips_wedges.focus();
    return (false);
  }      
  if (theForm.Popcorn.value == ""){
    alert("Please enter the amount of Popcorn you sell a day.");
    theForm.Popcorn.focus();
    return (false);
  }
    if (theForm.Potato_chips_corn_chips_other_snack_foods.value == ""){
    alert("Please enter the amount of Potato chips, corn chips and other snack foods you sell a day.");
    theForm.Potato_chips_corn_chips_other_snack_foods.focus();
    return (false);
  }
    if (theForm.Fresh_fruit.value == ""){
    alert("Please enter the amount of Fresh fruit you sell a day.");
    theForm.Fresh_fruit.focus();
    return (false);
  }
    if (theForm.Tinned_dried_fruit.value == ""){
    alert("Please enter the amount of Tinned and dried fruit you sell a day.");
    theForm.Tinned_dried_fruit.focus();
    return (false);
  }
    if (theForm.Yoghurt_dairy_food.value == ""){
    alert("Please enter the amount of Yoghurt and dairy food you sell a day.");
    theForm.Yoghurt_dairy_food.focus();
    return (false);
  }
    if (theForm.Chocolate_bars_muesli_bars.value == ""){
    alert("Please enter the amount of Chocolate bars and muesli bars you sell a day.");
    theForm.Chocolate_bars_muesli_bars.focus();
    return (false);
  }
      if (theForm.Sweets_licorice.value == ""){
    alert("Please enter the amount of Sweet and licorice you sell a day.");
    theForm.Sweets_licorice.focus();
    return (false);
  }
      if (theForm.Flavoured_milk_milkshakes.value == ""){
    alert("Please enter the amount of Flavoured milk and milkshakes you sell a day.");
    theForm.Flavoured_milk_milkshakes.focus();
    return (false);
  }
        if (theForm.Fizzy_drinks.value == ""){
    alert("Please enter the amount of Fizzy drinks you sell a day.");
    theForm.Fizzy_drinks.focus();
    return (false);
  }
  return (true);
}
function frmJobValidator(theForm){

 // validation checking for job form feilds
   if (theForm.Title.value == ""){
    alert("Please enter the Title.");
    theForm.Title.focus();
    return (false);
  }
  if (theForm.FamilyName.value == ""){
    alert("Please enter the Family Name.");
    theForm.FamilyName.focus();
    return (false);
  }
  
   if (theForm.Givennames.value == ""){
    alert("Please enter the Given names.");
    theForm.Givennames.focus();
    return (false);
  }
   if (theForm.HomePhone.value == ""){
    alert("Please enter the Home Phone number.");
    theForm.HomePhone.focus();
    return (false);
  }
  if (!isEmailAddr(theForm.email_from.value)){
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    theForm.email_from.focus();
    return (false);
  }
  
if(!theForm.declaration[0].checked) {
 alert("Please accept the declaration before submitting your application");
 theForm.declaration[0].focus();
 return (false);
}
// end of job validation form fields
  return (true);
}