
var NameRegExp = /^[A-Za-z|'|-]+$/;

function MovePhoneFaxFocus(type,part,len)
{
	if (part == 'areacode')
	{
		if (len == 3){document.getElementById(type+'prefix').focus();}
	}

	if (part == 'prefix')
	{
		if (len == 3){document.getElementById(type+'linenumber').focus();}
	}

}

function ValidateRegHome(inForm)
{
	if (inForm.zip.value == '' && inForm.schoolname.value == '')
	{
		alert('School Name or Zip Code are required')
		if (inForm.zip.value == '')
		{HighlightBox('zip_span');}
		else{DeHighlightBox('zip_span')}
		if (inForm.schoolname.value == '')
		{HighlightBox('schoolname_span');}
		else{DeHighlightBox('schoolname_span')}
		return false;
	}
	if (inForm.zip.value != '' && inForm.zip.value.length < 5)
	{alert('Zip Code needs to be a minimum of 5 numbers'); return false;};
	return true;
}

function ValidateSchoolSearch(inForm)
{
	if (inForm.zip.value == '' && inForm.schoolname.value == '')
	{
		alert('School Name or Zip Code are required')
		if (inForm.zip.value == '')
		{HighlightBox('zip_span');}
		else{DeHighlightBox('zip_span')}
		if (inForm.schoolname.value == '')
		{HighlightBox('schoolname_span');}
		else{DeHighlightBox('schoolname_span')}
		return false;
	}
	if (isNaN(inForm.zip.value))
	{
		alert('Zip Code must be numeric');
		HighlightBox('zip_span');
		return false;
	}
	else{DeHighlightBox('zip_span')}
	
	if (inForm.zip.value != '' && inForm.zip.value.length < 5)
	{alert('Zip Code needs to be a minimum of 5 numbers'); return false;};
	return true;
}

function ValidateCoachSearch(inForm)
{
	if (inForm.firstname.value == '' || inForm.lastname.value == '')
	{
		alert('First Name AND Last Name are required')
		if (inForm.firstname.value == '')
		{HighlightBox('firstname_span');}
		else{DeHighlightBox('firstname_span')}
		if (inForm.lastname.value == '')
		{HighlightBox('lastname_span');}
		else{DeHighlightBox('lastname_span')}
		return false;
	}
	return true;
}

function ValidateStudentSearch(inForm)
{
	if (inForm.studentfirstname.value == '' || inForm.studentlastname.value == '')
	{
		alert('First Name AND Last Name are required')
		if (inForm.studentfirstname.value == '')
		{HighlightBox('studentfirstname_span');}
		else{DeHighlightBox('studentfirstname_span')}
		if (inForm.studentlastname.value == '')
		{HighlightBox('studentlastname_span');}
		else{DeHighlightBox('studentlastname_span')}
		return false;
	}
	return true;
}


function ValidateUserSearch(inForm)
{
	if (inForm.userfirstname.value == '' || inForm.userlastname.value == '')
	{
		alert('First Name AND Last Name are required')
		if (inForm.userfirstname.value == '')
		{HighlightBox('userfirstname_span');}
		else{DeHighlightBox('userfirstname_span')}
		if (inForm.userlastname.value == '')
		{HighlightBox('userlastname_span');}
		else{DeHighlightBox('userlastname_span')}
		return false;
	}
	return true;
}



function ValidateUserSearch2(inForm)
{
	if (inForm.userfirstname.value == '' && inForm.userlastname.value == '' && inForm.useremail.value == '')
	{
		alert('First Name OR Last Name OR Email Address are required')
		HighlightBox('userfirstname_span');
		HighlightBox('userlastname_span');
		HighlightBox('useremail_span');
		return false;
	}
	else
	{
		DeHighlightBox('userfirstname_span');
		DeHighlightBox('userlastname_span');
		DeHighlightBox('useremail_span');	
	}
	return true;
}

function ValidateLoginForm(inForm)
{
	var msg = "";
	if (inForm.userlogin.value == '')
	{
		msg += '\n - User Name';
		HighlightBox('userlogin_span');
	}
	else{DeHighlightBox('userlogin_span')}
	
	if (inForm.userpassword.value == '')
	{
		msg += '\n - Password';
		HighlightBox('userpassword_span');
	}
	else{DeHighlightBox('userpassword_span')}
	
	if (msg != "")
	{
		msg = 'The following fields are required or not formatted properly:\n' + msg;
		alert(msg);
		return false;
	}
	return true;	
}

function ValidateFinances(inForm)
{
	var msg = "";
	if (inForm.schoolid.value == '')
	{
		msg += '\n - School Name';
		HighlightBox('schoolid_span');
	}
	else{DeHighlightBox('schoolid_span')}
	
	if (inForm.payee.value == '')
	{
		msg += '\n - Payee';
		HighlightBox('payee_span');
	}
	else{DeHighlightBox('payee_span')}
	
	if (inForm.payment.value == '')
	{
		msg += '\n - Payment';
		HighlightBox('payment_span');
	}
	else{DeHighlightBox('payment_span')}
	
	if (!isUSCurrency(inForm.payment.value))
	{
		msg += '\n - Payment is not a valid dollar amount';
		HighlightBox('payment_span');
	}
	
	
	if (inForm.checkno.value == '')
	{
		msg += '\n - Check Number';
		HighlightBox('checkno_span');
	}
	else{DeHighlightBox('checkno_span')}
	
	if (inForm.checkdate.value == '')
	{
		msg += '\n - Check Date';
		HighlightBox('checkdate_span');
	}
	else{DeHighlightBox('checkdate_span')}
	
	if (!isDate(inForm.checkdate.value))
	{
		msg += '\n - Check Date is not a valid date';
		HighlightBox('checkdate_span');
	}
	
	if (inForm.checkdatereceived.value == '')
	{
		msg += '\n - Date Check was Received';
		HighlightBox('checkdatereceived_span');
	}
	else{DeHighlightBox('checkdatereceived_span')}
	
	if (!isDate(inForm.checkdatereceived.value))
	{
		msg += '\n - Date Check was Received is not a valid date';
		HighlightBox('checkdatereceived_span');
	}
	
	
	if (inForm.numreg.value == '')
	{
		msg += '\n - Number of Students Registered';
		HighlightBox('numreg_span');
	}
	else{DeHighlightBox('numreg_span')}
	
	if (isNaN(inForm.numreg.value))
	{msg += '\n - Number of Students Registered is not numeric';HighlightBox('numreg_span');}
	
	
	if (msg != "")
	{
		msg = 'The following fields are required or not formatted properly:\n' + msg;
		alert(msg);
		return false;
	}
	return true;
}


function HighlightBox(spanbox)
{document.getElementById(spanbox).style.backgroundColor = 'yellow';}

function DeHighlightBox(spanbox)
{document.getElementById(spanbox).style.backgroundColor = '';}



function ValidateSiteForm(inForm)
{
	var msg = "";
	if (inForm.sitename.value == '')
	{
		msg += '\n - Site Name';
		HighlightBox('sitename_span');
	}
	else{DeHighlightBox('sitename_span')}
	
	if (inForm.address.value == '')
	{
		msg += '\n - Address';
		HighlightBox('address_span');
	}
	else{DeHighlightBox('address_span')}
	
	if (inForm.city.value == '')
	{
		msg += '\n - City';
		HighlightBox('city_span');
	}
	else{DeHighlightBox('city_span')}
	
	if (inForm.state.value == '')
	{
		msg += '\n - State';
		HighlightBox('state_span');
	}
	else{DeHighlightBox('state_span')}
	
	if (inForm.zip.value == '')
	{
		msg += '\n - Postal Code';
		HighlightBox('zip_span');
	}
	else{DeHighlightBox('zip_span')}
	
	if (isNaN(inForm.zip.value) || (inForm.zipfour.value != '' && isNaN(inForm.zipfour.value)))
	{msg += '\n - Zip is not numeric';HighlightBox('zip_span');}
	
	if (msg != "")
	{
		msg = 'The following fields are required or not formatted properly:\n' + msg;
		alert(msg);
		return false;
	}
	return true;	
}


function ValidateSchoolForm(inForm)
{
	var msg = "";
	if (inForm.schoolname.value == '')
	{
		msg += '\n - School Name';
		HighlightBox('schoolname_span');
	}
	else{DeHighlightBox('schoolname_span')}
	

	if (inForm.address.value == '')
	{
		msg += '\n - Address';
		HighlightBox('address_span');
	}
	else{DeHighlightBox('address_span')}
	
	if (inForm.city.value == '')
	{
		msg += '\n - City';
		HighlightBox('city_span');
	}
	else{DeHighlightBox('city_span')}
	
	if (inForm.state.value == '')
	{
		msg += '\n - State';
		HighlightBox('state_span');
	}
	else{DeHighlightBox('state_span')}
	
	if (inForm.zip.value == '')
	{
		msg += '\n - Postal Code';
		HighlightBox('zip_span');
	}
	else{DeHighlightBox('zip_span')}
	
	if (inForm.zip.value != '' && inForm.zip.value.length < 5)
	{	
		msg += '\n - Zip Code needs to be a mininum of 5 numbers.';
		HighlightBox('zip_span');
	}
	if (isNaN(inForm.zip.value) || (inForm.zipfour.value != '' && isNaN(inForm.zipfour.value)))
	{msg += '\n - Zip is not numeric';HighlightBox('zip_span');}
	
	if (inForm.areacode.value == '' || inForm.prefix.value == '' || inForm.linenumber.value == '')
	{
		msg += '\n - School Phone';
		HighlightBox('schoolphone_span');
	}
	else{DeHighlightBox('schoolphone_span')}
	
	if (isNaN(inForm.areacode.value))
	{msg += '\n - School Phone Number (Area Code) is not numeric';HighlightBox('schoolphone_span');}
	if (isNaN(inForm.prefix.value))
	{msg += '\n - School Phone Number (Prefix) is not numeric';HighlightBox('schoolphone_span');}
	if (isNaN(inForm.linenumber.value))
	{msg += '\n - School Phone Number (Line Number) is not numeric';HighlightBox('schoolphone_span');}

	if (isNaN(inForm.faxareacode.value))
	{msg += '\n - School Fax Number (Area Code) is not numeric';HighlightBox('schoolfax_span');}
	if (isNaN(inForm.faxprefix.value))
	{msg += '\n - School Fax Number (Prefix) is not numeric';HighlightBox('schoolfax_span');}
	if (isNaN(inForm.faxlinenumber.value))
	{msg += '\n - School Fax Number (Line Number) is not numeric';HighlightBox('schoolfax_span');}
	
	
	if (inForm.county.value == '')
	{
		msg += '\n - County';
		HighlightBox('county_span');
	}
	else{DeHighlightBox('county_span')}
	
	
	if (inForm.category.length)
	{
		var catselected = false;	
		for (i = 0; i < inForm.category.length; i++)
		{
		  if (inForm.category[i].checked == true)
		  {
		  	catselected = true;			
			break;
		  }
	   	}	
		if (catselected ==  false)
		{
			msg += '\n - Category';
			HighlightBox('category_span');
		}
		else{DeHighlightBox('category_span')}
	}

	
	
	if (msg != "")
	{
		msg = 'The following fields are required or not formatted properly:\n' + msg;
		alert(msg);
		return false;
	}
	return true;	
}


function ValidateResetSecurityForm(inForm)
{
	
	var msg = "";
	
	if (inForm.bAskForEmail.value == 'true')
	{
		if (inForm.email.value == '')
		{
			msg += '\n - Email';
			HighlightBox('email_span');
		}
		else{DeHighlightBox('email_span')}		
	}
	
	if (inForm.username.value == '')
	{
		msg += '\n - UserName';
		HighlightBox('username_span');
	}
	else{DeHighlightBox('username_span')}
	
	if (inForm.password1.value == '')
	{
		msg += '\n - Password';
		HighlightBox('password1_span');
	}
	else{DeHighlightBox('password1_span')}
	
	if (inForm.password2.value == '')
	{
		msg += '\n - Confirm Password';
		HighlightBox('password2_span');
	}
	else{DeHighlightBox('password2_span')}
	
	if ((inForm.password1.value != '' && inForm.password2.value != '') && (inForm.password1.value != inForm.password2.value))
	{
		msg += '\n - Passwords MUST Match';
		HighlightBox('password1_span');
		HighlightBox('password2_span');
		inForm.password1.value = "";
		inForm.password2.value = "";
	}
			
	if (inForm.securityqnid.value == '')
	{
		msg += '\n - Security Question';
		HighlightBox('securityqnid_span');
	}
	else{DeHighlightBox('securityqnid_span')}
	
	if (inForm.securityqnanswer.value == '')
	{
		msg += '\n - Security Question Answer';
		HighlightBox('securityqnanswer_span');
	}
	else{DeHighlightBox('securityqnanswer_span')}
	
	
	if (msg != "")
	{
		msg = 'The following fields are required or not formatted properly:\n' + msg;
		alert(msg);
		return false;
	}
	return true;	
}



function ValidateSchoolLoginReset(inForm)
{

	var msg = "";
	if (inForm.tempstudentlogin.value == '')
	{
		msg += '\n - Student Login';
		HighlightBox('tempstudentlogin_span');
	}
	else{DeHighlightBox('tempstudentlogin_span')}
	
	if (inForm.tempstudentpassword1.value == '')
	{
		msg += '\n - Password';
		HighlightBox('tempstudentpassword1_span');
	}
	else{DeHighlightBox('tempstudentpassword1_span')}
	
	if (inForm.tempstudentpassword2.value == '')
	{
		msg += '\n - Confirm Password';
		HighlightBox('tempstudentpassword2_span');
	}
	else{DeHighlightBox('tempstudentpassword2_span')}
	
	if ((inForm.tempstudentpassword1.value != '' && inForm.tempstudentpassword2.value != '') && (inForm.tempstudentpassword1.value != inForm.tempstudentpassword2.value))
	{
		msg += '\n - Passwords MUST Match';
		HighlightBox('tempstudentpassword1_span');
		HighlightBox('tempstudentpassword2_span');
		inForm.tempstudentpassword1.value = "";
		inForm.tempstudentpassword2.value = "";
	}
	
	
	if (msg != "")
	{
		msg = 'The following fields are required or not formatted properly:\n' + msg;
		alert(msg);
		return false;
	}
	return true;

}


function ValidateUserSecurityForm(inForm)
{
	
	var msg = "";
	if (inForm.username.value == '')
	{
		msg += '\n - UserName';
		HighlightBox('username_span');
	}
	else{DeHighlightBox('username_span')}
	
	if (inForm.password1.value == '')
	{
		msg += '\n - Password';
		HighlightBox('password1_span');
	}
	else{DeHighlightBox('password1_span')}
	
	if (inForm.password2.value == '')
	{
		msg += '\n - Confirm Password';
		HighlightBox('password2_span');
	}
	else{DeHighlightBox('password2_span')}
	
	if ((inForm.password1.value != '' && inForm.password2.value != '') && (inForm.password1.value != inForm.password2.value))
	{
		msg += '\n - Passwords MUST Match';
		HighlightBox('password1_span');
		HighlightBox('password2_span');
		inForm.password1.value = "";
		inForm.password2.value = "";
	}
			
	if (inForm.securityqnid.value == '')
	{
		msg += '\n - Security Question';
		HighlightBox('securityqnid_span');
	}
	else{DeHighlightBox('securityqnid_span')}
	
	if (inForm.securityqnanswer.value == '')
	{
		msg += '\n - Security Question Answer';
		HighlightBox('securityqnanswer_span');
	}
	else{DeHighlightBox('securityqnanswer_span')}
	
	
	if (msg != "")
	{
		msg = 'The following fields are required or not formatted properly:\n' + msg;
		alert(msg);
		return false;
	}
	return true;	
}


function ValidatePossibleMatches(inForm)
{
	var userselected = false;
	
	if (inForm.userid.length)
	{
		for (i = 0; i < inForm.userid.length; i++)
		{
		  if (inForm.userid[i].checked == true)
		  {
		  	userselected = true;			
			break;
		  }
	   	}		
	}
	else 
	{
		//alert(inForm.userid.checked)
		if (inForm.userid.checked == true)
	  	{userselected = true;}
	}
	if (userselected ==  false)
	{alert('You must choose at least one possible match.\n\nAdd New User if your record is not found.'); return false;}
	else{return true;}

}

function ValidatePossibleMatchesforDelete(inForm)
{
	var userselected = false;
	
	if (inForm.userid.length)
	{
		for (i = 0; i < inForm.userid.length; i++)
		{
		  if (inForm.userid[i].checked == true)
		  {
		  	userselected = true;
			userid = inForm.userid[i].value;			
			break;
		  }
	   	}		
	}
	else 
	{
		//alert(inForm.userid.checked)
		if (inForm.userid.checked == true)
	  	{userselected = true;userid = inForm.userid.value;}
	}
	if (userselected ==  false)
	{alert('You must choose at least one possible match.'); return false;}
	
	//alert(userid);
	username = eval('inForm.username'+userid+'.value')
	bFoundPosition = eval('inForm.bFoundPosition'+userid+'.value')
	//alert(bFoundPosition);
	
	//Check for Responsbilities
	if (bFoundPosition ==  'true')
	{alert('You must remove ' + username + '\'s responsibilities before deleting them from the system.');return false;}
		
	//Confirm Deletion	
	if(confirm('Are you sure you wish to delete ' + username + '?\n\nThis action is irreversible.\n\nOK to confirm; Cancel to abort'))
	{return true;}
	else{return false;}	

}



function ValidatePossibleStudents(inForm)
{
	var userselected = false;
	
	if (inForm.userid.length)
	{
		for (i = 0; i < inForm.userid.length; i++)
		{
		  if (inForm.userid[i].checked == true)
		  {
		  	userselected = true;			
			break;
		  }
	   	}		
	}
	else 
	{
		//alert(inForm.userid.checked)
		if (inForm.userid.checked == true)
	  	{userselected = true;}
	}
	if (userselected ==  false)
	{alert('You must choose at least one possible match.\n\nAdd New User if your record is not found.'); return false;}
	else{return true;}	
}

function ValidatePossibleDupUsers(inForm)
{
	var userselected = false;
	
	if (inForm.userid.length)
	{
		for (i = 0; i < inForm.userid.length; i++)
		{
		  if (inForm.userid[i].checked == true)
		  {
		  	userselected = true;			
			break;
		  }
	   	}		
	}
	else 
	{
		//alert(inForm.userid.checked)
		if (inForm.userid.checked == true)
	  	{userselected = true;}
	}
	if (userselected ==  false)
	{alert('You must choose at least one possible match in order to Edit an exisiting user.'); return false;}
	else{return true;}	
}



function ValidateFinanceDeletion(inForm)
{
	if(confirm('Are you sure you wish to delete this registration payment?\n\nOK to confirm; Cancel to abort'))
	{finance.action.value = 'delete'; return true;}
	else{return false;}	
}


function CheckNum(inForm,sel)
{
	var StudentIDArray = inForm.StudentsIDList.value.split(",");
	var NumTestTakers = 0;
	
	for (i = 0; i < StudentIDArray.length; i++)
	{
		if (eval('inForm.status_'+StudentIDArray[i]+'[0].checked') == true)
		NumTestTakers += 1;
	}
	//alert(NumTestTakers)
	//alert(inForm.StudentsPaid.value)
	if (NumTestTakers > inForm.StudentsPaid.value)
	{
		alert('You only paid for ' + inForm.StudentsPaid.value + ' students.  You have already met this limit.\n\nTo add additional Test Takers please send in addition registration or change a student\'s status from Test Taker to Alternate.')
		eval('inForm.status_'+sel+'[0].checked = false');
		eval('inForm.status_'+sel+'[1].checked = true');
		
	}	
}

function ValidateRoster(inForm)
{
	
	var StudentArray = inForm.StudentsIDList.value.split(',');				
	var NumTestTakers = 0;
	var StudentsToRemove = ""
	for (var y = 0; y < StudentArray.length; y++)
	{
		if (eval('inForm.status_'+StudentArray[y]+'[0].checked'))
		{
			NumTestTakers++;
		}					
	}
	if (NumTestTakers > inForm.TotalTestTakersPerTeam.value)
	{
		alert('Only '+inForm.TotalTestTakersPerTeam.value+' students are permitted to be Test Takers.\n\nPlease selected your students accordingly')
		return false;
	}
	
	var StudentsToRemove = ""
	for (var y = 0; y < StudentArray.length; y++)
	{
		
		if (eval('inForm.status_'+StudentArray[y]+'[2].checked'))
		{
			StudentsToRemove += eval('inForm.username_'+StudentArray[y]+'.value')+'\n'
		}					
	}
	if (StudentsToRemove != '')
	{
		if(!confirm('Are you sure you want to remove the following students\n\n'+StudentsToRemove+'\n\nOK to confirm; Cancel to abort'))
		{return false;}	
	}
				
	return true;			
}

function TakeFocus(formname,fieldname)
{
	//alert(formname);
	//alert(fieldname);
	if (is_nav)
	{
		//alert('is_nav: ' + is_nav);
		window.addEventListener("load", function () {eval(formname+'.'+fieldname+'.focus()')}, false);
	}
	if (is_ie)
	{
		//alert('is_ie: ' + is_ie);
		window.attachEvent("onload", function () {eval(formname+'.'+fieldname+'.focus()')});
	}
}



function ValidateCreateLogin(inForm)
{
	
	var msg = "";
	
	if (inForm.username.value == '')
	{
		msg += '\n - UserName';
		HighlightBox('username_span');
	}
	else{DeHighlightBox('username_span')}
	
	if (inForm.password1.value == '')
	{
		msg += '\n - Password';
		HighlightBox('password1_span');
	}
	else{DeHighlightBox('password1_span')}
	
	if (inForm.password2.value == '')
	{
		msg += '\n - Confirm Password';
		HighlightBox('password2_span');
	}
	else{DeHighlightBox('password2_span')}
	
	if ((inForm.password1.value != '' && inForm.password2.value != '') && (inForm.password1.value != inForm.password2.value))
	{
		msg += '\n - Passwords MUST Match';
		HighlightBox('password1_span');
		HighlightBox('password2_span');
		inForm.password1.value = "";
		inForm.password2.value = "";
	}
			
	if (inForm.securityqnid.value == '')
	{
		msg += '\n - Security Question';
		HighlightBox('securityqnid_span');
	}
	else{DeHighlightBox('securityqnid_span')}
	
	if (inForm.securityqnanswer.value == '')
	{
		msg += '\n - Security Question Answer';
		HighlightBox('securityqnanswer_span');
	}
	else{DeHighlightBox('securityqnanswer_span')}
	
	
	if (msg != "")
	{
		msg = 'The following fields are required or not formatted properly:\n' + msg;
		alert(msg);
		return false;
	}
	return true;	
}

function ValidateSchoolFormRequest(inForm)
{
	var msg = "";
	if (inForm.schoolname.value == '')
	{
		msg += '\n - School Name';
		HighlightBox('schoolname_span');
	}
	else{DeHighlightBox('schoolname_span')}
	

	if (inForm.address.value == '')
	{
		msg += '\n - Address';
		HighlightBox('address_span');
	}
	else{DeHighlightBox('address_span')}
	
	if (inForm.city.value == '')
	{
		msg += '\n - City';
		HighlightBox('city_span');
	}
	else{DeHighlightBox('city_span')}
	
	if (inForm.state.value == '')
	{
		msg += '\n - State';
		HighlightBox('state_span');
	}
	else{DeHighlightBox('state_span')}
	
	if (inForm.zip.value == '')
	{
		msg += '\n - Postal Code';
		HighlightBox('zip_span');
	}
	else{DeHighlightBox('zip_span')}
	
	if (inForm.zip.value != '' && inForm.zip.value.length < 5)
	{	
		msg += '\n - Zip Code needs to be a mininum of 5 numbers.';
		HighlightBox('zip_span');
	}
	if (isNaN(inForm.zip.value) || (inForm.zipfour.value != '' && isNaN(inForm.zipfour.value)))
	{msg += '\n - Zip is not numeric';HighlightBox('zip_span');}
	
	if (inForm.areacode.value == '' || inForm.prefix.value == '' || inForm.linenumber.value == '')
	{
		msg += '\n - School Phone';
		HighlightBox('schoolphone_span');
	}
	else{DeHighlightBox('schoolphone_span')}
	
	if (isNaN(inForm.areacode.value))
	{msg += '\n - School Phone Number (Area Code) is not numeric';HighlightBox('schoolphone_span');}
	if (isNaN(inForm.prefix.value))
	{msg += '\n - School Phone Number (Prefix) is not numeric';HighlightBox('schoolphone_span');}
	if (isNaN(inForm.linenumber.value))
	{msg += '\n - School Phone Number (Line Number) is not numeric';HighlightBox('schoolphone_span');}

	if (isNaN(inForm.faxareacode.value))
	{msg += '\n - School Fax Number (Area Code) is not numeric';HighlightBox('schoolfax_span');}
	if (isNaN(inForm.faxprefix.value))
	{msg += '\n - School Fax Number (Prefix) is not numeric';HighlightBox('schoolfax_span');}
	if (isNaN(inForm.faxlinenumber.value))
	{msg += '\n - School Fax Number (Line Number) is not numeric';HighlightBox('schoolfax_span');}
	
	
	if (inForm.county.value == '')
	{
		msg += '\n - County';
		HighlightBox('county_span');
	}
	else{DeHighlightBox('county_span')}
	
	if (msg != "")
	{
		msg = 'The following fields are required or not formatted properly:\n' + msg;
		alert(msg);
		return false;
	}
	return true;	
}

function ValidateEnrollmentForm(inForm)
{
	var msg = "";
	//alert(inForm.schoolidlist.value);
	var SchoolIDArray = inForm.schoolidlist.value.split(",");
	for (var y = 0; y < SchoolIDArray.length; y++)
	{
		if (isNaN(eval('inForm.enrollment_'+SchoolIDArray[y]+'.value')))
		{
			msg +='Enrollment Figures for ' + eval('inForm.schoolname_'+SchoolIDArray[y]+'.value') + ' is not numeric.\n';
		}					
	}
	if (msg != "")
	{
		msg = msg + '\nEnrollment figures must be numeric.';
		alert(msg);
		return false;
	}
	return true;
}




function ValidateHomeSchoolApprove(inForm)
{
	var SchoolIDArray = inForm.SchoolIDList.value.split(",");
	var coachselected = false;	
	
	for (i = 0; i < SchoolIDArray.length; i++)
	{
	
	  if ( eval('inForm.School_'+SchoolIDArray[i]+'[0].checked') == true || eval('inForm.School_'+SchoolIDArray[i]+'[1].checked') == true )
	  {
	  	coachselected = true;			
		break;
	  }
   	}	
	if (coachselected ==  false)
	{
		alert('You must choose at least one Home-School');
		return false;		
	}
	return true;
}

function ValidateCoachApprove(inForm)
{
	var SchoolIDArray = inForm.SchoolIDList.value.split(",");
	var coachselected = false;	
	
	for (i = 0; i < SchoolIDArray.length; i++)
	{
	
	  if ( eval('inForm.School_'+SchoolIDArray[i]+'[0].checked') == true || eval('inForm.School_'+SchoolIDArray[i]+'[1].checked') == true )
	  {
	  	coachselected = true;			
		break;
	  }
   	}	
	if (coachselected ==  false)
	{
		alert('You must choose at least one Coach');
		return false;		
	}
	return true;
}

function ValidateIndStudentApprove(inForm)
{
	var StudentIDArray = inForm.StudentIDList.value.split(",");
	var studentselected = false;	
	
	for (i = 0; i < StudentIDArray.length; i++)
	{
	
	  if ( eval('inForm.Student_'+StudentIDArray[i]+'[0].checked') == true || eval('inForm.Student_'+StudentIDArray[i]+'[1].checked') == true || eval('inForm.Student_'+StudentIDArray[i]+'[2].checked') == true )
	  {
	  	studentselected = true;			
		break;
	  }
   	}	
	if (studentselected ==  false)
	{
		alert('You must choose at least one Student');
		return false;		
	}
	return true;
}


function ConfirmRemoveSchoolfromSite(school,siteschoolid)
{
	//Confirm Deletion	
	if(confirm('Are you sure you wish to remove the school ' + school + ' as a registered school?\n\nOK to confirm; Cancel to abort'))
	{
		window.location.href = 'unregisterschool.cfm?siteschoolid=' + siteschoolid;
	}
	else{return false;}	
}


function ConfirmRemoveIndvStudentfromSite(student, studentsid, siteid, year)
{
	//Confirm Deletion	
	if(confirm('Are you sure you wish to remove the student ' + student + ' as a registered student?\n\nOK to confirm; Cancel to abort'))
	{
		window.location.href = 'unregisterindvstudent.cfm?studentsid=' + studentsid;
	}
	else{return false;}	
}


function ValidateStudentScoresForm(inForm)
{
	var msg = "";
	var StudentsIDArray = inForm.studentsidlist.value.split(",");
	for (var y = 0; y < StudentsIDArray.length; y++)
	{
		if (isNaN(eval('inForm.score_'+StudentsIDArray[y]+'.value')))
		{
			msg +='Scores for ' + eval('inForm.studentname_'+StudentsIDArray[y]+'.value') + ' is not numeric.\n';
		}					
	}
	if (msg != "")
	{
		msg = msg + '\nStudents Scores must be numeric.';
		alert(msg);
		return false;
	}
	return true;
}

function ShowSeatingLabels(filter, filtertext)
{

	if (filter == '')
	{
		alert('You must choose a ' + filtertext)
	}
	else
	{
		if (filtertext == 'Site Name')
		{openNewWindow('SiteLabels','StudentSeatingLabelsOutput.cfm?bDownload=true&SiteID=' + filter,'','','','',1,1,1,1,1,1,1,1);}
		else if (filtertext == 'School Name')
		{openNewWindow('SchoolLabels','StudentSeatingLabelsOutput.cfm?bDownload=true&Schoolid=' + filter,'','','','',1,1,1,1,1,1,1,1);}
		else if (filtertext == 'Student')
		{openNewWindow('StudentsLabels','StudentSeatingLabelsOutput.cfm?bDownload=true&StudentsID=' + filter,'','','','',1,1,1,1,1,1,1,1);}
		else if (filtertext == 'All')
		{openNewWindow('SchoolLabels','StudentSeatingLabelsOutput.cfm?bDownload=true','','','','',1,1,1,1,1,1,1,1);}
		else if (filtertext == 'SchoolNameOnly')
		{openNewWindow('SchoolLabels','StudentSeatingLabelsOutput.cfm?bDownload=true&SchoolOnlyid=' + filter,'','','','',1,1,1,1,1,1,1,1);}
		else
		{alert('Error: Student Labels');}
	}
}

function ShowAnswerDocStudentInfo(filter, filtertext)
{

	if (filter == '')
	{
		alert('You must choose a ' + filtertext)
	}
	else
	{
		if (filtertext == 'Site Name')
		{openNewWindow('AnswerDocsStudentInfo','answerdocstudentinfooutput.cfm?bDownload=true&SiteID=' + filter,'','','','',1,1,1,1,1,1,1,1);}
		else if (filtertext == 'School Name')
		{openNewWindow('AnswerDocsStudentInfo','answerdocstudentinfooutput.cfm?bDownload=true&SiteandSchoolID=' + filter,'','','','',1,1,1,1,1,1,1,1);}
		else if (filtertext == 'Student')
		{openNewWindow('AnswerDocsStudentInfo','answerdocstudentinfooutput.cfm?bDownload=true&StudentsID=' + filter,'','','','',1,1,1,1,1,1,1,1);}
		else if (filtertext == 'All')
		{openNewWindow('AnswerDocsStudentInfo','answerdocstudentinfooutput.cfm?bDownload=true','','','','',1,1,1,1,1,1,1,1);}
		else if (filtertext == 'blank')
		{openNewWindow('AnswerDocsStudentInfo','answerdocstudentinfooutput.cfm?bDownload=true&Blank=true','','','','',1,1,1,1,1,1,1,1);}
		else
		{alert('Error: Answer Document Student Information');}
	}
}



function ConfirmSendingStudentScores(thankyous,qualifiers,coaches,allcoaches)
{

	//Confirm Email Student Scores
	alert('You are about to send the following emails:\n\n' 
	+ thankyous + ' emails to Students thanking them for participanting.\n'
	+ qualifiers + ' emails for OHMIO qualifiers.\n'
	+ coaches + ' emails to coaches of OHMIO qualifiers.\n');	
	+ allcoaches + ' emails to Coaches thanking them for participating.\n\n\nYou will be asked to confirm this action.'
	if(confirm('Are you sure you wish to send the Student Scores?\n\nOK to confirm; Cancel to abort'))
	{return true;}
	else{return false;}	

}
