// Javascript source code for school in PDSurvey.

var aSchoolId = new Array();
var aSchool = new Array();
var aSchoolDistrict = new Array();
var bSurvey = false;

function onSelectDistrict()
{
	var frmName = document.frmSchool;
	var nSchool = aSchool.length;
	var sDistrict = frmName.sDistrict.options[frmName.sDistrict.selectedIndex].value;
	var oOption = frmName.nSchoolId.options;	
	var count = 2;
	oOption.length = 2;	

	if(sDistrict != "")
	{		
		for(i = 0; i < nSchool; i++)
		{
			if((aSchoolDistrict[i] == sDistrict))
			{
				oOption.length++;
				oOption[count].value = aSchoolId[i];
				oOption[count].text = aSchool[i];
				count++;
			}
		}
	}
	
	if(!bSurvey)
		onSelectSchool();
}

function onSelectSchool()
{	
	var frmName = document.frmSchool;
	frmName.sSchoolName.value = frmName.nSchoolId.options[frmName.nSchoolId.selectedIndex].text;
}

function onReport()
{
	var bRet = true;
	if(document.frmSchool.sSurveyYear1.value >= document.frmSchool.sSurveyYear2.value)
	{
		alert("Comparison Year should be earlier than Report Results for Selected Year.");
		bRet = false;
	}	
	else
	{
		document.frmSchool.btnReport.disabled = true;
		document.frmSchool.btnReport.value = "Generating report...";
	}
	
	return bRet;
}
