	function checkChildBox(postForm, postSource, postTarget) {
		var x = postForm.elements["service[]"];
		
		for (i=0; i<x.length; i++) {
			if (x[i].value == postSource) {
				var y = postForm.elements["service[]"][i];
			}
			if (x[i].value == postTarget) {
				var z = postForm.elements["service[]"][i];
			}
		}
		
		if (y.checked) {
			
		}
		else {
			z.checked = false;
		}
	}
	
	function checkParentBox(postForm, postSource, postTarget) {
		var x = postForm.elements["service[]"];
		
		for (i=0; i<x.length; i++) {
			if (x[i].value == postSource) {
				var y = postForm.elements["service[]"][i];
			}
			if (x[i].value == postTarget) {
				var z = postForm.elements["service[]"][i];
			}
		}
		
		if (y.checked) {
			z.checked = true;
		}
		else {
			
		}
	}
	
	function createXMLHttpRequest() {
		var XMLRequest = false;
		
		// create object for IE7, Mozilla, Safari, etc. (native object)
		if (window.XMLHttpRequest) {
			XMLRequest = new XMLHttpRequest();
		}
		// create object for IE6, IE5, etc. (ActiveX object)
		else if (window.ActiveXObject) {
			var success = false;
			var progIDs = new Array(
				"Msxml2.XMLHTTP.6.0",
				"Msxml2.XMLHTTP.3.0",
				"Msxml2.XMLHTTP",
				"Microsoft.XMLHTTP"
			);
			
			for (i=0; i<progIDs.length && !success; i++) {
				try {
					XMLRequest = new ActiveXObject(progIDs[i]);
					success = true;
				}
				catch (failure) {
					
				}
			}
		}
		
		return XMLRequest;
	}
	
	function jumpSelect(postField) {
		eval("document.location='" + postField.options[postField.selectedIndex].value + "'");
	}
	
	var populate = false;
	
	function populateUsername(postForm) {
		populate = !populate;
		
		if (populate) {
			postForm.username.value = postForm.email_address.value;
		}
		else {
			postForm.username.value = "";
		}
	}
	
	function popupWindow(popupURL, popupWidth, popupHeight) {
		var windowWidth = popupWidth;
		var windowHeight = popupHeight;
		
		var leftPosition = Math.ceil((screen.width - windowWidth) / 2);
		var topPosition = Math.ceil((screen.height - windowHeight) / 2);
		
		var tmpWindow = window.open(popupURL, "popup_window", "width=" + windowWidth + ", height=" + windowHeight + ", left=" + leftPosition + ", top=" + topPosition + ", channelmode=0, directories=0, fullscreen=0, location=0, menubar=0, resizable=1, scrollbars=1, status=0, toolbar=0");
		tmpWindow.focus();
	}
	
	function relateSelect(postForm, postField, postTarget, dataArray, refArray) {
		var selectedOption = postForm.elements[postField].selectedIndex;
		var targetBox = postForm.elements[postTarget];
		var refBox = new Array();
		
		for (i=0; i<postForm.elements[refArray].length; i++) {
			refBox[postForm.elements[refArray][i].value] = i;
		}
		
		targetBox.length = 0;
		
		if (selectedOption == 0) {
			k = 0;
			
			for (i=1; i<dataArray.length; i++) {
				for (j=0; j<dataArray[i].length; j++) {
					if (!(dataArray[i][j].value in refBox)) {
						targetBox[k] = new Option(dataArray[i][j].text, dataArray[i][j].value, "", "");
						k++;
					}
				}
			}
		}
		else {
			k = 0;
			
			for (i=0; i<dataArray[selectedOption].length; i++) {
				if (!(dataArray[selectedOption][i].value in refBox)) {
					targetBox[k] = new Option(dataArray[selectedOption][i].text, dataArray[selectedOption][i].value, "", "");
					k++;
				}
			}
		}
	}
	
	function removeOptions(postForm, postSource, postField, postTarget, dataArray) {
		var theBox = postForm.elements[postSource];
		
		var theBoxArray = new Array();
		var lookupArray = new Array();
		
		var theBoxLength = 0;
		
		for (i=0; i<theBox.options.length; i++) {
			if (!theBox.options[i].selected) {
				lookupArray[theBox.options[i].text] = theBox.options[i].value;
				theBoxArray[theBoxLength] = theBox.options[i].text;
				theBoxLength++;
			}
		}
		
		theBoxArray.sort();
		
		theBox.length = 0;
		
		for (i=0; i<theBoxArray.length; i++) {
			theBox[i] = new Option(theBoxArray[i], lookupArray[theBoxArray[i]], "", "");
		}
		
		relateSelect(postForm, postField, postTarget, dataArray, postSource);
	}
	
	function setDateSelect(postForm, postMonth, postMonthValue, postDay, postDayValue, postYear, postYearValue) {
		var x = postForm.elements[postMonth];
		
		for (i=0; i<x.length; i++) {
			if (x.options[i].value == postMonthValue) {
				x.options[i].selected = true;
				break;
			}
		}
		
		var x = postForm.elements[postDay];
		
		for (i=0; i<x.length; i++) {
			if (x.options[i].value == postDayValue) {
				x.options[i].selected = true;
				break;
			}
		}
		
		var x = postForm.elements[postYear];
		
		for (i=0; i<x.length; i++) {
			if (x.options[i].value == postYearValue) {
				x.options[i].selected = true;
				break;
			}
		}
	}
	
	function showAdmin(formId, formLength) {
		for (i=1; i<=formLength; i++) {
			document.getElementById("form_" + i).style.display = "none";
			document.getElementById("td_" + i).style.backgroundColor = "#5E5E5E";
		}
		
		document.getElementById("form_" + formId).style.display = "block";
		document.getElementById("td_" + formId).style.backgroundColor = "#A00000";
	}
	
	function swapOptions(postForm, postSource, postTarget) {
		var fromBox = postForm.elements[postSource];
		var toBox = postForm.elements[postTarget];
		
		var fromBoxArray = new Array();
		var toBoxArray = new Array();
		var lookupArray = new Array();
		
		for (i=0; i<toBox.options.length; i++) {
			lookupArray[toBox.options[i].text] = toBox.options[i].value;
			toBoxArray[i] = toBox.options[i].text;
		}
		
		var fromBoxLength = 0;
		var toBoxLength = toBoxArray.length;
		
		for (i=0; i<fromBox.options.length; i++) {
			if (fromBox.options[i].selected) {
				lookupArray[fromBox.options[i].text] = fromBox.options[i].value;
				toBoxArray[toBoxLength] = fromBox.options[i].text;
				toBoxLength++;
			}
			else {
				lookupArray[fromBox.options[i].text] = fromBox.options[i].value;
				fromBoxArray[fromBoxLength] = fromBox.options[i].text;
				fromBoxLength++;
			}
		}
		
		fromBoxArray.sort();
		toBoxArray.sort();
		
		fromBox.length = 0;
		toBox.length = 0;
		
		for (i=0; i<fromBoxArray.length; i++) {
			fromBox[i] = new Option(fromBoxArray[i], lookupArray[fromBoxArray[i]], "", "");
		}
		
		for (i=0; i<toBoxArray.length; i++) {
			toBox[i] = new Option(toBoxArray[i], lookupArray[toBoxArray[i]], "", "");
		}
	}
	
	function validateLoginForm(postForm) {
		var errorMessage = "The following errors must be corrected before proceeding:\n";
		var validFlag = true;
		
		// validate text
		var x = postForm.username.value;
		document.getElementById('username').style.border = "3px solid #D5D5D5";
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter a username";
			validFlag = false;
			document.getElementById('username').style.border = "3px solid #C00000";
		}
		
		// validate password
		var x = postForm.password.value;
		document.getElementById('password').style.border = "3px solid #D5D5D5";
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter a password";
			validFlag = false;
			document.getElementById('password').style.border = "3px solid #C00000";
		}
		
		// validate form
		if (validFlag == false) {
			alert(errorMessage);
			return false;
		}
		else {
			return true;
		}
	}
	
	function validatePasswordForm(postForm) {
		var errorMessage = "The following errors must be corrected before proceeding:\n";
		var validFlag = true;
		
		// validate text
		var x = postForm.email_address.value;
		var filter = /^[A-Za-z0-9\-\._]+@[A-Za-z0-9\-\.]+\.(biz|ca|com|edu|gov|info|mil|museum|name|net|org|uk|us)$/;
		document.getElementById('email_address').style.border = "3px solid #D5D5D5";
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter an email address";
			validFlag = false;
			document.getElementById('email_address').style.border = "3px solid #C00000";
		}
		else if (!filter.test(x)) {
			errorMessage += "\n - Enter an email address (format errors detected)";
			validFlag = false;
			document.getElementById('email_address').style.border = "3px solid #C00000";
		}
		
		// validate text
		var x = postForm.username.value;
		document.getElementById('username').style.border = "3px solid #D5D5D5";
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter a username";
			validFlag = false;
			document.getElementById('username').style.border = "3px solid #C00000";
		}
		
		// validate form
		if (validFlag == false) {
			alert(errorMessage);
			return false;
		}
		else {
			return true;
		}
	}
	
	function validateSignupForm1(postForm) {
		var errorMessage = "The following errors must be corrected before proceeding:\n";
		var validFlag = true;
		
		// validate radio
		var x = postForm.type;
		
		if (!x[0].checked && !x[1].checked && !x[2].checked) {
			errorMessage += "\n - Select a website option: Team, League, or Tournament";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.folder.value;
		var filter = /^[A-Za-z0-9\-_]+$/i;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your desired Sport.ca URL";
			validFlag = false;
		}
		else if (!filter.test(x)) {
			errorMessage += "\n - Enter your desired Sport.ca URL (only alpha-numeric characters, '-', and '_')";
			validFlag = false;
		}
		else if (x.length < 3) {
			errorMessage += "\n - Enter your desired Sport.ca URL (minimum 3 characters)";
			validFlag = false;
		}
		
		// validate select
		var x = postForm.province_id.options[postForm.province_id.selectedIndex].value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Select your province";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.city_town.value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your city/town";
			validFlag = false;
		}
		
		// validate select
		var x = postForm.sport_id.options[postForm.sport_id.selectedIndex].value;
		var y = postForm.sport_other.value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Select your sport";
			validFlag = false;
		}
		else if (x == "10" && (y == "" || y == null)) {
			errorMessage += "\n - Enter your sport";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.name.value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter the name of your team, league, or tournament";
			validFlag = false;
		}
		
		// validate select
		var x = postForm.gender.options[postForm.gender.selectedIndex].value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Select a gender option";
			validFlag = false;
		}
		
		// validate text
		var x1 = postForm.age_range_minimum.value;
		var x2 = postForm.age_range_maximum.value;
		var filter = /^[0-9]{1,2}$/;
		
		if (x1 == "" || x1 == null || x2 == "" || x2 == null) {
			errorMessage += "\n - Enter an age range";
			validFlag = false;
		}
		else if (!filter.test(x1) || !filter.test(x2)) {
			errorMessage += "\n - Enter an age range (numeric characters only)";
			validFlag = false;
		}
		else if (parseFloat(x1) > parseFloat(x2)) {
			errorMessage += "\n - Enter an age range (minimum age to maximum age)";
			validFlag = false;
		}
		
		// validate radio
		var x = postForm.legal_drinking_age;
		
		if (!x[0].checked && !x[1].checked) {
			errorMessage += "\n - Select a legal drinking age option";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.first_name.value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your first name";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.last_name.value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your last name";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.email_address.value;
		var filter = /^[A-Za-z0-9\-\._]+@[A-Za-z0-9\-\.]+\.(biz|ca|com|edu|gov|info|mil|museum|name|net|org|uk|us)$/;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your email address";
			validFlag = false;
		}
		else if (!filter.test(x)) {
			errorMessage += "\n - Enter your email address (format errors detected)";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.username.value;
		var filter1 = /^[A-Za-z0-9\-\._]+$/;
		var filter2 = /^[A-Za-z0-9\-\._]+@[A-Za-z0-9\-\.]+\.(biz|ca|com|edu|gov|info|mil|museum|name|net|org|uk|us)$/;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your desired username";
			validFlag = false;
		}
		else if (!filter1.test(x) && !filter2.test(x)) {
			errorMessage += "\n - Enter your desired username (an email address or alpha-numeric characters, '-', '_', and '.')";
			validFlag = false;
		}
		
		// validate password
		var x1 = postForm.elements['password[]'][0].value;
		var x2 = postForm.elements['password[]'][1].value;
		
		if (x1 == "" || x1 == null || x2 == "" || x2 == null) {
			errorMessage += "\n - Enter a password and then re-enter it";
			validFlag = false;
		}
		else if (x1.length < 3 || x2.length < 3) {
			errorMessage += "\n - Enter a password and then re-enter it (minimum 3 characters)";
			validFlag = false;
		}
		else if (x1 != x2) {
			errorMessage += "\n - Enter a password and then re-enter it (passwords do not match)";
			validFlag = false;
		}
		
		// validate checkbox
		var x = postForm.elements['terms_of_use'];
		
		if (!x.checked) {
			errorMessage += "\n - Indicate that you have read and agreed to the Terms of Use";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.verification_code.value;
		var filter = /^[0-9]{5}$/;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter the verification code";
			validFlag = false;
		}
		else if (!filter.test(x)) {
			errorMessage += "\n - Enter the verification code (5 numeric characters only)";
			validFlag = false;
		}
		
		// validate form
		if (validFlag == false) {
			alert(errorMessage);
			return false;
		}
		else {
			return true;
		}
	}
	
	function validateSignupForm2(postForm) {
		var errorMessage = "The following errors must be corrected before proceeding:\n";
		var validFlag = true;
		
		// validate select
		var x = postForm.province_id.options[postForm.province_id.selectedIndex].value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Select your province";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.city_town.value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your city/town";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.first_name.value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your first name";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.last_name.value;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your last name";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.email_address.value;
		var filter = /^[A-Za-z0-9\-\._]+@[A-Za-z0-9\-\.]+\.(biz|ca|com|edu|gov|info|mil|museum|name|net|org|uk|us)$/;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your email address";
			validFlag = false;
		}
		else if (!filter.test(x)) {
			errorMessage += "\n - Enter your email address (format errors detected)";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.username.value;
		var filter1 = /^[A-Za-z0-9\-\._]+$/;
		var filter2 = /^[A-Za-z0-9\-\._]+@[A-Za-z0-9\-\.]+\.(biz|ca|com|edu|gov|info|mil|museum|name|net|org|uk|us)$/;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter your desired username";
			validFlag = false;
		}
		else if (!filter1.test(x) && !filter2.test(x)) {
			errorMessage += "\n - Enter your desired username (an email address or alpha-numeric characters, '-', '_', and '.')";
			validFlag = false;
		}
		
		// validate password
		var x1 = postForm.elements['password[]'][0].value;
		var x2 = postForm.elements['password[]'][1].value;
		
		if (x1 == "" || x1 == null || x2 == "" || x2 == null) {
			errorMessage += "\n - Enter a password and then re-enter it";
			validFlag = false;
		}
		else if (x1.length < 3 || x2.length < 3) {
			errorMessage += "\n - Enter a password and then re-enter it (minimum 3 characters)";
			validFlag = false;
		}
		else if (x1 != x2) {
			errorMessage += "\n - Enter a password and then re-enter it (passwords do not match)";
			validFlag = false;
		}
		
		// validate checkbox
		var x = postForm.elements['terms_of_use'];
		
		if (!x.checked) {
			errorMessage += "\n - Indicate that you have read and agreed to the Terms of Use";
			validFlag = false;
		}
		
		// validate text
		var x = postForm.verification_code.value;
		var filter = /^[0-9]{5}$/;
		
		if (x == "" || x == null) {
			errorMessage += "\n - Enter the verification code";
			validFlag = false;
		}
		else if (!filter.test(x)) {
			errorMessage += "\n - Enter the verification code (5 numeric characters only)";
			validFlag = false;
		}
		
		// validate form
		if (validFlag == false) {
			alert(errorMessage);
			return false;
		}
		else {
			return true;
		}
	}