/* Functions for the registration script for teh Frosh-Soph Meet */


function nocommas(c) {
	//alert("in");
	
	var name = "runner" + c;
	var r = document.getElementById(name).value;
	
	if(r.indexOf(',') != -1) {
		alert("Please do not use commas in your entries.  Enter FIRST LAST, ex: John Smith.");
		document.getElementById(name).value = "";
	}
}

function nocommascoach() {
	//alert("in");
	
	var r1 = window.document.entryform.coach.value;
	
	if(r1.indexOf(',') != -1) {
		alert("Please do not use commas in entry for the coach.");
		window.document.entryform.coach.value = "";
	}
}

function noCommasSchool() {
	//alert("in");
	
	var r1 = window.document.entryform.school.value;
	
	if(r1.indexOf(',') != -1) {
		alert("Please do not use commas in entry for the school.");
		window.document.entryform.school.value = "";
	}
}

function numRunnersChange() {
	
	/* Create an entry field for each runner */
	var r = parseInt(document.getElementById("runners").value);
	var i = 0;
	var s = "<table border=\"0\" cellpadding=\"5\" cellspacing=\"2\">\n" +
			"<tr>\n  <td><u>#</u></td>\n  <td><i><u>Name</u></i> (First Last)</td>\n" +
			"  <td><i><u>Grade</u></i></td>\n</tr>\n";

	
	for (i = 0; i < r; i++) {
		s = s +	"<tr>\n";
		s = s + "   <td>" + (i+1) + "</td>\n";
		s = s + "   <td><input size=\"50\" name=\"runner" + (i+1) + "\" id=\"runner" + (i+1) +
			"\" type=\"text\" onchange=\"nocommas(" + (i+1) + ")\" /></td>\n";
		s = s + "   <td>\n";
		s = s + "      <select name=\"grade" + (i+1) + "\">\n";
		s = s + "         <option value=\"9\">9</option>\n";
		s = s + "         <option value=\"10\">10</option>\n";
		s = s + "      </select>\n";
		s = s + "   </td>\n";
		s = s + "</tr>\n";

	}
	
	s = s + "</table>\n";
	//alert(s);
	document.getElementById("entranttable").innerHTML = s;
}
