

/***** This function hides and displays the attendees ****/
function showAttendees() {
	var number = document.register.number[document.register.number.selectedIndex].text;
	for (i=1; i<theAttendees.getElementsByTagName('tr').length; i++) {
		theRow = theAttendees.rows[i];
		if (i <= number) {
			theRow.style.display = "";
			attendeeLinePrice(i);
		} else { 
			theRow.style.display = "none";
		}
	}
	calcTotal();
}

/***** This function enables and disables the "student" column *****/
function showStudent(display) {
	theAttendees.rows[0].getElementsByTagName("th")[4].style.display = display;
	for (i=1; i<theAttendees.getElementsByTagName('tr').length; i++) {
		theAttendees.rows[i].getElementsByTagName("td")[4].style.display = display;
		attendeeLinePrice(i);
	}
	calcTotal();
}

/***** Automatically fill in the first and last name into the attendee info *****/
function fillName(letter, clear) {
	theName = document.forms[0][letter+'name'];
	theName1 = document.forms[0][letter+'name1'];
	if (clear && (theName.value == theName1.value)) {
		theName1.value = "";
	} else if (theName1.value == "") {
		theName1.value = theName.value;
	}
}

/***** Calculate the price for a given attendee  *****/
function attendeeLinePrice(attendeeNum,dototal) {
	price = 0.00;
	if (document.register["lunch"+attendeeNum].checked) {
		price += lunchPrice;
	}
	if (document.getElementById("individualType").checked) {
		if (document.register["student"+attendeeNum].checked) {
			price += stuPrice;
		} else {
			price += indivPrice;
		}
	}
	document.register["price"+attendeeNum].value = price;
	if (dototal) {
		calcTotal();
	}
}


/***** Set family / individual mode  *****/
function doFamily(family) {
	if (family) {
		showStudent('none');
		//document.register["price_fam"].value = famPrice;
	} else {
		showStudent('');
		//document.register["price_fam"].value = 0;
	}
}


/***** Check to see if the string is a number  *****/
function isNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode
	if ((charCode > 31 && (charCode < 48 || charCode > 57)) && charCode != 46) {
		return false;
	}
	return true;
}


/***** Calculate the total price  *****/
function calcTotal() {
	var totPrice = 1 - 1;
	if (document.getElementById("familyType").checked) {
		totPrice += famPrice;
	}
	var number = document.register.number[document.register.number.selectedIndex].text;
	//number = document.register.number.value;
	for (i=1; i<=number; i++) {
		totPrice += document.register["price"+i].value - 0;
	}
	totPrice *= (1 + taxRate);
	totPrice += document.register.donation.value - 0;
  totPrice *= 100;
  totPrice = Math.round(totPrice);
	totPrice /= 100;
	document.register["estimate"].value = totPrice;
}


function confirmReset() {
	response = confirm("Are you sure you wish to clear this form?");
	if (response) {
		return true;
	}
	return false;
}


/***** Display / Hide the Specify Field for How they Heard about the Seminar *****/
function hearAbout(theMenu)
{
  var theTitle = theMenu[theMenu.selectedIndex].title;
  if (theTitle)
  {
    document.getElementById('specifyTitle').innerHTML = theTitle;
    document.getElementById('hearSpecify').style.display = '';
  }
  else
  {
    document.getElementById('hearSpecify').style.display = 'none';
  }
} 
