	function validateAppForm(theForm) {
		if (theForm.club_name.value == "") {
			alert("cannot proceed without a club name supplied");
			theForm.club_name.focus();
			return false;
		}
		if (theForm.club_capt_name.value == "") {
			alert("cannot proceed without a Captain's name supplied");
			theForm.club_capt_name.focus();
			return false;
		}
		if (theForm.club_capt_phone1.value == "") {
			alert("cannot proceed without a Captain's phone number supplied");
			theForm.club_capt_phone1.focus();
			return false;
		}
		
		theForm.submit();
		return true;
	}

	function validateNewClubAppForm(theForm) {
		if (theForm.club_name.value == "") {
			alert("cannot proceed without a club name supplied");
			theForm.club_name.focus();
			return false;
		}

		theForm.submit();
		return true;
	}

	function findPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
			return [curleft,curtop];
		}
	}

	function openPopWindowSize(url,desc,wdth,hght,item) {
		if (item) {
			var elem = document.getElementById("calevt" + item);
			var coords = Array();
			coords = findPos(elem);
			popwindow = window.open(url,desc,'width=' + wdth + ',height=' + hght + ',scrollbars=yes,resizable=yes');
			popwindow.moveTo(coords[0], coords[1]);
		}
		else {
			popwindow = window.open(url,desc,'width=' + wdth + ',height=' + hght + ',scrollbars=yes,resizable=yes');
			popwindow.moveTo(150, 300);
		}
	}

	function IsEmail(elem) {
		var field = elem.value;
		var regex = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i ;
		var retval = regex.test(field);
		return (retval);
	}

	function validateContactUsForm(theForm) {
		if ((theForm.fromaddress.value == "") || (! IsEmail(theForm.fromaddress))) {
			alert("You must supply a valid email address to proceed");
			theForm.fromaddress.focus();
			return false;
		}
		
		if (theForm.emailmsg.value == "") {
			alert("Please type a smalll message in the box");
			theForm.emailmsg.focus();
			return false;
		}
		
		theForm.submit();
		return true;
	}

	function sendTeamEmail(theForm) {
		var formObj = document.getElementById(theForm);
		if (formObj) {
			var idx = 0;
			var idstr = '';
			for (idx = 0; idx < formObj.elements.length; idx++) {
				if (formObj.elements[idx].type == 'checkbox') {
					if (formObj.elements[idx].id.substr(0, 17) == 'player_select_cbx') {
						if (formObj.elements[idx].checked) {
							if (idstr == '') idstr += formObj.elements[idx].value;
							else idstr += ", " + formObj.elements[idx].value;
						}
					}
				}
			}
			if (idstr == '') {
				alert("No player selected");
				return false;
			}
			else {
				var playerlist = document.getElementById('player_id_selected_list');
				playerlist.value = idstr;
				formObj.action = 'team_email.php'
				formObj.submit();
				return true;
			}
		}
	}
	
	function selectAll(theForm) {
		var formObj = document.getElementById(theForm);
		var selallcbx = document.getElementById('selectall');
		
		if (formObj) {
			var idx = 0;
			var idstr = '';
			var val2apply = false;
			if (selallcbx.checked == true) val2apply = true; 
			for (idx = 0; idx < formObj.elements.length; idx++) {
				if (formObj.elements[idx].type == 'checkbox') {
					if (formObj.elements[idx].id.substr(0, 17) == 'player_select_cbx') {
						formObj.elements[idx].checked = val2apply;
					}
				}
			}
		}		
	}
