var checkboxesChecked = 0;

function updateCheckBoxes(thisObj)
{
	if(thisObj.checked)
		checkboxesChecked++;
	else
	{
		if(checkboxesChecked > 0)
			checkboxesChecked--;
	}
}


function checkFieldsRequest(thisForm)
{
	if(thisForm.school.value.trim() == "")
	{
		alert("Enter an Organization or School Name.");
		thisForm.school.focus();
		return false;
	}
	if(thisForm.contacttitle.value.trim() == "")
	{
		alert("Enter a Contact Title.");
		thisForm.contacttitle.focus();
		return false;
	}
	if(thisForm.name.value.trim() == "")
	{
		alert("Enter a Contact Name.");
		thisForm.name.focus();
		return false;
	}
	if(thisForm.address.value.trim() == "")
	{
		alert("Enter an address.");
		thisForm.address.focus();
		return false;
	}
	if(thisForm.city.value.trim() == "")
	{
		alert("Enter a City.");
		thisForm.city.focus();
		return false;
	}
	if(thisForm.ddlState.value == "")
	{
		alert("Select a state.");
		thisForm.ddlState.focus();
		return false;
	}
	if(thisForm.zip.value.trim() == "")
	{
		alert("Enter a Zip Code.");
		thisForm.zip.focus();
		return false;
	}	

	if(!isNumeric(thisForm.zip.value)||(thisForm.zip.value.trim().length != 5))
	{
		alert("Zip Code must be numeric and 5 digits long.");
		thisForm.zip.focus();
		return false;
	}
	
	if(thisForm.phone.value.trim() == "")
	{
		alert("Phone Number is required.");
		thisForm.phone.focus();
		return false;
	}
	
	if((thisForm.phone.value.trim().length != 10)||!isNumeric(thisForm.phone.value.trim()))
	{
		alert("Phone Number must be 10 digits long and numeric (including area code).");
		thisForm.phone.focus();
		return false;
	}	

	if((thisForm.fax.value.trim() != "")&&((thisForm.fax.value.trim().length != 10)||!isNumeric(thisForm.fax.value.trim())))
	{
		alert("Fax Number must be 10 digits long and numeric (including area code).");
		thisForm.fax.focus();
		return false;
	}			
	
	if(thisForm.email.value.trim() == "")
	{
		alert("Email address is required.");
		thisForm.email.focus();
		return false;
	}
		
	if(!isEmail(thisForm.email.value))
	{
		alert("Invalid email address.");
		thisForm.email.focus();
		return false;
	}

	if(thisForm.moreInfo.value.trim() == "")
	{
		alert("Enter what you want to know.");
		thisForm.moreInfo.focus();
		return false;
	}	
	
	if(thisForm.moreInfo.value.length > 500)
	{
		alert("Enter 500 or less characters.  You currently have " + thisForm.moreInfo.value.length);
		thisForm.moreInfo.focus();
		return false;
	}	

	/*if(thisForm.O.checked && thisForm.other.value.trim() == "")
	{
		alert("Enter the name of the program you wish to receive more information about.");
		thisForm.other.focus();
		return false;
	}
	
	if(checkboxesChecked == 0)
	{
		alert("Select one or more programs you wish to receive more information about.");
		return false;
	}*/
	return true;
}

function checkFieldsSpeakerRequest(thisForm)
{
	if(thisForm.school.value.trim() == "")
	{
		alert("Enter an Organization or School Name.");
		thisForm.school.focus();
		return false;
	}
	if(thisForm.contacttitle.value.trim() == "")
	{
		alert("Enter a Contact Title.");
		thisForm.contacttitle.focus();
		return false;
	}
	if(thisForm.name.value.trim() == "")
	{
		alert("Enter a Contact Name.");
		thisForm.name.focus();
		return false;
	}
	if(thisForm.address.value.trim() == "")
	{
		alert("Enter an address.");
		thisForm.address.focus();
		return false;
	}
	if(thisForm.city.value.trim() == "")
	{
		alert("Enter a City.");
		thisForm.city.focus();
		return false;
	}
	if(thisForm.ddlState.value == "")
	{
		alert("Select a state.");
		thisForm.ddlState.focus();
		return false;
	}
	if(thisForm.zip.value.trim() == "")
	{
		alert("Enter a Zip Code.");
		thisForm.zip.focus();
		return false;
	}	
	if(!isNumeric(thisForm.zip.value)||(thisForm.zip.value.trim().length != 5))
	{
		alert("Zip Code must be numeric and 5 digits long.");
		thisForm.zip.focus();
		return false;
	}
	
	if(thisForm.phone.value.trim() == "")
	{
		alert("Phone Number is required.");
		thisForm.phone.focus();
		return false;
	}
	
	if((thisForm.phone.value.trim().length != 10)||!isNumeric(thisForm.phone.value.trim()))
	{
		alert("Phone Number must be 10 digits long and numeric (including area code).");
		thisForm.phone.focus();
		return false;
	}	

	if((thisForm.fax.value.trim() != "")&&((thisForm.fax.value.trim().length != 10)||!isNumeric(thisForm.fax.value.trim())))
	{
		alert("Fax Number must be 10 digits long and numeric (including area code).");
		thisForm.fax.focus();
		return false;
	}		
	
	if(thisForm.ddlMonth.selectedIndex == 0)
	{
		alert("Month of Speaking Engagement is required.");
		thisForm.ddlMonth.focus();
		return false;
	}
	
	if(thisForm.ddlDay.selectedIndex == 0)
	{
		alert("Day of Speaking Engagement is required.");
		thisForm.ddlDay.focus();
		return false;
	}

	if(thisForm.ddlYear.selectedIndex == 0)
	{
		alert("Year of Speaking Engagement is required.");
		thisForm.ddlYear.focus();
		return false;
	}
	
	//if (one is filled out) and not (all are filled out)
	if(	((thisForm.txtSEName.value.trim() != "") ||
			(thisForm.txtSEAddress.value.trim() != "") ||
			(thisForm.txtSECity.value.trim() != "") ||
			(thisForm.ddlSEState.selectedIndex != 0) ||
			(thisForm.txtSEZip.value.trim() != "") ||
			(thisForm.txtSEPhone.value.trim() != "")) &&
		(!((thisForm.txtSEName.value.trim() != "") &&
			(thisForm.txtSEAddress.value.trim() != "") &&
			(thisForm.txtSECity.value.trim() != "") &&
			(thisForm.ddlSEState.selectedIndex != 0) &&
			(thisForm.txtSEZip.value.trim() != "") &&
			(thisForm.txtSEPhone.value.trim() != ""))))
	{
		alert("Complete the Place of Speaking Engagment.");
		thisForm.txtSEName.focus();
		return false;
	}
	
	if((thisForm.txtSEZip.value.trim() != "")&&((thisForm.txtSEZip.value.trim().length != 5)||!isNumeric(thisForm.txtSEZip.value.trim())))
	{
		alert("Zip Code must be 5 digits long and numeric.");
		thisForm.txtSEZip.focus();
		return false;
	}	

	if((thisForm.txtSEPhone.value.trim() != "")&&((thisForm.txtSEPhone.value.trim().length != 10)||!isNumeric(thisForm.txtSEPhone.value.trim())))
	{
		alert("Phone Number must be 10 digits long and numeric (including area code).");
		thisForm.txtSEPhone.focus();
		return false;
	}	

	if(thisForm.ddlHour.selectedIndex == 0)
	{
		alert("Hour of Speaking Engagement is required.");
		thisForm.ddlHour.focus();
		return false;
	}
	
	if(thisForm.ddlMinute.selectedIndex == 0)
	{
		alert("Minute of Speaking Engagement is required.");
		thisForm.ddlMinute.focus();
		return false;
	}	
	
	if(thisForm.txtAudienceSize.value.trim() == "")
	{
		alert("Audience Number is required.");
		thisForm.txtAudienceSize.focus();
		return false;
	}

	if(!isNumeric(thisForm.txtAudienceSize.value.trim()))
	{
		alert("Audience Number must be numeric.");
		thisForm.txtAudienceSize.focus();
		return false;
	}	

	if(thisForm.txtSpeakingTime.value.trim() == "")
	{
		alert("Length of Speaking Time is required.");
		thisForm.txtSpeakingTime.focus();
		return false;
	}

	if(isNaN(thisForm.txtSpeakingTime.value.trim()))
	{
		alert("Length of Speaking Time must be numeric.");
		thisForm.txtSpeakingTime.focus();
		return false;
	}


	if(thisForm.O.checked && thisForm.other.value.trim() == "")
	{
		alert("Enter the name of the program you wish to receive more information about.");
		thisForm.other.focus();
		return false;
	}
	
	if(checkboxesChecked == 0)
	{
		alert("Select one or more programs you wish to receive more information about.");
		return false;
	}
	
	return true;
}

function checkTextField(thisObj)
{
	if(thisObj.checked == false)
		document.Form1.other.value="";
}

function manageOtherText(textField, chkbox)
{
	if(textField.value.trim() != "")
	{
		if(chkbox.checked == false)
			checkboxesChecked++;
		chkbox.checked = true;
	}
	else
	{
		if(chkbox.checked == true)
		{
			if(checkboxesChecked > 0)
				checkboxesChecked--;
		}
		chkbox.checked = false;
	}
}