// define the namespace if necessary
if ( Jensen == undefined )
	var Jensen = { };
	
if ( Jensen.ContactUs == undefined )
	Jensen.ContactUs = { };
	
	
Jensen.ContactUs.timeframeValidator = function() {
	this.IsValid = false;

	// at least one of the following checkboxes must be checked
	var contactMorning = Lutz.DomUtil.getFormFieldValue( "chkContactMorning" );
	var contactMidday = Lutz.DomUtil.getFormFieldValue( "chkContactMidday" );
	var contactAfternoon = Lutz.DomUtil.getFormFieldValue( "chkContactAfternoon" );

	if  ( contactMorning || contactMidday || contactAfternoon )
		this.IsValid = true;
		
	// Tada! Validation is complete
	this.AfterFieldValidate.fire();
}

	
Jensen.ContactUs.ValidationParameters = { 
	FormId     : "frmContactUs",
	Validators : [
		{ 	Type               : Lutz.Validation.ValidatorType.Required,  
			Key                : "FullNameRequired",
			ControlToValidate  : "txtFullName",
			EmptyState         : "Full Name",
			ErrorMessage       : "You must enter your Full Name."
		}, 
		{ 	Type               : Lutz.Validation.ValidatorType.Required,  
			Key                : "PhoneNumberRequired",
			ControlToValidate  : "txtPhoneNumber",
			EmptyState         : "Phone Number",
			ErrorMessage       : "You must enter your Phone Number."
		}, 
		{ 	Type               : Lutz.Validation.ValidatorType.Required,  
			Key                : "EmailRequired",
			ControlToValidate  : "txtEmail",
			EmptyState         : "Email",
			ErrorMessage       : "You must enter your Email Address."
		}, 
		{ 	Type               : Lutz.Validation.ValidatorType.Required,  
			Key                : "CommentsRequired",
			ControlToValidate  : "txtComments",
			ErrorMessage       : "Please enter some notes about the reason you are contacting us."
		}, 
		{ 	Type              : Lutz.Validation.ValidatorType.Custom,  
			Key               : "ContactWhen",
			ValidationFunction: Jensen.ContactUs.timeframeValidator,
			ErrorMessage      : "You must check at least one box to indicate the best time to contact you."
		}
	],
	Visualizers : [
		{
			Type          : Lutz.Validation.VisualizerType.Summary,
			Control       : "ctlValidationSummary"
		}
	]
}
