// schoolselects.js

//  processes schoolziptbl.js.

//  takes value from SCF text box and places appropriate array

//  in select box. 

//

//  08/4/00 - vgw

//


var sname;
var snum;
var loadFlag = 0;
var urlFlag = 0; // flag checks to see if page is loaded from a referring url or not
var urlSchool = '';



function reloadSchools()

{
        if (urlFlag != 1) 
        {

           if (document.theform.SCF.value != "" 

	   && document.theform.SCF.value.substring(0, 1) != " ")

	   {

		loadFlag = 1;

		selectSchools(); 

		document.theform.School.selectedIndex = 0;

	   }
        } // end urlFlag if
}



function selectSchools()

{
  if (document.forms[0].SCF.value == "" || document.forms[0].SCF.value.substring(0, 1) == " ")

  {

 	if (! loadFlag)

 	{

		alert("Please enter the first 3 digits of your school's zip code.");

  		document.forms[0].SCF.focus();

  	}

  }

  else

  {

	 var scfName;

	 var scfNum;

	 var cntary=0;

	 var checkscf="";

	 var foundone=0;

	 var verifyVal = "000";

	 var listLength = 0;

	 var form = document.forms[0];

	 var checkList = document.forms[0].SCF;

	 var buildList = form.School;

	 var checkValue = checkList.selectedIndex;



	//set up the right list based on option selected

	

	for (var s=0;s <= bldarycnt;s++)  // cycle through multiple scf arrays

	{

		checkscf= eval("verifySCF"+ s);

		for (var v=0;v < checkscf.length;v++)  // cycle through single scf array

		{

			if (checkscf[v] == checkList.value)

			{    break; } // break out of for v

		} // end for v

		if (v < checkscf.length)

		{
			eval("s"+ checkList.value+"();");
			scfName = sname;
			scfNum = snum;

			verifyVal = checkList.value;

			foundone=1;

			break;   // break out of for s

		}

	} // end for s

	if (! foundone)

	{		// scf not found
		eval("s000();");
		scfName = sname;
		scfNum = snum;

	}

		

	newlistLength = scfName.length+1; //allows for first text entry 'Select Your School'

	

	buildList.options.length = newlistLength;



	//add new options

	

	buildList.options[0].text = "  Select Your School  ";

	buildList.options[0].value = "10007";

	buildList.selectedIndex = 0;

//	buildList.options.length++;

	for (var i = 1; i < newlistLength; i++)

	{

		buildList.options[i].text = scfName[i-1];

		buildList.options[i].value = scfNum[i-1];

	}

	if (verifyVal != "000")

	{

		buildList.options.length++;

		buildList.options[i].text = "Other";

		buildList.options[i].value = "10007";

	}

	

	//alert("setting selectedIndex = " + form.School.SelectedIndex);

	//buildList.SelectedIndex = 0;

	//alert("set selectedIndex = " + form.School.SelectedIndex);

	

  }//end else	
if (urlFlag == 1)
{
    for (var j=1; j < newlistLength; j++)
    {
       if (buildList.options[j].value == urlSchool)
       {
          document.theform.School.selectedIndex = j;
          document.theform.School.options[j].selected=true;
          break;
       }
       else
       {
          document.theform.School.options[0].selected=true;
       }
    }
//urlFlag = 0;
}
}



 var visibleVar="null";

 function initDiv()

 {

 

 if (navigator.appName != "Netscape") {

 	layerStyleRef="layer.";

 	layerRef="document.layers";

 	styleSwitch="";

 	visibleVar="show";

  	//visibleVar="hide";

}else{

 	layerStyleRef="layer.style.";

 	layerRef="document.all";

 	styleSwitch=".style";

 	visibleVar="visible";

 	//visibleVar="hidden";

 	}

 }

 function SchoolToggleLayer(schoolList,layerName,inputBox)
 {

  var optIndex = schoolList.selectedIndex;

  if (navigator.appName != "Netscape") 

  {

	if (schoolList.options[optIndex].text.substring(0,5) == "Other")

 	{ showLayer(layerName,inputBox); }

	else

	{ hideLayer(layerName,inputBox); }

  }

  else if (schoolList.options[optIndex].text.substring(0,5) == "Other")

  { inputBox.focus(); }

 }
 function ToggleLayer(schoolList,layerName,inputBox)

 {

  var optIndex = schoolList.selectedIndex;

  if (navigator.appName != "Netscape") 

  {

	if (schoolList.options[optIndex].text.substring(0,5) == "Other")

 	{ showLayer(layerName,inputBox); }

	else

	{ hideLayer(layerName,inputBox); }

  }

  else if (schoolList.options[optIndex].text.substring(0,5) == "Other")

  { inputBox.focus(); }

 }

 function showLayer(layerName,inputBox){

 	eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');

 	inputBox.focus();

 }

 function hideLayer(layerName,inputBox){

 	eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');

	inputBox.value="";

 }

