var cH = 0;


function comprobar(frm)
{
	if (frm.nombre.value == '')
	{
		alert("Debe introducir el nombre.");
		frm.nombre.focus();
		return false;
	}


	if ( frm.provincia.value == "")
	{
		alert("Debe introducir la provincia.");
		return false;
	}

	if (frm.email.value == "")
	{
		alert("Debe introducir el email.");
		frm.email.focus();
		return false;
	}

	if (frm.telefono.value.length==0) {
		alert("El teléfono es un campo obligatorio.");
		frm.telefono.focus();
		return false;
	}
	


document.frmalta.submit(); 
}


function Validaremail(email) {
    var caracteres = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.";
    var i;
    var pos_arroba = email.indexOf("@");
    var pos_ultimo_punto = email.lastIndexOf(".");
    var email_minus = email.toLowerCase();
    var login;
    
    if (pos_arroba == -1) {
        return false;
    }
    if (email_minus.indexOf("info@mercalia.eu") != -1){
        return false;
    }
    if (pos_ultimo_punto == -1) {
        return false;
    }
    if (email.charAt(pos_arroba+1)=='.') {
    	return false;
    }
    login = email.substring(0, pos_arroba);
    for(i=0;i<login.length;i++) {
        if (caracteres.indexOf(login.charAt(i)) == -1) {
	        return false;
        }
    }    
    valido = true;
    trozo = email.substring(1+pos_arroba, pos_ultimo_punto);
    for(i=0;i<trozo.length;i++) {
        if (caracteres.indexOf(trozo.charAt(i)) == -1) {
	        return false;
        }
    }    
    valido = true;
    trozo = email.substring(1+pos_ultimo_punto, email.length);    
    if ((trozo.length >= 2)&&(trozo.length <= 4)) {
        for(i=0;i<trozo.length;i++) {
            if (caracteres.indexOf(trozo.charAt(i)) == -1) {
		        return false;
            }
        }    
    } else {
        return false;
    }
    return true;

}   
