	var studentID = 1;
	var s1p9=s1p10=s1p11=s1sp=s2p9=s2p10=s2p11=s2sp=s3p9=s3p10=s3p11=s3sp=s1t=s2t=s3t=0;
	var total=5;
	var student = "";
	var studentGradeNo = "12";
	var eflag = 0;
//      document.cookie = 'TotalCost=0.00';

	function updateStudent()
		{
		var studentGrade;
		student = document.FillForm.student.value;
		studentID = 0;
		if (document.RegForm.S3Name.value=="" ||
			document.RegForm.S3Name.value==student) studentID=3;
		if (document.RegForm.S2Name.value=="" ||
			document.RegForm.S2Name.value==student) studentID=2;
		if (document.RegForm.S1Name.value=="" ||
			document.RegForm.S1Name.value==student) studentID=1;
		if (studentID==0) 
			{
			student = "";
			alert ("Warning: Only 3 students can be registered at a time.");
			}
		if (document.FillForm.grade.value)
			studentGradeNo = document.FillForm.grade.value;
		else studentGradeNo = "13";
		switch (studentGradeNo) 
		{
		case "0":       studentGrade = "Kindergarten";
				break;
		case "1":       studentGrade = "1st grade";
				break;
		case "2":       studentGrade = "2nd grade";
				break;
		case "3":       studentGrade = "3rd grade";
				break;
		case "9":       studentGrade = "Teen";
				break;
		case "10":      studentGrade = "Parent";
				break;
		case "12":      studentGrade = "";
				break;
		case "13":      studentGrade = "Enter grade"; // Netscape 4.7
				break;
		default:        studentGrade = studentGradeNo+"th grade";
		}
		switch (studentID) 
		{
		case 1: document.RegForm.S1Grade.value=studentGrade;
				document.RegForm.S1Name.value=student;
				document.RegForm.S1AlName.value=student;
				break;
		case 2: document.RegForm.S2Grade.value=studentGrade;
				document.RegForm.S2Name.value=student;
				document.RegForm.S2AlName.value=student;
				break;
		case 3: document.RegForm.S3Grade.value=studentGrade;
				document.RegForm.S3Name.value=student;
				document.RegForm.S3AlName.value=student;
		}
		}

	function classClick(classTime,className,price,lowGrade,highGrade)
		{
		var studentGrade, myGrade;
		myGrade = studentGradeNo;
		switch (studentGradeNo) 
			{
			case "0":       studentGrade = "in Kindergarten";
					break;
			case "1":       studentGrade = "in the 1st grade";
					break;
			case "2":       studentGrade = "in the 2nd grade";
					break;
			case "3":       studentGrade = "in the 3rd grade";
					break;
			case "9":       studentGrade = "a Teenager";
					break;
			case "10":      studentGrade = "a Parent";
					if (className=="Beginning Spanish" | className=="Continuing French" | 
			    			className=="Introduction to French" | className=="Introduction to Chinese" |
			    			className=="Continuing Spanish" | className=="Beginning French"){
						price = 40;
						myGrade = highGrade;
						}
					if (className=="Advanced Chess" | className=="Beginning Chess" |
			    			className=="Intermediate Chess" ){
						price = 35;
						myGrade = highGrade;
						}
					break;
			case "13":      myGrade = highGrade; // Netscape 4.7
					break;
			default:        studentGrade = "in the "+studentGradeNo+"th grade";
			}
		if (classTime == 0)
			alert ("This class size is already full."); 
		else if (document.FillForm.status.value == "submit")
			alert ("Form cannot be modified after being transmitted."); 
		else if (studentGradeNo==12 | student == "")
			alert ("Please enter student name and grade level."); 
		else
		{
			if (myGrade>highGrade)
				alert (student+" is "+studentGrade+" (typically too old for this class), but we\n"+
					"do make exceptions (send e-mail request to Registration@dgfrog.org).");
			if (myGrade<lowGrade)
				alert (student+" is "+studentGrade+" (typically too young for this class), but we\n"+
					"do make exceptions (send e-mail request to Registration@dgfrog.org).");
			if (myGrade>=lowGrade & myGrade<=highGrade)
				{
				switch (studentID)
					{
					case 1:
						switch (classTime) 
							{
							case 9: s1p9 = price;
									document.RegForm.S1T9.value=className;
									break;
							case 10:        s1p10 = price;
									document.RegForm.S1T10.value=className;
									break;
							case 11:        s1p11 = price;
									document.RegForm.S1T11.value=className;
							}
						s1t=s1p9+s1p10+s1p11+s1sp;
						document.RegForm.S1Cost.value='$'+s1t+'.00';
						break;
					case 2:
						switch (classTime) 
							{
							case 9: s2p9 = price;
									document.RegForm.S2T9.value=className;
									break;
							case 10:        s2p10 = price;
									document.RegForm.S2T10.value=className;
									break;
							case 11:        s2p11 = price;
									document.RegForm.S2T11.value=className;
							}
						s2t=s2p9+s2p10+s2p11+s2sp;
						document.RegForm.S2Cost.value='$'+s2t+'.00';
						break;
					case 3:
						switch (classTime) 
							{
							case 9: s3p9 = price;
									document.RegForm.S3T9.value=className;
									break;
							case 10:        s3p10 = price;
									document.RegForm.S3T10.value=className;
									break;
							case 11:        s3p11 = price;
									document.RegForm.S3T11.value=className;
							}
						s3t=s3p9+s3p10+s3p11+s3sp;
						document.RegForm.S3Cost.value='$'+s3t+'.00';
					}
					s123t = s1t+s2t+s3t;
					document.RegForm.S123Cost.value=s123t;
					setTotalCost();
				}
			}
		}

	function chess(chessFee)
		{
		// var chessFee;
		if (student == "")
			alert ("Please enter student name and grade level.");
		else if (studentGradeNo>8 || studentGradeNo<1)
			alert ("Chess tournament is for 1st through 8th graders.");
		else	{ 
			switch (studentID)
				{
				case 1:
					if (chessFee==0)                                
						document.RegForm.S1TS.value=" ";
					else
						document.RegForm.S1TS.value="Chess Tournament";
					s1sp = chessFee;
					s1t=s1p9+s1p10+s1p11+s1sp;
					document.RegForm.S1Cost.value='$'+s1t+'.00';
					break;
				case 2:
					if (chessFee==0)                                
						document.RegForm.S2TS.value=" ";
					else
						document.RegForm.S2TS.value="Chess Tournament";
					s2sp = chessFee;
					s2t=s2p9+s2p10+s2p11+s2sp;
					document.RegForm.S2Cost.value='$'+s2t+'.00';
					break;
				case 3:
					if (chessFee==0)                                
						document.RegForm.S3TS.value=" ";
					else
						document.RegForm.S3TS.value="Chess Tournament";
					s3sp = chessFee;
					s3t=s3p9+s3p10+s3p11+s3sp;
					document.RegForm.S3Cost.value='$'+s3t+'.00';
					}
				s123t = s1t+s2t+s3t;
				document.RegForm.S123Cost.value=s123t;
				setTotalCost();
				}
		}
	function checkCity()
		{
		switch (document.RegForm.Zipcode.value) 
			{
			case "60439":   document.RegForm.City.value="Lemont";
					break;
			case "60440":   document.RegForm.City.value="Bolingbrook";
					break;
			case "60514":   document.RegForm.City.value="Clarendon Hills";
					break;
			case "60515":   document.RegForm.City.value="Downers Grove";
					break;
			case "60516":   document.RegForm.City.value="Downers Grove";
					break;
			case "60517":   document.RegForm.City.value="Woodridge";
					break;
			case "60523":   document.RegForm.City.value="Oak Brook";
					break;
			case "60532":   document.RegForm.City.value="Lisle";
					break;
			case "60559":   document.RegForm.City.value="Westmont";
					break;
			case "60561":   document.RegForm.City.value="Darien";
					break;
			case "60565":   document.RegForm.City.value="Naperville";
					break;
			}               
		document.RegForm.State.value="IL";
		}

	function checkForm()
		{
		s123Cost=GetCookie("S123Cost");
		if (s123Cost < 10)
			alert ("Registration is incomplete: No classes selected");
		else if (document.RegForm.LastName.value=="" ||
			document.RegForm.FirstName.value=="" ||
			document.RegForm.Street.value=="" ||
			document.RegForm.City.value=="" ||
			document.RegForm.Zipcode.value=="")
			alert ("We need your entire name and address to process your registration.");
		else if (document.RegForm.Emergency.value=="" ||
			document.RegForm.EmerPhone.value=="")
			alert ("We need an emergency contact and phone number.");
		else if (document.RegForm.Email.value=="" && eflag!=1)
			{
  //                    alert ("Reg:cookies="+document.cookie);
			alert ("We cannot confirm your registration without your e-mail address.");
			eflag = 1;
			}
		else
			{
			document.cookie = 'EMail='+document.RegForm.Email.value;

	var cooked;
	var agt = navigator.userAgent.toLowerCase();
	if (agt.indexOf("msie")<0)
	    {
	    var expDate = new Date();
	    expDate.setTime(expDate.getTime()+ 1000*60*60);
//          document.cookie = 'expires='+expDate.toGMTString();
	    document.cookie = 'domain=.addr.com';
	    }

			document.FillForm.reset();
			document.FillForm.status.value = "submit";
//                      alert ("Reg:cookies="+document.cookie);
			document.RegForm.submit();
			}
		}
//      Function setTotalCost updates the member fee and total registration cost 
//    in registration form and cookie.

	function setTotalCost()
		{
//      Set the member fee to $10 unless only chess tournament is selected.

		if (s123t > s1sp+s2sp+s3sp) 
			memfee = 5;
		else
			memfee = 0;
		total = s123t+memfee;
		document.cookie = 'AnnualFee='+memfee;
		document.cookie = 'S123Cost='+s123t;
//              document.cookie = 'TotalCost='+total+'.00';
//              document.RegForm.totalCost.value='$'+total+'.00';
//              document.RegForm.annualFee.value='$'+memfee+'.00';
//              if (memfee==0) document.RegForm.annualFee.value='$0.00 (FRoG Board)';
		}

// GetCookie - Returns the value of the specified cookie or null
//             if the cookie doesn't exist
//
 
function GetCookie(name) {
   var result = null;
   var myCookie = " " + document.cookie + ";";
   var searchName = " " + name + "=";
   var startOfCookie = myCookie.indexOf(searchName)
   var endOfCookie;
   if (startOfCookie != -1) {
      startOfCookie += searchName.length; // skip past cookie name
      endOfCookie = myCookie.indexOf(";",startOfCookie);
      result =
	 unescape(myCookie.substring(startOfCookie,endOfCookie));
   }
   return result;
   }
