/* Note. Most of logic is array manipulation. Could be simplified using js 1.2 array object methods
  however for now catering to js 1.0 if possible
*/  
function checkName() {

 trimText(document.LMJS_SEL.fullname);

 if (document.LMJS_SEL.fullname.value.length < 2){
     alert("Please enter at least 2 characters (more would be helpful)!");
     document.LMJS_SEL.fullname.focus();
     return false;}

return true;

}

function trimText(field) {
  while(''+field.value.charAt(field.value.length-1)==' ') {
     field.value=field.value.substring(0,field.value.length-1);}
}

function chg_Year(inpOpt){

if (document.LMJS_SEL.sYear == null) {return;}
//var v2006 = new Array("01-25-2004");

var raceOpts = new Array("December 4th Sunday Run", "November 4th Sunday Run",
				"October 4th Sunday Run", "September 4th Sunday Run",
				"Time is on Your Side", "July 4th Sunday Run",
				"June 4th Sunday Run", "May 4th Sunday Run",
				"Tilden Tough Ten", "April 4th Sunday Run", 
				"March 4th Sunday Run", "Couples Relay",
				"January 4th Sunday Run");


// leave this for proposed change to schedule (TOYS in July)				
var raceOpts_chgOrder = new Array("December 4th Sunday Run", "November 4th Sunday Run",
				"October 4th Sunday Run", "September 4th Sunday Run",
				"August 4th Sunday Run", "Time is on Your Side",
				"June 4th Sunday Run", "May 4th Sunday Run",
				"Tilden Tough Ten", "April 4th Sunday Run", 
				"March 4th Sunday Run", "Couples Relay",
				"January 4th Sunday Run");

// no march race
var raceOpts_2010 = new Array("", "December 4th Sunday Run", "November 4th Sunday Run",
				"October 4th Sunday Run", "September 4th Sunday Run",
				"Time is on Your Side", "July 4th Sunday Run", 
				"June 4th Sunday Run", "May 4th Sunday Run",
				"Tilden Tough Ten",
				"April 4th Sunday Run",
				"Couples Relay",
				"January 4th Sunday Run");


var raceVal = new Array();
var raceYear = document.LMJS_SEL.sYear.options[document.LMJS_SEL.sYear.selectedIndex].value;
var j; var i;

raceVal = eval("v"+raceYear);
document.LMJS_SEL.racedate.options.length = 0;

if (raceYear == "1997") {
	j = 0;}
else {
	j = 13 - raceVal.length;}

for (var i=0; i < raceVal.length; i++) {

	if ((raceYear > "2000") && (raceYear < "2008")) {
		document.LMJS_SEL.racedate.options[i] = new Option(raceOpts_chgOrder[j]);}
	else if (raceYear == "2010") {
		document.LMJS_SEL.racedate.options[i] = new Option(raceOpts_2010[j]);}
	else {
		document.LMJS_SEL.racedate.options[i] = new Option(raceOpts[j]);}	

	document.LMJS_SEL.racedate.options[i].value = raceVal[i];
	j++}

document.LMJS_SEL.racedate.options[0].selected = true;

//if ((navigator.appName == "Netscape") & (inpOpt == "new")) {history.go(0);}
//if ((navigator.appName == "Netscape") && (inpOpt == "new")) {history.go(0);}
//if (((navigator.appName == "Safari") || (navigator.appName == "Netscape")) && (inpOpt == "new")) {history.go(0);}

}

function chg_Div(inpOpt){

var div = new Array("overall",
	"-20",
	"20-29",
	"30-39",
	"40-49",
	"50-59",
	"60-69",
	"70+",
	"-40",
	"40-59",
	"60-79",
	"80-99",
	"100-119",
	"130-139",
	"140+",
	"all");

var divOpts = new Array("Overall Best",
	"Age, under 20",
	"Age, 20-29",
	"Age, 30-39",
	"Age, 40-49",
	"Age, 50-59",
	"Age, 60-69",
	"Age, 70 & over",
	"Combined Age, under 40",
	"Combined Age, 40-59",
	"Combined Age, 60-79",
	"Combined Age, 80-99",
	"Combined Age, 100-119",
	"Combined Age, 120-139",
	"Combined Age, 140 & over",
	"-- All Divisions --");

	
var raceSel = document.LMJS_SEL.best_race.options[document.LMJS_SEL.best_race.selectedIndex].value;
var typeSel;

if (raceSel == "all") {
	typeSel = "all";}
else {
	typeSel = raceSel.substring(raceSel.length - 1, raceSel.length);}

if ((typeSel == 'R') || (typeSel == 'T')) {typeSel = 'I';}

var i=0; 
var j=0;
document.LMJS_SEL.best_div.options.length = 0;
var ndiv = 15;

if (typeSel == 'S') {
	document.LMJS_SEL.best_div.options[0] = new Option("No Divisions Apply");
	document.LMJS_SEL.best_div.options[0].value = "overall";
}
else if (typeSel == 'all')  {
	for (var i=0; i <= ndiv; i++) {
		document.LMJS_SEL.best_div.options[i] = new Option(divOpts[i]);
		document.LMJS_SEL.best_div.options[i].value = div[i];}
}
else {
	for (var i=0; i <= ndiv; i++) {
		if ((typeSel == 'I') && (i > 7) && (i < ndiv)) {continue;}
		if ((typeSel == 'C') && (i > 0) && (i < 8)) {continue;}	
			
		document.LMJS_SEL.best_div.options[j] = new Option(divOpts[i]);
		document.LMJS_SEL.best_div.options[j].value = div[i];
		j++;}
}


document.LMJS_SEL.best_div.options[0].selected = true;

//if (((navigator.appName == "Safari") || (navigator.appName == "Netscape")) && (inpOpt == "new")) {history.go(0);}

}
