function send_mail() {
	var form = document.getElementById('contact_form');
	var name = form.name;
	var email = form.email;
	var phone = form.teleph;
	var msg = form.msg;
	if (name.value != '' && phone.value !== '' && msg.value != '' && email.value != '') {
		if (!validarEmail(email)) {
			return false;
		}
		form.submit();
	} else {
		alert('Debe ingresar todos los datos correctamente');
	}
}

function pre_mail() {
	var form = document.getElementById('pre_form');
	var project = form.project;
	var applicant = form.applicant;
	var phone = form.phone;
	var email = form.email;
	var att_file = form.att_file;
	if (project.value != '' && att_file.value !== '' && phone.value !== '' && applicant.value != '' && email.value != '') {
		if (!validarEmail(email)) {
			return false;
		}
		form.submit();
	} else {
		alert('Debe ingresar todos los datos que estan marcados como obligatorios');
	}
}

function maq_mail() {
	var form = document.getElementById('maq_form');
	var project = form.project;
	var applicant = form.applicant;
	var phone = form.phone;
	var email = form.email;
	var att_file = form.att_file;
	var papel = form.text_papel;
	var text_imp = form.text_imp;
	if (project.value != '' && applicant.value != '' && phone.value !== '' && email.value != '' && att_file.value !== '' && papel.value != '' && text_imp.value != '') {
		if (!validarEmail(email)) {
			return false;
		}
		form.submit();
	} else {
		alert('Debe ingresar todos los datos que estan marcados como obligatorios');
	}
}

function dis_mail() {
	var form = document.getElementById('dis_form');
	var project = form.project;
	var applicant = form.applicant;
	var phone = form.phone;
	var email = form.email;
	var att_file = form.att_file;
	var req = form.req;
	if (project.value != '' && att_file.value !== '' && phone.value !== '' && req.value != '' && applicant.value != '' && email.value != '') {
		if (!validarEmail(email)) {
			return false;
		}
		form.submit();
	} else {
		alert('Debe ingresar todos los datos que estan marcados como obligatorios');
	}
}

function recommend_mail() {
	var form = document.getElementById('recommend_form');
	var name = form.name;
	var email = form.email;
	var tname = form.tname;
	var temail = form.temail;
	var from = form.from;
	if (name.value != '' && tname.value != '' && email.value != ''  && temail.value != '') {
		if (!validarEmail(email) || !validarEmail(temail)) {
			return false;
		}
		form.submit();
	} else {
		alert('Debe ingresar todos los datos correctamente');
	}
}


function validarEmail(cadena)  {
    var a = cadena.value;
    var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+.[A-Za-z0-9_.]+[A-za-z]$/;
        if ((a.length != 0) && (filter.test(a)))
            return true;
        else
            alert("Por favor, debe ingresar una direccion de correo valida");
        cadena.focus();
        return false;
}

function user_submit() {
	var form = document.getElementById('user_form');
	form.submit();
}