
function onSuccess(data, status)
{
	data = $.trim(data);
	$("#notification").text(data).fadeOut(1500);
	$("#imgSend").hide();
	$('#contact')[0].reset();
}

function onError(data, status)
{
	// manejo de errores
	$("#imgSend").hide();
}       

function onComplete(data, status) {
	$("#notification").text(data);
}

$(document).ready(function() {
	$("#button_submit").click(function(){
	
		var empresa = $("input#empresa").val();
		if (empresa == "") {
			$('#notification').show().html("Ingrese nombre de empresa");
			$("#notification").hide().fadeIn(1500);
			$("input#empresa").focus();
			return false;
		}
	
		var mail = $("input#email").val();
		if (mail == "") {
			$('#notification').show().html("Ingrese direccion de e-mail");
			$("#notification").hide().fadeIn(1500);
			$("input#email").focus();
			return false;
		}
		
		var telefono = $("input#tel").val();
		if (telefono == "") {
			$('#notification').show().html("Ingrese telefono para contacto");
			$("#notification").hide().fadeIn(1500);
			$("input#tel").focus();
			return false;
		}
		$("#notification").html("");
		$("#imgSend").show();
		$("#notification").show();
		$("#notification").append("Enviando...").fadeIn(1000);
		
		var formData = $("#contact").serialize();
		
		$.ajax({
			type: "POST",
			url: "contenido/contact_send.asp",
			cache: false,
			data: formData,
			success: onSuccess,
			error: onError,
			complete: onComplete
		});
		
		return false;
	});
});
