// Handle the selection of a title
function rego_titleSelect($sel) {
	// OTHER //
	
	// If the title is 'other'...	
	if ($sel == "TitleOther") {
		// Show the other box
		document.getElementById("OtherTitle").style.display = "block";
	} else {
		// Hide the other box
		document.getElementById("OtherTitle").style.display = "none";
	}
}

// Handle the selection of a church
function rego_churchSelect($sel) {
	// SERVING //
	
	// If the church is a CIC church...
	if ($sel.substr(0, 3) == "CIC") {
		// Show the 'serving section'
		document.getElementById("ServingSection").style.display = "block";
	// If the church is something else...
	} else {
		// Hide the 'serving' section
		document.getElementById("ServingSection").style.display = "none";
	}
	
	
	// OTHER //
	
	// If the church is 'other'...
	if ($sel == "OtherChurch") {
		// Show the other box
		document.getElementById("ChurchOther").style.display = "block";
	} else {
		// Hide the other box
		document.getElementById("ChurchOther").style.display = "none";
	}
	
	
	// HOST DELEGATES //
	
	// If the church is CIC Auckland...
	if ($sel == "CICAuckland") {
		// Show the delegates section
		document.getElementById("HostDelegates").style.display = "block";
	// If the church is NOT CIC Auckland...
	} else {
		// Hide the delegates section
		document.getElementById("HostDelegates").style.display = "none";
	}
}

// Handle the clicking of the serving question checkbox
function rego_servingSelect() {
	// If currently ticked (it therefore just got unticked)...
	if (document.getElementById("ServingQVal").value == "on") {
		// Hide the 'serving options'
		document.getElementById("ServingOptions").style.display = "none";
		document.getElementById("TeamServing").style.display = "none";
		// Toggle ServingQVal
		document.getElementById("ServingQVal").value = "off";
	// If NOT currently ticked (it therefore just got ticked)...
	} else {
		// Show the 'serving options'
		document.getElementById("ServingOptions").style.display = "block";
		document.getElementById("TeamServing").style.display = "block";
		// Toggle ServingQVal
		document.getElementById("ServingQVal").value = "on";
	}
}

// Handle the initialisation of the serving question checkbox
function rego_servingInit() {
	// If currently ticked...
	if (document.getElementById("ServingQVal").value == "on") {
		// Show the 'serving options'
		document.getElementById("ServingOptions").style.display = "block";
		document.getElementById("TeamServing").style.display = "block";
		// Toggle ServingQVal
		document.getElementById("ServingQVal").value = "on";
	// If NOT currently ticked...
	} else {
		// Hide the 'serving options'
		document.getElementById("ServingOptions").style.display = "none";
		document.getElementById("TeamServing").style.display = "none";
		// Toggle ServingQVal
		document.getElementById("ServingQVal").value = "off";
	}
}

// Handle the selection of full or part time serving
function rego_serveTimeSelect($sel) {
	// DAYS //
	
	// If part...
	if ($sel == "part") {
		// Show the days selection
		document.getElementById("ServingDays").style.display = "block";
	// If full...
	} else {
		// Hide the days selection
		document.getElementById("ServingDays").style.display = "none";
	}
}

// Handle the selection of Global Kids
function rego_StreamSelect($sel) {
	// DAYS //
	
	// If select...
	if ($sel == "GlobalKids") {
		// Show the days selection
		document.getElementById("StreamOptions").style.display = "block";
	// If all...
	} else {
		// Hide the days selection
		document.getElementById("StreamOptions").style.display = "none";
	}
}

// Handle the selection of All or Select sessions for Global Kids
function rego_serveKidsTimeSelect($sel) {
	// DAYS //
	
	// If select...
	if ($sel == "select") {
		// Show the days selection
		document.getElementById("StreamDays").style.display = "block";
	// If all...
	} else {
		// Hide the days selection
		document.getElementById("StreamDays").style.display = "none";
	}
}

// Show postal address fields when tick box is checked
function showhidefield()
  {
    if (document.WAATKRegistrationForm.PostalAddress.checked)
    {
      document.getElementById("postalUser").style.display = "block";
    }
    else
    {
      document.getElementById("postalUser").style.display = "none";
    }
}

// Show postal address fields when tick box is checked FOR GI TEAM REGISTRATIONS FORM
function showhidefieldGI()
  {
    if (document.WADAInsertForm.PostalCheck.checked)
    {
      document.getElementById("postal").style.display = "block";
    }
    else
    {
      document.getElementById("postal").style.display = "none";
    }
}

// Show 'other' title field when 'Other' is selected from drop-down list
function itemSelect($selItem) {
	if ($selItem == "Other") {
		document.getElementById("OtherTitle").style.display = "block";
	} else {
		document.getElementById("OtherTitle").style.display = "none";
	}
}



// Handle the clicking of the MINISTRY TEAM question checkbox
function rego_teamSelect() {
	// If currently ticked (it therefore just got unticked)...
	if (document.getElementById("TeamQValue").value == "on") {
		// Hide the 'ministry team options'
		document.getElementById("TeamOptions").style.display = "none";
		// Toggle ServingQVal
		document.getElementById("TeamQValue").value = "off";
	// If NOT currently ticked (it therefore just got ticked)...
	} else {
		// Show the 'ministry team options'
		document.getElementById("TeamOptions").style.display = "block";
		// Toggle ServingQVal
		document.getElementById("TeamQValue").value = "on";
	}
}

// Handle the initialisation of the MINISTRY TEAM question checkbox
function rego_teamInit() {
	// If currently ticked...
	if (document.getElementById("TeamQValue").value == "on") {
		// Show the 'serving options'
		document.getElementById("TeamOptions").style.display = "block";
		// Toggle ServingQVal
		document.getElementById("TeamQValue").value = "on";
	// If NOT currently ticked...
	} else {
		// Hide the 'serving options'
		document.getElementById("TeamOptions").style.display = "none";
		// Toggle ServingQVal
		document.getElementById("TeamQValue").value = "off";
	}
}

// Handle the MINISTRY TEAM SELECTION
function rego_teamOtherSelect($sel) {
	// If other is selected
	if ($sel == "OtherTeam") {
		// Show the text box to complete for other team
		document.getElementById("TeamOther").style.display = "block";
	// If full...
	} else {
		// Hide the other team selection
		document.getElementById("TeamOther").style.display = "none";
	}
}

// Initialise dyamic content on page load
function rego_init($churchName, $time, $team, $kidstime, $streamselect) {
	rego_churchSelect($churchName);
	rego_servingInit();
	rego_teamInit();
	rego_serveTimeSelect($time);
	rego_serveKidsTimeSelect($kidstime);
	rego_StreamSelect($streamselect);	
	rego_teamOtherSelect($team);
}