$(function(){
	$("#send").click(function(){
		var data = $("#contact_form").serialize();
		
		$.ajax({
			url: 'includes/valid_form.php',
			type: 'POST',
			data: data,
			dataType: 'xml',
			
			success: function(xml){
				var exito = $(xml).find('status').attr('id');
				if(exito == -1){
					var errors="This information is required:\n\n";
					$(xml).find('errors').each(function(){
						var id = $(this).find('type').attr('id');
						errors = errors + $(this).find('type').text();
					});
					alert(errors);
				}
				else {
					alert("Information was submited, Thank You!");
					document.getElementById("contact_form").reset();
				}
			},
			error: function(xhr, status, error){
				alert("Sorry: An Error Occurred During Submition. Try Again Later.");
			}
		});
	});
});
