// JavaScript Document
<!--
//global variables that can be used by ALL the function son this page.
var inputs;
var imgFalse = '/images/forms/false.gif';
var imgTrue = '/images/forms/true.gif';

//this function runs when the page is loaded, put all your other onload stuff in here too.
function init() {
    replaceChecks();
}

function replaceChecks() {
    
    //get all the input fields on the page
    inputs = document.getElementsByTagName('input');

    //cycle trough the input fields
    for(var i=0; i < inputs.length; i++) {

        //check if the input is a checkbox
        if(inputs[i].getAttribute('type') == 'checkbox') {
            
            //create a new image
            var img = document.createElement('img');
            
            //check if the checkbox is checked
            if(inputs[i].checked) {
                img.src = imgTrue;
            } else {
                img.src = imgFalse;
            }

            //set image ID and onclick action
            img.id = 'checkImage'+i;
            //set image
            img.onclick = new Function('checkChange('+i+');');
            //place image in front of the checkbox
            inputs[i].parentNode.insertBefore(img, inputs[i]);
            
            //hide the checkbox
            inputs[i].style.display='none';
        }
    }
}

function fieldsNotBlank() {
  if (document.registration.TitleMain.value==""){alert("Please enter your title");return false;}
  if (document.registration.FirstNameBox.value==""){alert("Please enter your first name");return false;}
  if (document.registration.LastNameBox.value==""){alert("Please enter your  last name");return false;}
  if (document.registration.EmailBox.value==""){alert("Please enter your email address");return false;}
  else {
	//check email
	var rx = new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");
	if(!rx.test(document.registration.EmailBox.value)) {alert("Please enter a valid email address");return false;}
  }
  if (document.registration.Phone.value==""){alert("Please enter your phone number");return false;}

  if (document.registration.City.value==""){alert("Please enter your City / Suburb");return false;}
  if (document.registration.StateLive.value==""){alert("Please enter your home state");return false;}
  if (document.registration.DayDropDown.value=="99" || document.registration.MonthDropDown.value=="99" || document.registration.YearDropDown.value=="1983"){
    alert("Please enter the approximate date of your wedding");return false;
  }
  if (document.registration.Approx_Time.value==""){alert("Please fill out the approximate time of your wedding");return false;}
  if (document.registration.LocationDropDown.value==""){alert("Please enter the Australian state of your wedding");return false;}
  if (document.registration.Approx_Location.value==""){alert("Please enter the approximate location of your wedding");return false;}
  if (document.registration.Approx_Guests.value==""){alert("Please enter the approximate number of guests invited to your wedding");return false;}
  
  //if (!hasChecked()) {alert("Please select at least one category of suppliers to contact");return false;}
  if (!document.getElementById("chkConsent").checked && document.getElementById("consentRequired").value=="true"){alert("Please indicate your consent to being contacted by suitable suppliers by ticking the box at the bottom of the form.");return false;}

  
  return true;
}
window.onload = init;
//-->