/*
	Registers the required fields to the Validations object
	Returns True or False if all required fields have been entered
	and are of valid format.
*/
var validated;
var validations;	
var highlightField = true;
var errorMessageId = "errorMessage";
var errorMessage = "One or more required form fields are either empty or are missing selections.  Please review the form, correct as needed, and try sending again.";

function init()
{
	validated = true;
	validations = new Array();
}

function validateFields(validations)
{
	for (var v in validations) 
		validated = validated && validations[v];

	if (false == validated)
	{
		validation.message(errorMessageId, errorMessage);
		validation.highlightLabel(validated, errorMessageId);
		
		document.getElementById(errorMessageId).style.display = "block";
	}
	else
	{
		document.getElementById(errorMessageId).style.display = "none";
	}
	
	return validated;
}

function validateContactForm()
{
	init();

	validations.push(validation.required("firstname", errorMessageId, errorMessage, highlightField, "firstnameLabel"));
	validations.push(validation.required("lastname", errorMessageId, errorMessage, highlightField, "lastnameLabel"));
	validations.push(validation.required("email", errorMessageId, errorMessage, highlightField, "emailLabel"));
	// validations.push(validation.required("comments", errorMessageId, errorMessage, highlightField, "commentsLabel")); Do not require comments
	// validations.push(validation.required("subject", errorMessageId, errorMessage, highlightField, "subjectLabel")); Do not require subject
			
	return validateFields(validations);
}

function validateRequestSpeakerForm()
{
	init();

	validations.push(validation.required("firstname", errorMessageId, errorMessage, highlightField, "firstnameLabel"));
	validations.push(validation.required("lastname", errorMessageId, errorMessage, highlightField, "lastnameLabel"));
	validations.push(validation.required("email", errorMessageId, errorMessage, highlightField, "emailLabel"));
	validations.push(validation.required("businessPhone", errorMessageId, errorMessage, highlightField, "businessPhoneLabel"));

	return validateFields(validations);
}

function validateCorporateSponsorForm()
{
	init();
	
	validations.push(validation.required("firstname", errorMessageId, errorMessage, highlightField, "firstnameLabel"));
	validations.push(validation.required("lastname", errorMessageId, errorMessage, highlightField, "lastnameLabel"));
	validations.push(validation.required("email", errorMessageId, errorMessage, highlightField, "emailLabel"));
	validations.push(validation.required("businessPhone", errorMessageId, errorMessage, highlightField, "businessPhoneLabel"));
	validations.push(validation.required("sponsorshipType", errorMessageId, errorMessage, highlightField, "sponsorshipTypeLabel"));

	return validateFields(validations);
}

function validateRequestTicketForm()
{
	init();
	
	validations.push(validation.required("firstname", errorMessageId, errorMessage, highlightField, "firstnameLabel"));
	validations.push(validation.required("lastname", errorMessageId, errorMessage, highlightField, "lastnameLabel"));
	validations.push(validation.required("email", errorMessageId, errorMessage, highlightField, "emailLabel"));
	validations.push(validation.required("phone", errorMessageId, errorMessage, highlightField, "phoneLabel"));

	return validateFields(validations);
}

function validateRsvpForm()
{
	init();
	
	validations.push(validation.required("firstname", errorMessageId, errorMessage, highlightField, "firstnameLabel"));
	validations.push(validation.required("lastname", errorMessageId, errorMessage, highlightField, "lastnameLabel"));
	validations.push(validation.required("email", errorMessageId, errorMessage, highlightField, "emailLabel"));
	validations.push(validation.required("phone", errorMessageId, errorMessage, highlightField, "phoneLabel"));
	validations.push(validation.required("attendingEventAnswer", errorMessageId, errorMessage, highlightField, "attendingEventLabel"));
	validations.push(validation.required("associationAnswer", errorMessageId, errorMessage, highlightField, "associationLabel"));

	return validateFields(validations);
}

function showSponsorshipLevels()
{
	// Corporate Sponsor
	if (1 == document.becomeSponsor.sponsorshipType.selectedIndex)
	{
		document.getElementById("corporateSponsorship").style.display = "block";
		document.getElementById("meetingSponsorship").style.display = "none";
	}
	// Meeting
	else if (2 == document.becomeSponsor.sponsorshipType.selectedIndex)
	{
		document.getElementById("meetingSponsorship").style.display = "block";
		document.getElementById("corporateSponsorship").style.display = "none";
	}
	else
	{
		document.getElementById("meetingSponsorship").style.display = "none";
		document.getElementById("corporateSponsorship").style.display = "none";
	}
}