// This holds all of my javascript functions for the site
function clearForms() {
	
	var i;

	for (i = 0; i < document.newsform.length; i++) {

		document.newsform.elements[i].value="";
	}

}

function validate() {
	
	var shouldSubmit;
	var isTitle = false;
	var isName = false;
	var isBody = false;
	var isLink = false;

	shouldSubmit = confirm("Are You sure you want to want to submit this news item?");	
	
	if (shouldSubmit == false) 
		return false;
	else {

		if (document.newsform.title.value == "") {
			alert("You must include a title");
			document.newsform.title.focus();
			return false;
		}

		if (document.newsform.dateM.selectedIndex == "0") {
			alert("You must include a month");
			document.newsform.dateM.focus();
			return false;
		}

		if (document.newsform.dateD.selectedIndex == "0") {
			alert("You must include a day of the month");
			document.newsform.dateD.focus();
			return false;
		}

		if (document.newsform.dateY.selectedIndex == "0") {
			
			alert("You must include a year");
			document.newsform.dateY.focus();
			return false;
		}

		if (document.newsform.body.value == "") {
			alert("Your news item has no text");
			document.newsform.body.focus();
			return false;
		}

		if (document.newsform.link.value == "") {
			shouldSubmit = confirm("Are you sure you don't want to include a link?");
			if (shouldSubmit == false) {
				document.newsform.link.focus();
				return false;
			} else 
				return true;
		}
		
	}
}

/*
function validator () {

	nameIndex = document.forms[0].name.selectedIndex;
	teamIndex = document.forms[0].team.selectedIndex;

	submit = "true";

	if (nameIndex == 0 || teamIndex == 0) {

		alert("Unspecified name or team; Please select...");
	
		if (nameIndex == 0)				// Just to set the focus on the unselected function
			document.forms[0].name.focus();
		else
			document.forms[0].team.focus();
	
		submit = "false";

	}

	if (submit == "false") return false;

}
</script>
*/
