

jQuery(document).ready(function($){

//------ Reference to form
	
	var $form = $('#form-sign-up');

//-----	Form fields blanking script
	$form
		.find('.txt')//Grab all the text fields on this form
		.focus(function(){//When the field gains focus
			var e = $(this);
			if(e.val() == e.attr('rel'))//if the value is the default blank it in order to help the user fill it out
			{
				e.val('');
			}
		})
		.blur(function(){//When the field loses focus
			var e = $(this);
			if($.trim(e.val()) == '')//If the field is blank add the default value back to indicate to the user what type of  information this field holds
			{
				e.val(e.attr('rel'));
			}
		});


//form validation


	$form.submit(function($e){
	
		var $f = $(this);
		
		if($f.hasClass('submitted'))
		{
			$e.preventDefault();
			alert('Form submission is progress');	
		}
		
		var error = new Array();
		
		if(!$f.find('#Title').validField())error.push('You must select a title.');
		if(!$f.find('#FirstName').validField({varType:'enumeratedNegated',enumerated:['First Name•']}))error.push('You must enter your first name.');
		if(!$f.find('#LastName').validField({varType:'enumeratedNegated',enumerated:['Last Name•']}))error.push('You must enter your last name.');
		if(!$f.find('#EmailAddress').validField({varType:'email'}))error.push('You must enter a valid email address.');
		
		var oCaptcha = captchaIsInvalid(this, "Enter Word Verification in box below", "Please enter the correct Word Verification as seen in the image"); 
		
		if(oCaptcha != '')
		{
			error.push(oCaptcha);
		}
		
		
		if(error.length > 0)
		{
			$e.preventDefault();
			alert(error.join('\n'));	
		} else {
			$f.addClass('submitted');
			
			/*
			alert('SUCCESS. Don\'t forget to enable the submission by removing the code below this line.');
			$e.preventDefault();	
			*/
		}
	});
	
	

	
});
