function initFormTable(tableName) {
	var tObj = document.getElementById(tableName);
	for (var i=0;i<tObj.rows.length;i++) {
		tObj.rows[i].groupItems = tObj.rows;
		tObj.rows[i].onclick = function() {
			manageRowClick(this);
		}
		/*tObj.rows[i].onmouseout = function() {
			this.style.backgroundColor = "";
		}*/
	}
	
	/*var inputClassName = "inputBoxes";
	var allInputItems = tObj.all ? tObj.all : tObj.getElementsByTagName('input');
	
	for (var i=0;i<allInputItems.length;i++) {
		if (allInputItems[i].className.toLowerCase() == inputClassName.toLowerCase()) {
			allInputItems[i].groupItems = allInputItems;
			allInputItems[i].inputClassName = inputClassName;
			allInputItems[i].onclick = function() {
				manageInputClick(this);
			}
		}
	}*/
}

function manageRowClick(rObj) {
	if (typeof(rObj.groupItems) != "undefined") {
		for (var i=0;i<rObj.groupItems.length;i++) {
			if (rObj.groupItems[i] == rObj) {
				rObj.groupItems[i].style.backgroundColor = "#fce4c8";
			} else {
				rObj.groupItems[i].style.backgroundColor = "";
			}
		}
	}
}

function manageInputClick(sObj) {
	if (typeof(sObj.groupItems) != "undefined") {
		for (var i=0;i<sObj.groupItems.length;i++) {
			if (typeof(sObj.groupItems[i].inputClassName) != "undefined" && sObj.groupItems[i].className.toLowerCase() == sObj.groupItems[i].inputClassName.toLowerCase()) {
				if (sObj.groupItems[i] == sObj) {
					sObj.groupItems[i].style.borderColor = "#f29522";
				} else {
					sObj.groupItems[i].style.borderColor = "#606163";
				}
			}
		}
	}
}

function checkForNum(obj) {
	if (isNaN(obj.value)) {
		obj.value = 1;
	}
}

function checkForm() {
	var eForm = document.getElementById('DelegateRegistration');
	var message = "These fields are still required for submit:";
	
	var isValid = true;
	
	if (eForm.first_name.value == "") {
		message += "<br>*First Name";
		isValid = false;
	}
	if (eForm.surname.value == "") {
		message += "<br>*Surname";
		isValid = false;
	}
	if (eForm.address_line1.value == "" && eForm.address_line2.value == "" && eForm.address_line3.value == "") {
		message += "<br>*Postal Address";
		isValid = false;
	}
	if (eForm.email_address.value == "") {
		message += "<br>*E-mail Address";
		isValid = false;
	}
	if (eForm.phone_number.value == "") {
		message += "<br>*Phone Number";
		isValid = false;
	}
	if (eForm.cell_number.value == "") {
		message += "<br>*Cell Number";
		isValid = false;
	}
	if (eForm.number_of_delegates.value == "") {
		message += "<br>*Number of Delegates";
		isValid = false;
	}
	
	if (isValid) {
		eForm.submit();
	} else {
		alert(message);
	}
}

function increaseDecrease(fieldName,iord) {
	var inputField = document.getElementById(fieldName);
	
	if (iord == "i") {
		inputField.value = parseInt(inputField.value) + 1;
	} else {
		if (inputField.value > 1) {
			inputField.value = parseInt(inputField.value) - 1;
		}
	}
}