var TestimonialForm = {
	totalWords: function()
	{
		var value = $('#txtMessage').val();
		
		a=value.replace(/\s/g,' ');
		a=a.split(' ');
		
		return a.length;
	},
	
	onSubmit: function()
	{
		var frm = new validator('#frmEntry');
		frm.checkEmpty({'#txtName' : 'Name is required. Please enter a name.',
					   '#txtEmail' : 'Email is required. Please enter an email.',
					   '#txtAddress1': 'Address is required. Please enter an address.',
					   '#txtPhone': 'Phone is required. Please enter a phone number.',
					   '#txtMessage': 'Testimonial is required. Please enter a testimonial.',
					   '#txtCaptcha': 'Security code is required. Please enter the code shown in the security image.'});
		frm.checkEmail({'#txtEmail': 'Email is invalid. Please enter a valid email address.'});
		
		var totalWords = TestimonialForm.totalWords();
		frm.must('#txtMessage', 'Testimonial must be within 250 words. You have entered ' + totalWords + '.', (totalWords <= 250));
		
		if(frm.isValid())
		{
			util.block('#testimonial_entry');
			return true;
		}
		else
		{
			frm.publish('#result');
		}
		
		return false;
	},
	
	
	
	init: function()
	{
		$('#frmEntry').bind('submit', TestimonialForm.onSubmit);
	}
};
