function cambiar_datosf(valor) {
	// alert(valor);
	if (valor != "") {
       document.form_alta.nombre_f.style.backgroundColor = '#808080' ;
       document.form_alta.apellidos_f.style.backgroundColor = '#808080' ;
       document.form_alta.empresa_f.style.backgroundColor = '#808080' ;
       document.form_alta.nif_f.style.backgroundColor = '#808080' ;
       document.form_alta.direccion_f.style.backgroundColor = '#808080' ;
       document.form_alta.cp_f.style.backgroundColor = '#808080' ;
       document.form_alta.poblacion_f.style.backgroundColor = '#808080' ;
       document.form_alta.provincia_f.style.backgroundColor = '#808080' ;
       document.form_alta.pai_codi_f.style.backgroundColor = '#808080' ;
       document.form_alta.email_f.style.backgroundColor = '#808080' ;
	
	   document.form_alta.nombre_f.disabled = true ;
	   document.form_alta.apellidos_f.disabled = true ;
       document.form_alta.empresa_f.disabled = true ;
       document.form_alta.nif_f.disabled = true ;
       document.form_alta.direccion_f.disabled = true ;
       document.form_alta.cp_f.disabled = true ;
       document.form_alta.poblacion_f.disabled = true ;
       document.form_alta.provincia_f.disabled = true ;
       document.form_alta.pai_codi_f.disabled = true ;
       document.form_alta.email_f.disabled = true ;
	}
	else {
	   document.form_alta.nombre_f.style.backgroundColor = '#EDEDED' ;
	   document.form_alta.apellidos_f.style.backgroundColor = '#EDEDED' ;
       document.form_alta.empresa_f.style.backgroundColor = '#EDEDED' ;
       document.form_alta.nif_f.style.backgroundColor = '#EDEDED' ;
       document.form_alta.cp_f.style.backgroundColor = '#EDEDED' ;
       document.form_alta.direccion_f.style.backgroundColor = '#EDEDED' ;
       document.form_alta.poblacion_f.style.backgroundColor = '#EDEDED' ;
       document.form_alta.provincia_f.style.backgroundColor = '#EDEDED' ;
       document.form_alta.pai_codi_f.style.backgroundColor = '#EDEDED' ;
       document.form_alta.email_f.style.backgroundColor = '#EDEDED' ;
	
	   document.form_alta.nombre_f.disabled = false ;
	   document.form_alta.apellidos_f.disabled = false ;
       document.form_alta.empresa_f.disabled = false ;
       document.form_alta.nif_f.disabled = false ;
       document.form_alta.direccion_f.disabled = false ;
       document.form_alta.cp_f.disabled = false ;
       document.form_alta.poblacion_f.disabled = false ;
       document.form_alta.provincia_f.disabled = false ;
       document.form_alta.pai_codi_f.disabled = false ;
       document.form_alta.email_f.disabled = false ;
	}
}

function validaralta() {
	// Aceptació de condicions de privacitat
    if(!document.form_alta.aceptocond.checked) {
        alert(aIdioma['DEBE_ACEPTAR_CONDICIONES']);
        return (false) ;
    }
	
    //Comprovar que empresa o Nom te valor
    if(document.form_alta.nombre.value.length == 0 && document.form_alta.empresa.value.length == 0) {
        alert(aIdioma['RELLENAR_NOMBRE_EMPRESA']) ;
        document.form_alta.nombre.focus() ;
        return (false) ;
    }

    if (!compruebaNoVacioCampo(document.form_alta.nif)) return(false) ;
    if (!compruebaNoVacioCampo(document.form_alta.direccion)) return(false) ;
    if (!compruebaNoVacioCampo(document.form_alta.cp)) return(false) ;    
    if (!compruebaNoVacioCampo(document.form_alta.poblacion)) return(false) ;
    if (!compruebaNoVacioCampo(document.form_alta.provincia)) return(false) ;
    if (!compruebaNoVacioCampo(document.form_alta.telefono)) return(false) ;
    //if (!compruebaNoVacioCampo(document.form_alta.respuesta)) return(false) ;    
    /*
    id (document.form_alta.pai_codi[document.form_alta.pai_codi.selectedIndex].value == 'ES' ? compruebaNoVacioCampo(document.form_alta.cp) && compruebaCodigoPostal(document.form_alta.cp) && isNumeric(document.form_alta.cp) && tieneLongitud(document.form_alta.cp, 5) : compruebaNoVacioCampo(document.form_alta.cp))
    && compruebaNoVacioCampo(document.form_alta.provincia)
    && compruebaNoVacioCampo(document.form_alta.telefono)
    && compruebaNoVacioCampo(document.form_alta.email)
    && compruebaNoVacioCampo(document.form_alta.respuesta)) ;
    if (!bResposta) return (false) ;
    */

    if (!isEmail(document.form_alta.email)) return(false) ;

    //Comprovar usuario
    passw = /^[0-9a-zA-Z\_\$\.\-\@#%ñÑçÇ]{6,32}$/ ;
    var resultado;
    resultado = document.form_alta.usuario.value.match(passw);
    if (resultado == null) {
        alert(aIdioma['USUARIO_INVALIDO']) ;
        document.form_alta.usuario.focus() ;
        return (false) ;
    }

    //Comprovaciones sobre claves
    if (document.form_alta.clave1.value != document.form_alta.clave2.value) {
        alert(aIdioma['CLAVES_IGUALES']) ;
        document.form_alta.clave1.focus() ;
        return (false) ;
    }

    resultado = document.form_alta.clave1.value.match(passw);
    if (resultado == null) {
        alert(aIdioma['CLAVE_INVALIDO']) ;
        document.form_alta.clave1.focus() ;
        return (false) ;
    }
    
    // comprobamos si hay datos de facturacion diferentes
    if (document.form_alta.facturacion.checked == false) {
        if(document.form_alta.nombre_f.value.length == 0 && document.form_alta.empresa_f.value.length == 0) {
            alert(aIdioma['RELLENAR_NOMBRE_EMPRESA_FACTURACION']) ;
            document.form_alta.nombre_f.focus() ;
            return (false) ;
        }

        if (!compruebaNoVacioCampo(document.form_alta.nif_f)) return(false) ;
        if (!compruebaNoVacioCampo(document.form_alta.direccion_f)) return(false) ;
        if (!compruebaNoVacioCampo(document.form_alta.poblacion_f)) return(false) ;
        if (!compruebaNoVacioCampo(document.form_alta.cp_f)) return(false) ;
        if (!compruebaNoVacioCampo(document.form_alta.provincia_f)) return(false) ;
    }

	v1 = document.form_alta.valcode.value ;
	v2 = document.form_alta.valcode2.value ;
	if (v1 != v2) {
		alert(aIdioma['CAMPO_VALIDACION_INCORRECTO']);
		return (false) ;
	}

    return (true);
}

function checkRecordarClave() {
        v1 = document.form1.usuario.value ;
    if (v1.length == 0) {
        alert(aIdioma['ENTRAR_USUARIO']) ;
        return (false) ;
    }
    else {
    	v1 = document.form1.valcode.value ;
    	v2 = document.form1.valcode2.value ;
    	if (v1 != v2) {
    		alert(aIdioma['CAMPO_VALIDACION_INCORRECTO']);
    		return (false) ;
    	}
    	
        return (true) ;
    }
}

function paisEsEstadosUnidos(sIP) {
	if (document.form_alta.pai_codi[document.form_alta.pai_codi.selectedIndex].value == 'US') {
		alert(aIdioma['DOMINIOS_SPAM_ILEGAL']+'\n\n'+aIdioma['DIRECCION_IP']+': '+sIP) ;
		document.form_alta.nombre_f.focus() ;
	}
}