function enviar(boton) {

	var f = boton.form;

if (f.nombre.value == "") return alert('Debe rellenar todos los campos marcados con *');
if (f.empresa.value == "") return alert('Debe rellenar todos los campos marcados con *');
if (f.provincia.value == "") return alert('Debe rellenar todos los campos marcados con *');
if (f.email.value == "") return alert('Debe rellenar todos los campos marcados con *');
if (f.comentarios.value == "") return alert('Debe rellenar todos los campos marcados con *');

	//Deshabilitar botón
	boton.disabled = true;
	var valor = boton.value;
	boton.value = 'Espere por favor...';

	//Envío
	new Ajax.Request('mail.php', {

		parameters: $('form1').serialize(true), 

		onSuccess: function(transport){
			var response = transport.responseText;
			if(response == '') {
				alert('El formulario se ha enviado correctamente');
				f.reset();
			} else {
				alert('Ha habido un error al enviar el formulario, por favor inténtelo de nuevo');
			}
			
			boton.disabled = false;
			boton.value = valor;
		},

		onFailure: function(){ 
			alert('Ha habido un error al enviar el formulario, por favor inténtelo de nuevo'); 
			boton.disabled = false;
			boton.value = valor;
		}
	});

}

function enviar_en(boton) {

	var f = boton.form;

if (f.nombre.value == "") return alert('Please fill the fields marked with *');
if (f.empresa.value == "") return alert('Please fill the fields marked with *');
if (f.provincia.value == "") return alert('Please fill the fields marked with *');
if (f.email.value == "") return alert('Please fill the fields marked with *');
if (f.comentarios.value == "") return alert('Please fill the fields marked with *');

	//Deshabilitar botón
	boton.disabled = true;
	var valor = boton.value;
	boton.value = 'Please wait...';

	//Envío
	new Ajax.Request('mail.php', {

		parameters: $('form1').serialize(true), 

		onSuccess: function(transport){
			var response = transport.responseText;
			if(response == '') {
				alert('The form has been send');
				f.reset();
			} else {
				alert('There was an error sending the form. Please try again');
			}
			
			boton.disabled = false;
			boton.value = valor;
		},

		onFailure: function(){ 
			alert('There was an error sending the form. Please try again'); 
			boton.disabled = false;
			boton.value = valor;
		}
	});

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

