/*schlfinder_validation.js*/

function  _CF_checkschl(_CF_this)
{

  if (_CF_hasValue(_CF_this.schoolToggle, "RADIO" ))
   { 
  	for (i=0; i < _CF_this.schoolToggle.length; i++)
    	{
		if (_CF_this.schoolToggle[i].checked)
			{
				/*if homeschooler*/
				if (_CF_this.schoolToggle[i].value == "homeSchool")
				{
				  if  (!_CF_hasValue(_CF_this.homeSchoolAddress, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.homeSchoolAddress, _CF_this.homeSchoolAddress.value, "Please enter your home address.    "))
				          {
				          return false; 
				          }
				      }
					  
				   if  (!_CF_hasValue(_CF_this.homeSchoolCity, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.homeSchoolCity, _CF_this.homeSchoolCity.value, "Please enter the city of your home address.    "))
				          {
				          return false; 
				          }
				      }
					  
				    if  (!_CF_hasValue(_CF_this.homeSchoolState, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.homeSchoolState, _CF_this.homeSchoolState.value, "Please select the state of your home address.    "))
				          {
				          return false; 
				          }
				      }
					 
					 if  (!_CF_hasValue(_CF_this.homeSchoolZip, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.homeSchoolZip, _CF_this.homeSchoolZip.value, "Please enter your zip code.    "))
				          {
				          return false; 
				          }
				      }
				 }
				 
				/* for Non-PID school*/
				if (_CF_this.schoolToggle[i].value == "notListed")
				{
				  if  (!_CF_hasValue(_CF_this.schoolName, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.schoolName, _CF_this.schoolName.value, "Please enter your school name.    "))
				          {
				          return false; 
				          }
				      }
					  
				  if  (!_CF_hasValue(_CF_this.schoolAddress, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.schoolAddress, _CF_this.schoolAddress.value, "Please enter your school address.    "))
				          {
				          return false; 
				          }
				      }
					  
				   if  (!_CF_hasValue(_CF_this.schoolCity, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.schoolCity, _CF_this.schoolCity.value, "Please enter the city name.    "))
				          {
				          return false; 
				          }
				      }
					  
				   if  (!_CF_hasValue(_CF_this.schoolState, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.schoolState, _CF_this.schoolState.value, "Please select a state.    "))
				          {
				          return false; 
				          }
				      }
					  
					if  (!_CF_hasValue(_CF_this.schoolState, "SELECT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.schoolState, _CF_this.schoolState.value, "Please select a state.    "))
				          {
				          return false; 
				          }
				      }
					  
					if  (!_CF_hasValue(_CF_this.schoolZip, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.schoolZip, _CF_this.schoolZip.value, "Please enter the zip code.    "))
				          {
				          return false; 
				          }
				      }
					  
					if  (!_CF_hasValue(_CF_this.schoolPhone, "TEXT" )) 
				     {
				      if  (!_CF_onError(_CF_this, _CF_this.schoolPhone, _CF_this.schoolPhone.value, "Please enter your school phone number.    "))
				          {
				          return false; 
				          }
				      }
				 }
			 }
		 }
	  }

 else if (!_CF_hasValue(_CF_this.schoolToggle, "RADIO" )) 
	{
	 if  (!_CF_hasValue(_CF_this.zip, "TEXT" ))
		{
			if  (!_CF_onError(_CF_this, _CF_this.zip, _CF_this.zip.value, "Please enter the 5-digit zip code of your school or district.    "))
			{
				return false;
			}
		}
		
	  if  (!_CF_hasValue(_CF_this.school, "SELECT" ))
		{
			if  (!_CF_onError(_CF_this, _CF_this.school, _CF_this.school.value, "Please select your school or district from the list.    "))
			{
				return false;
			}
		}
		

	  if  (_CF_hasValue(_CF_this.school, "SELECT" ) && (_CF_this.school.value.indexOf('No Record') != -1)  )
		 {
			if  (!_CF_onError(_CF_this, _CF_this.school, _CF_this.school.value, "Invalid school or district!\nPlease enter a valid zip code and select your school or district from the list.    "))
			{
				return false;
			}
		} 
		
	 if  (_CF_hasValue(_CF_this.school, "SELECT" ) && (_CF_this.school.value.indexOf('Loading...') != -1)  )
		 {
			if  (!_CF_onError(_CF_this, _CF_this.school, _CF_this.school.value, "Invalid school or district!\nPlease enter a valid zip code and select your school or district from the list.    "))
			{
				return false;
			}
		} 

	  if  (_CF_hasValue(_CF_this.school, "SELECT" ) && (_CF_this.school.value.indexOf('--school') != -1)  )
		 {
			if  (!_CF_onError(_CF_this, _CF_this.school, _CF_this.school.value, "Please select your school or district from the list.    "))
			{
				return false;
			}
		} 
		
	}
	return true;
}

