$(document).ready( function(){
	
	var $validateForm;
	var valid = true;
	var requiredFields = new Array;
	
	// search through all the forms and retrieve the required validation one
	$('form').each(function(){
		//alert($(this).attr('name'))
		if($(this).attr('class') == 'ssrequired'){
			$validateForm = $(this);
			getRequiredField();
		}
	})
	
	function getRequiredField(){
		$('form.ssrequired input').each(function(){
			if($(this).attr('name') == 'Name'){
				requiredFields.push($(this));
			}
			if($(this).attr('name') == 'Phone'){
				requiredFields.push($(this));				
			}
			if($(this).attr('name') == 'Email'){
				requiredFields.push($(this));				
			}			
		});			
	}
	
	$validateForm.submit(function(){
		valid = true;						  
		var thisArray = new Array;
		jQuery.each(requiredFields, function(){			
			if($(this).val() == ""){				
				thisArray.push($(this).attr('name'))
				//alert("Please fill in the required fields ( "+ thisArray+ ") before submitting the form.")
				valid = false;
			}
		})
		if(valid == false){
			alert("Please fill in the required fields ( "+ thisArray+ " ) before submitting the form.")
		}
		return valid;
   });
	
});