(function($){
	$.fn.YDPsendContact = function(options) {


/*************************************************************************
	Configuration
*************************************************************************/

		var defaults = {
			php :	'inc/send_contact.php',
			formdiv : '#contact_form'
			};
		
		var options = $.extend(defaults,options);


/*************************************************************************
	Main Loop
*************************************************************************/

		$(options.formdiv + ' #submit').click(function() {
			
			$('.error').hide();

/*************************************************************************
	Validation
*************************************************************************/

			//Validate the name field
			if($('#name').val() == '')
			{
				$('#name_error').show();	
				$('#name').focus();
				return false;
			}
			
			//Validate the email field
			if($('#email').val() == '')
			{
				$('#email_error').show();	
				$('#email').focus();
				return false;
			}
			
			//Validate the message field
			if($('#message').val() == '')
			{
				$('#message_error').show();	
				$('#message').focus();
				return false;
			}

/*************************************************************************
	AJAX Submission
*************************************************************************/
			$('#submit').hide();
			
			$.ajax({
				type: 'POST',
				url: options.php,
				data: $('form').serialize(),
				success: function(data){
					$(options.formdiv).html(data);
				}
			});
			return false;
		});

/*************************************************************************
	End
*************************************************************************/
		return this;
	};
})(jQuery);
