<!--
// Initialize arrays and variables
var iTop=0
var _c1 =["","","","",""]
var _c2 =["","","","",""]
var arteachers=["","","","","",""]
var sClassListText="<select id='lstClass' name='lstClassName'>"
var ASPFeeAmount=0;
var RegistrationFee=0;

// K-2 classes by day
_c1[0]="<option value='Computers'>Computers</option><option value='Sports'>Sports</option><option value='Sand art'>Send art</option><option value='Homework help'>Homework help</option>";
_c1[1]="<option value='Computers'>Computers</option><option value='Origami and more'>Origami and more</option><option value='Exercise to Music'>Exercise to Music</option><option value='Homework help'>Homework help</option>";
_c1[2]="<option value='Spanish Speaking/Eating'>Spanish Speaking/Eating</option><option value='Wii Sports'>Wii Sports</option><option value='Chess'>Chess</option><option value='Homework help'>Homework help</option>";
_c1[3]="<option value='Computers'>Computers</option><option value='Clay'>Clay</option><option value='Sports'>Sports</option><option value='Homework help'>Homework help</option>";
_c1[4]="<option value='Lego mania'>Lego mania</option><option value='Weekend Homework Relief'>Weekend Homework Relief</option><option value='Artistic desserts'>Artistic desserts</option><option value='Sports'>Sports</option>";

// 3-5 classes by day
_c2[0]="<option value='Computers'>Computers</option><option value='Sports'>Sports</option><option value='Chess'>Chess</option><option value='Homework help'>Homework help</option>";
_c2[1]="<option value='Computers'>Computers</option><option value='Wii Sports'>Wii Sports</option><option value='Art with Ms. Haar'>Art with Ms. Haar</option><option value='Homework help'>Homework help</option>";
_c2[2]="<option value='Sculpting with clay'>Sculpting with clay</option><option value='Test prep'>Test prep</option><option value='Sports'>Sports</option><option value='Homework help'>Homework help</option>";
_c2[3]="<option value='Computers'>Computers</option><option value='Yoga'>Yoga</option><option value='Spanish Speaking/Eating'>Spanish Speaking/Eating</option><option value='Homework help'>Homework help</option>";
_c2[4]="<option value='Wii Sports'>Wii Sports</option><option value='Artistic Desserts'>Artistic Desserts</option><option value='Food and nutrition'>Food and nutrition</option><option value='Weekend Homework Relief'>Weekend Homework Relief</option>";

// Fee array by # of days and pickup time
var _fee =[[360,720,1020,1360,1600],[400,800,1140,1520,1800], [440,880,1280,1680,2000]];
var _morningfee = [100,200,300,360,410];

// HTML string of K-5 teachers
s=""
s+="<option value='Gaudio' selected>Gaudio</option><option value='Margulis'>Margulis</option>";
s+="<option value='Mintz'>Mintz</option><option value='Roberson'>Roberson</option>";
s+="<option value='Romano'>Romano</option>";
arteachers[0]=s;

s="";
s+="<option value='Mazzola'>Mazzola</option><option value='Shababb' selected>Shababb</option>";
s+="<option value='Vaughn'>Vaughn</option>";
s+="<option value='Golub'Golub</option>";
arteachers[1]=s;

s="";
s+="<option value='Limeri' selected>Limeri</option>";
s+="<option 'Healey'>Healey</option><option value='Limeri'>Limeri</option>";
s+="<option 'Margrill' selected>Margrill</option>";
s+="<option 'Steinberg'>Steinberg</option>";
arteachers[2]=s;

s="";
s+="<option 'Axelrod'>Axelrod</option>";
s+="<option 'Lathrop' selected>Lathrop</option>";
s+="<option 'Perez'>Perez</option>";
s+="<option 'Feller'>Feller</option>";
arteachers[3]=s;

s="";
s+="<option 'Helman'>Helman</option>";
s+="<option 'Kaufman'>Kaufman</option>";
s+="<option 'Schembri'>Schembri</option>";
s+="<option 'Ginzberg'>Ginzberg</option>";
arteachers[4]=s;

s=""
s+="<option 'King'>King</option><option 'La Rocca'>La Rocca</option><option 'Levin'>Levin</option>";
s+="<option 'Herman'>Herman</option>";
s+="<option 'Tiger' selected>Tiger</option>";
arteachers[5]=s;

function BodyOnload()
{

// Set the Kindergarten teacher list when form is loaded
o=document.getElementById("divTeacher");
if (o) o.innerHTML="<select id='lstteacher' name='lstteacher'>"+arteachers[0]+"</selected>";
}

function ChangeTeacher()
{
// User changed the grade in the list, reset teacher list, then
// get the classes for that grade
var grade=document.frmASP.lstgrade.selectedIndex;
var s="<select id='lstteacher' name='lstteacher'>";
s+=arteachers[grade];
s+="</selected>";
document.getElementById("divTeacher").innerHTML=s;
GetClasses();
}


function CourseReg(objchk)
{
	// User changed the number of days to register for, 
	// display/hide the day and class divs to correspond to the selected days

	var row="" // this will contain a reference to the Row divs 
	// First, set the hidden fields with the # of days selected & the pickup time
	// when the form is submitted, we'll have this info to email.
	var days = objchk.id.substring(3,4)
	var hours = objchk.id.substring(4,5)
	document.frmASP.txtday.value=days
	document.frmASP.txthour.value=hours
	var objDiv=document.getElementById("divCourseTitle")
	// Get the prior Div so we can get the position on the page
	iTop=objDiv.offsetTop+objDiv.offsetHeight
	var height=iTop
	
	if (objchk.checked)
	{
		objDiv.style.display="block";  // Display divCourseTitle
		UncheckBoxes(objchk.id)
	
		for  ( i=1; i<=5; i+=1)
			{
			// Loop through all the day row divs and show or hide them and position them
			row="Row"+i.toString()
			objDiv=document.getElementById(row)
			if (i<=days)
				{
				// Display the row
				objDiv.style.display="block";
				objDiv.style.height=40
				height=height+40
				if (i==days)
					{
						// if this is the last visible day, display the bottom border
						objDiv.style.borderBottomStyle="solid"
					}
				else
					{
						// hide the bottom border for the other row divs
						objDiv.style.borderBottomStyle="none"
					}
				}
			else
				{
				// hide the row
				objDiv.style.display="none"
				objDiv.style.borderbottomstyle="none"
				objDiv.style.height=0
				}
			}
		iTop=height+10;
		ResetDivTop("divFees,divCC,divMedical");
		GetClasses();
		//alert(document.all.divCourses.style.height)
    	GetFees(days,hours);
	}
	else
	{
	    //ASPFeeAmount=0;
	    RegistrationFee=50;
	    
		HideDivs("divCourseTitle,Row1,Row2,Row3,Row4,Row5");
		if(document.getElementById("ddlMorning").selectedIndex==0)
		    HideDivs("divFees,divCC,divMedical");
		GetFees();
	}

	
}

function UncheckBoxes(id)
{
// This checks to see which checkbox was checked, and it
// unchecks all the other boxes, since only one can be checked
// at a time, operates like an option button, but the interface
// designed called for checkboxes
var obj
var objID=""
for (i=1;i<=5;i+=1)
	{
	objID="chk" + i.toString() + "5"
	if (objID!=id)
		{
			obj=document.getElementById(objID)
			obj.checked=false
		}
		
	objID="chk" + i.toString() + "6"
	if (objID!=id)
		{
			obj=document.getElementById(objID)
			obj.checked=false
		}

	objID="chk" + i.toString() + "7"
	if (objID!=id)
		{
			obj=document.getElementById(objID)
			obj.checked=false
		}
				
	}


}	

function GetClasses()
{
// Display the classes available for the selected grade
	var lstText=""
	var row=""
	var divclass=""
	var grade=document.frmASP.lstgrade.selectedIndex
	for  (i=1; i<=5; i+=1)
		{
			row = "Row" + i.toString()
			divclass="divclass" + i.toString()
			// Get the row div and see if it's visible
			if (document.getElementById(row).style.display=="block")	 
				{
				//if (document.getElementById(divclass).innerHTML.length==0)
				
				//{
					daycontrol="lstday" + i.toString()
					// Get which day 1-5 for Monday-Friday
					BuildClassListHTML(document.frmASP.lstgrade.selectedIndex, document.getElementById(daycontrol).selectedIndex, i)
				//}
				}
			else
			{
			document.getElementById(divclass).innerHTML=""
			}
		}
}

function ChangeClassList(objDay)
{
	// Called from the lstDay dropdown to set the available
	// classes by day and grade
	BuildClassListHTML(document.frmASP.lstgrade.selectedIndex, objDay.selectedIndex, objDay.id.substring(6,7));
	//Amount=Math.floor(document.frmASP.txtAmount.value);
	//if (document.getElementById("Discount").value.length>0) Amount=(Amount-(Amount * .1));
	
	
	//Amount = ASPFeeAmount;
	//Amount+=RegistrationFee; // registration fee
	//if (document.frmASP.chkWFF.checked && !RegisteredFriday()) Amount+=12;
	//alert(Amount);
	//document.frmASP.txtASPTotalAmount.value=Amount.toString() + ".00";
}


function BuildClassListHTML(Grade, iDay, iRow)
{
	//Build an HTML string to create a dropdown list box, 

	divclass="divclass" + iRow // Which row are we working with, 1-5?
	
	//	This replace sets the ID of the
	// dropdown to be lstClass# and the name is lstClassName#
	lstText=sClassListText.replace("lstClass", "lstClass"+iRow)
	lstText=lstText.replace("lstClassName", "lstClassName"+iRow)

	if (Grade<=2)
		{
		lstText=lstText + _c1[iDay]
		}
	else
		{
		lstText=lstText + _c2[iDay]
		}
	document.getElementById(divclass).innerHTML=lstText + "</select>"

}


function GetFees(numDays, numHours)
{
// For asp program, deteermine the fee by the number of hours & days
// and then look in the array for the amount

numHours=numHours-5;
numDays=numDays-1;
var Amount=0;
document.getElementById("txtASPRegistrationFee").value="";
ASPFeeAmount=0;
if(!isNaN(numHours) && !isNaN(numDays)) 
{
    // only used for ASP, not for mornings so Amount=0 if only mornings selected
    ASPFeeAmount=Math.floor(_fee[numHours][numDays]);
    if (document.getElementById("Discount").value.length>0) ASPFeeAmount=Math.round(ASPFeeAmount-(ASPFeeAmount * .1));
    RegistrationFee=50;    
}
if (ASPFeeAmount>0) 
    document.getElementById("txtASPRegistrationFee").value="50.00";
Amount = ASPFeeAmount + Math.floor(document.getElementById("MorningFee").value);

document.getElementById("txtAmount").value=Amount.toString() + ".00";
Amount += RegistrationFee;

if (document.getElementById("chkWFF").checked && !RegisteredFriday()) Amount+=12;
document.getElementById("txtASPTotalAmount").value=Amount.toString() + ".00";
}

function RegisteredFriday()
{
bHasFriday=false;
lstObj=document.getElementsByTagName("SELECT");
for(i=0;i<lstObj.length;i++)
{
	if (lstObj[i].value=="Friday") bHasFriday=true;
}
return bHasFriday;
}

function ChangeForm(chkASPType)
{
// runs when user clicks the top checkbox from asp coursereg to dance
// show and hide the divs
var divclass=""
var row=""
var ctl=""
var ctlDiv=""

	if (chkASPType.checked)
		{
			// Dance only
			ctlDiv = document.getElementById("tblPersonalInfo");
			iTop=ctlDiv.offsetTop+ctlDiv.offsetHeight+7;
			
			ResetDivTop("divDance,divCC,divMedical");
			HideDivs("divCourseTitle,divASP,Row1,Row2,Row3,Row4,Row5,divFees");
			
			document.getElementById("ddlMorning").selectedIndex=0;
		}
	else
		{
			// Regular ASP, show any DOW row div that might have been selected
			ctlDiv = document.getElementById("divCourseTitle")
			iTop=ctlDiv.offsetTop+ctlDiv.offsetHeight

			HideDivs("divDance")		
			document.getElementById("divASP").style.display="block";
			height=0
			for  ( i=1; i<=5; i+=1)
				{
				divclass="divclass" + i.toString()
				ctl=document.getElementById(divclass)
				if (ctl.innerHTML.length>0)
					{
					row="Row" + i.toString()
					//document.getElementById(row).style.top=iTop+height
					document.getElementById(row).style.display="block";
					height+=40
					}
				}
			if (height>0)
				{
				// DOW Rows were selected, so now reset and display the remaining divs
				iTop=iTop + height+7
				ctlDiv.style.display="block";
				ResetDivTop("divFees,divCC,divMedical")

//				DisplayDivs(height+divCourseTitle.offsetTop+divCourseTitle.offsetHeight)
				}
			else
				{
				// No DOW rows had been selected, hide the other divs
				HideDivs("divCC,divMedical")
				}
		}
}

function ResetDivTop(DivList)
{
// Takes an input , separated list of divs, splits the list and shows and sets the top of the div

var ctlDiv=""
var _list=DivList.split(",")
for(var i=0;i<=_list.length-1;i++)
	{
	ctlDiv = document.getElementById(_list[i])
	ctlDiv.style.display="block"
	ctlDiv.style.top=iTop	
	iTop=ctlDiv.offsetTop+ctlDiv.offsetHeight+7
	}
}

function HideDivs(DivList)
{
// Takes an input , separated list of divs, splits the list and hides the divs
var _list=DivList.split(",")
 for(var i=0;i<=_list.length-1;i++)
	document.getElementById(_list[i]).style.display="none";
}

if(window.attachEvent)window.attachEvent("onload",resetStyles);

function resetStyles(){
    unGoogle('INPUT');
    unGoogle('SELECT');

} 

function unGoogle(eleType){
    var t=document.getElementsByTagName(eleType);
    for(var i=0;i<t.length;i++){
        t[i].attachEvent('onpropertychange',resetCSS);
        t[i].style.backgroundColor='';
    }
} 

function resetCSS(){
    var s=event.srcElement.style;
    if(s.backgroundColor!='')s.backgroundColor='';
} 

function CheckWFF()
{
// User is registering for ASP and checking to also register for the dance
var Amount=Math.floor(document.getElementById("txtASPTotalAmount").value)
if (!RegisteredFriday())
{
	if (document.getElementById("chkWFF").checked)
		{Amount+=12}
	else
		{Amount-=12}
	document.getElementById("txtASPTotalAmount").value=Amount.toString()+".00"
}
}


function check_form(form) {
// Validation for form, make sure all fields have been filled in
// this does not validate for properly formatted email addresses yet
var bOK=true
var sMessage=""
var SelectedMornings=0;
WFMDay();

		if (form.txtchildname.value.length==0)
		{
			sMessage+= "\tChild's Name\n"
			bOK=false
		}
		

	if (form.txtpgfirstname.value.length==0)
		{
			sMessage+= "\tParent/Guardian First Name\n"
			bOK=false
		}

	if (form.txtpglastname.value.length==0)
		{
			sMessage+= "\tParent/Guardian Last Name\n"
			bOK=false
		}


	if (form.txtpaname.value.length==0)
		{
			sMessage+= "\tParent Authorized to Pick Up\n"
			bOK=false
		}
	if (form.txtaddress.value.length==0)
		{
			sMessage+= "\tAddress\n"
			bOK=false
		}
	if (form.txtcity.value.length==0)
		{
			sMessage+= "\tCity\n"
			bOK=false
		}	
	if (form.txtzip.value.length==0)
		{
			sMessage+= "\tZip Code\n"
			bOK=false
		}

	if (form.txthomephone.value.length==0)
		{
			sMessage+= "\tHome Phone\n"
			bOK=false
		}
	if (form.txtecname.value.length==0)
		{
			sMessage+= "\tEmergency Contact Name\n"
			bOK=false
		}	
	if (form.txtecphone.value.length==0)
		{
			sMessage+= "\tEmergency Contact Phone\n"
			bOK=false
		}

	if (form.txtcc.value.length==0)
		{
			sMessage+= "\tCredit Card Number\n"
			bOK=false
		}
	if (!form.chkASPType.checked)
		{
		// Make sure that the user selected one of each day, in other words
		// check that the user did not select Tuesday twice, by building
		// a string of selections, then verifying the selection is not in the list
		var s=""
		var ListVal=""
		for(var i=1;i<=5;i++)
			{
			if (document.getElementById("Row" + i.toString()).style.display=="block")
				{
					ListVal=document.getElementById("lstday" + i.toString()).value
					if (s.search(ListVal)<0)
						{
						s += ListVal
						}
					else
						{
						if (s.length>0 && sMessage.search(ListVal)<0)	{sMessage+="\t"+ListVal + " has been selected more than once\n"}
						}
				}	// element=visible
			} // for var i=1
		} //!chkASPType.checked
    if (bOK)
        {
        if(document.getElementById("ddlMorning").selectedIndex > 0)
        {
            for(i=1;i<=document.getElementById("ddlMorning").selectedIndex;i++)
                if(document.getElementById("chk" + i + "day").checked) SelectedMornings++
            if(SelectedMornings<document.getElementById("ddlMorning").selectedIndex-1)
                {
                    bOK=false;
                    alert("Please select the corresponding number of mornings for Be Cool Before School");
                    return false;
                }
        }
    }
	if (!form.chkSameAsMailing.checked)
		{
			// If user's billing is not the same as mailing, make sure billing is filled in
			if (form.txtbillfirstname.value.length==0)
			{
				sMessage+= "\tBilling First Name\n"
				bOK=false
			}
			if (form.txtbilllastname.value.length==0)
			{
				sMessage+= "\tBilling Last Name\n"
				bOK=false
			}

			if (form.txtbilladdress.value.length==0)
			{
				sMessage+= "\tBilling Address\n"
				bOK=false
			}

			if (form.txtbilladdress.value.length==0)
			{
				sMessage+= "\tBilling Address\n"
				bOK=false
			}

			if (form.txtbillcity.value.length==0)
			{
				sMessage+= "\tBilling City\n"
				bOK=false
			}
			if (form.txtbillzip.value.length==0)
			{
				sMessage+= "\tBilling Zip Code\n"
				bOK=false
			}
			
		}//(!form.chkSameAsMailing.checked)

		
	if (form.txtdoctor.value.length==0)
		{
			sMessage+= "\tDoctor Name\n"
			bOK=false
		}

	if (form.txtdoctorphone.value.length==0)
		{
			sMessage+= "\tDoctor's Phone\n"
			bOK=false
		}
	if (!form.chkagree.checked)
		{
			sMessage+= "\tAgreement Checkbox\n"
			bOK=false
		}
		
	if (!bOK)
		{
			sMessage="The following fields must be filled in:\n\n  "  + sMessage
			alert(sMessage)
		}
return bOK
}

function ClearASP()
{
// Clears day selections for ASP

// hide course info
HideDivs("divCourseTitle,Row1,Row2,Row3,Row4,Row5");
if (document.getElementById("ddlMorning").selectedIndex==0)HideDivs("divFees,divCC,divMedical");
ASPFeeAmount=0;
RegistrationFee=0;

// clear ASP check boxes
for (i=1;i<6;i++)
    for(j=5;j<8;j++)
        document.getElementById("chk" + i + j).checked=false;
GetFees();

}

function WFMReg()
{
var Display="none";
var o = document.getElementById("ddlMorning");
if (o.selectedIndex>0)Display="block";
document.getElementById("rowMorning").style.display=Display;
document.getElementById("rowMorningFee").style.display=Display;
if(Display=="none")
    {
    for (i=1;i<6;i++)
            document.getElementById("chk" + i + "day").checked=false;
    document.getElementById("MorningFee").value="0";
    document.getElementById("MorningDays").value="";
    document.getElementById("colMorningFee").style.innerText="";
    if(ASPFeeAmount==0) HideDivs("divFees,divMedical,divCC");
    }
else
    {
    if(o.selectedIndex==o.length-1)
        {
        document.getElementById("MorningDays").value="Monday, Tuesday, Wednesday, Thursday, Friday";
        for (i=1;i<6;i++)
            document.getElementById("chk" + i + "day").checked=true;            
        }
     else
     {
        for (i=1;i<6;i++)
            document.getElementById("chk" + i + "day").checked=false;     
     }
    document.getElementById("MorningDays").value="";
     document.getElementById("MorningFee").value = _morningfee[o.selectedIndex-1];
     document.getElementById("colMorningFee").innerHTML="$" + _morningfee[o.selectedIndex-1] + " total sesssion";
     ResetDivTop("divFees,divMedical,divCC");
     
     GetFees();
    }
}

function WFMDay()
{
var DayText=""
   if(document.getElementById("chk1day").checked) DayText += "Monday, ";
   if(document.getElementById("chk2day").checked) DayText += "Tuesday, ";
   if(document.getElementById("chk3day").checked) DayText += "Wednesday, ";
   if(document.getElementById("chk4day").checked) DayText += "Thursday, ";
   if(document.getElementById("chk5day").checked) DayText += "Friday, ";
   if(DayText.length>0)
        DayText=DayText.substr(0, DayText.length-2);
       
   document.getElementById("MorningDays").value=DayText;
}
-->