// JavaScript Document

function toggleChildBaggageLocation()
{
	var dropdownIndex = document.getElementById('session_attending').selectedIndex;
	var session = document.getElementById('session_attending')[dropdownIndex].text;
	
	if (session == '')
	{		
		var optionString1 = '<select name="dropoff_at" id="dropoff_at"><option value=\"\">Select a session...</option></select>';
		var optionString2 = '<select name="pickup_at" id="pickup_at"><option value=\"\">Select a session...</option></select>';
		
		document.getElementById('dropoff_at').disabled = true;
		document.getElementById('pickup_at').disabled = true;
	}

	else  // If they picked something
	{
		document.getElementById('dropoff_at').disabled = false;
		document.getElementById('pickup_at').disabled = false;
		
		var optionString1 = '<select name="dropoff_at" id="dropoff_at"><option value=\"none\">Select a location...</option>';
		var optionString2 = '<select name="pickup_at" id="pickup_at"><option value=\"none\">Select a location...</option>';
	
		if (session == 'Session 1')
		{
			optionString1 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Rockland - Palisades Mall</option><option>Westchester - Bloomingdales, White Plains</option><option>New Jersey - Livingston Mall</option><option>Bethesda, MD - Chevy Chase Library</option><option>I plan to drop bags at camp</option><option>I plan to use Camp Trucking</option><option>I plan to use Fedex or UPS</option><option>Flight</option>';	
						   
			optionString2 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>Bethesda, MD - Chevy Chase Library</option><option>Flight</option><option>I plan to pick up my camper\'s bags at camp</option><option>I plan to use Camp Trucking</option><option>I plan to use Fedex or UPS</option>';	
		}
		
		if (session == 'Session 2')
		{
			optionString1 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>Cherry Hill, NJ / Philadelphia - Marriot Hotel, Mount Laurel</option><option>Bethesda, MD - Chevy Chase Library</option><option>I plan to drop bags at camp</option><option>I plan to use Camp Trucking</option><option>I plan to use Fedex or UPS</option><option>Flight</option>';	
						   
			optionString2 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>NYC - 5th Avenue Between 86th and 87th St.</option><option>Cherry Hill, NJ / Philadelphia - Marriot Hotel, Mount Laurel</option><option>Bethesda, MD - Chevy Chase Library</option><option>Flight</option><option>I plan to pick up my camper\'s bags at camp</option><option>I plan to use Camp Trucking</option><option>I plan to use Fedex or UPS</option>';	
		}
		
		if (session == 'Full Summer')
		{
			optionString1 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Rockland - Palisades Mall</option><option>Westchester - Bloomingdales, White Plains</option><option>New Jersey - Livingston Mall</option><option>Bethesda, MD - Chevy Chase Library</option><option>I plan to drop bags at camp</option><option>I plan to use Camp Trucking</option><option>I plan to use Fedex or UPS</option>';	
						   
			optionString2 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>NYC - 5th Avenue Between 86th and 87th St.</option><option>Cherry Hill, NJ / Philadelphia - Marriot Hotel, Mount Laurel</option><option>Bethesda, MD - Chevy Chase Library</option><option>Flight</option><option>I plan to pick up my camper\'s bags at camp</option><option>I plan to use Camp Trucking</option><option>I plan to use Fedex or UPS</option>';	
		}	
		
	}
		document.getElementById('dropoff_at_td').innerHTML = optionString1;
		document.getElementById('pickup_at_td').innerHTML = optionString2;
}

function toggleChildCamperLocation()
{
	var session = document.getElementById('session_attending').value;
	
	if (session == '')
	{		
		var optionString1 = '<option>Select a session...</option>';
		var optionString2 = '<option>Select a session...</option>';
		
		document.getElementById('dropoff_at').disabled = 'disabled';
		document.getElementById('pickup_at').disabled = 'disabled';
	}

	else  // If they picked something
	{
		document.getElementById('dropoff_at').disabled = '';
		document.getElementById('pickup_at').disabled = '';
		
		var optionString1 = '<option>Select a location...</option>';
		var optionString2 = '<option>Select a location...</option>';
	
		if (session == 'Session 1')
		{
			optionString1 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>NYC - 5th Avenue Between 86th and 87th St.</option><option>Flight</option><option>I plan to drive my child to camp</option>';	
						   
			optionString2 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>Flight</option><option>I plan on picking my child up at camp</option>';	
		}
		
		if (session == 'Session 2')
		{
			optionString1 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>Cherry Hill, NJ / Philadelphia - Marriot Hotel, Mount Laurel</option><option>Bethesda, MD - Chevy Chase Library</option><option>I plan on driving my child to camp</option>';	
						   
			optionString2 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>NYC - 5th Avenue Between 86th and 87th St.</option><option>Cherry Hill, NJ / Philadelphia = Marriot Hotel, Mount Laurel</option><option>Bethesda, MD - Chevy Chase Library</option><option>Flight</option><option>I plan on picking my child up at camp</option>';	
		}
		
		if (session == 'Full Summer')
		{
			optionString1 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>NYC - 5th Avenue Between 86th and 87th St.</option><option>Flight</option><option>I plan to drive my child to camp</option>';	
						   
			optionString2 += '<option>Long Island - Old Bethpage Village Restoration</option><option>Westchester / Rockland - Palisades Mall</option><option>New Jersey - Livingston Mall</option><option>NYC - 5th Avenue Between 86th and 87th St.</option><option>Cherry Hill, NJ / Philadelphia = Marriot Hotel, Mount Laurel</option><option>Bethesda, MD - Chevy Chase Library</option><option>Flight</option><option>I plan on picking my child up at camp</option>';	
		}	
	}
		
		document.getElementById('dropoff_at').innerHTML = optionString1;
		document.getElementById('pickup_at').innerHTML = optionString2;
}


function validateForm(formName)
{
	var valid = true;
	var form = document.getElementById(formName);
	var alertMsg = '';
	
	
	if (formName == 'is_baggage_service')
	{
		if (form.email.value == '')
		{
			alertMsg += "Please enter an e-mail address!";
			form.email.style.background = 'yellow';
			form.email.focus();
			valid = false;
		}
		
		else if (form.camper_first_name.value == '')
		{
			alertMsg += "Please enter the camper's first name!";
			form.camper_first_name.style.background = 'yellow';
			form.camper_first_name.focus();			
			valid = false;
		}
		
		else if (form.camper_last_name.value == '')
		{
			alertMsg += "Please enter the camper's last name!";
			form.camper_last_name.style.background = 'yellow';
			form.camper_last_name.focus();		
			valid = false;			
		}
		
		else if (form.session_attending.value == '')
		{
			alertMsg += "Please enter the session your child is attending, and then select the pickup / dropoff locations!";
			form.session_attending.style.background = 'yellow';
			form.session_attending.focus();			
			valid = false;				
		}
		
		else if (form.dropoff_at.value == 'none')
		{
			alertMsg += "Please enter both a dropoff and pickup location!";
			form.dropoff_at.style.background = 'yellow';
			form.dropoff_at.focus();			
			valid = false;				
		}
		
		else if (form.pickup_at.value == 'none')
		{
			alertMsg += "Please enter both a dropoff and pickup location!";
			form.pickup_at.style.background = 'yellow';
			form.pickup_at.focus();			
			valid = false;				
		}
		
	}
	
	else if (formName == 'is_camper_travel')
	{
		if (form.email.value == '')
		{
			alertMsg += "Please enter an e-mail address!\n";
			valid = false;
		}
		
		 if (form.session_attending.value == '')
		{
			alertMsg += "Please enter the session your child is attending, and then select the pickup / dropoff locations!";
			form.session_attending.style.background = 'yellow';
			form.session_attending.focus();			
			valid = false;				
		}
		
		if (form.camper_first_name.value == '' || form.camper_last_name.value == '')
		{
			alertMsg += "Please enter the camper's full name!\n";
			valid = false;
		}
		
		if (form.pickup_at.value == '' || form.dropoff_at.value == '')
		{
			alertMsg += "Please enter both a dropoff and pickup location!\n";
			valid = false;				
		}
		
		
		
		if (!captcha)
		{
			alertMsg += "Please enter the correct validation text at the bottom of the form!\n";
			valid = false;			
		}
	}
	
	else if (formName == 'is_golf')
	{
					
		
		if (form.email.value == '')
		{
			alertMsg += "Please enter your e-mail address!";
			form.email.style.background = 'yellow';
			form.email.focus();
			valid = false;
		}	
		
		else if (form.camper_first_name.value == '')
		{
			alertMsg += "Please enter the camper's first name!";
			form.camper_first_name.style.background = 'yellow';
			form.camper_first_name.focus();
			valid = false;
		}
		
		else if (form.camper_last_name.value == '')
		{
			alertMsg += "Please enter the camper's last name!";
			form.camper_last_name.style.background = 'yellow';
			form.camper_last_name.focus();
			valid = false;
		}
		
		else if (form.package.value == '')
		{
			alertMsg += "Please select a golf package!";
			form.package.style.background = 'yellow';
			form.package.focus();
			valid = false;
		}
		

	}
	
	else if (formName == 'cs_team_member_application')
	{
		
	
		if (form.first_name.value == '')
		{
			alertMsg += "Please enter your first name!";
			form.first_name.style.background = 'yellow';
			form.first_name.focus();
			valid = false;
		}
		
		else if (form.last_name.value == '')
		{
			alertMsg += "Please enter your last name!";
			form.last_name.style.background = 'yellow';
			form.last_name.focus();
			valid = false;
		}		
		
		else if (form.email.value == '')
		{
			alertMsg += "Please enter your e-mail address!";
			form.email.style.background = 'yellow';
			form.email.focus();
			valid = false;
		}
		
		else if (!captcha)
		{
			alertMsg += "Please enter the correct validation text at the bottom of the form!\n";
			valid = false;			
		}
	}
	
	else if (formName == 'cs_pres_weekend_registration')
	{		
							
		
		
		if (form.head_coach_first_name.value == '')
		{
			alertMsg += "Please enter the head coach's first name!";
			form.head_coach_first_name.style.background = 'yellow';
			form.head_coach_first_name.focus();
			valid = false;
		}
		
		else if (form.head_coach_last_name.value == '')
		{
			alertMsg += "Please enter the head coach's last name!";
			form.head_coach_last_name.style.background = 'yellow';
			form.head_coach_last_name.focus();
			valid = false;
		}		
		
		else if (form.head_coach_email.value == '')
		{
			alertMsg += "Please enter the head coach's email address!";
			form.head_coach_email.style.background = 'yellow';
			form.head_coach_email.focus();
			valid = false;
		}
		
		else if (!captcha)
		{
			alertMsg += "Please enter the validation text at the bottom of the page!";
			form.jcap_word.background = 'yellow';
			form.jcap_word.focus();
			valid = false;		
		}
	}
	
	else if (formName == 'cs_pres_week_camp')
	{
			
		
		if (form.player_first_name.value == '')
		{
			alertMsg += "Please enter the player's first name!";
			form.player_first_name.style.background = 'yellow';
			form.player_first_name.focus();
			valid = false;
		}
		
		else if (form.player_last_name.value == '')
		{
			alertMsg += "Please enter the player's last name!";
			form.player_last_name.style.background = 'yellow';
			form.player_last_name.focus();
			valid = false;
		}
		
		else if (form.parent_email.value == '')
		{
			alertMsg += "Please enter your e-mail address!";
			form.parent_email.style.background = 'yellow';	
			form.parent_email.focus();
			valid = false;
		}
	}
	
	
	else if (formName == 'fc_camper_application')
	{
		if (form.family_last_name.value == '')
		{
			alertMsg += "Please enter your family's last name!";
			form.family_last_name.style.background = 'yellow';
			form.family_last_name.focus();
			valid = false;
		}	
		
		else if (form.filler_email.value == '')
		{
			alertMsg += "Please enter your e-mail address!";
			form.filler_email.style.background = 'yellow';
			form.filler_email.focus();
			valid = false;
		}

	}
	
	if (!valid) {alert(alertMsg);} // If invalid, display reason why
	
	return valid;
}
