function go_einf() {
	document.location.href = "http://www.informacion-empresas.com";
}
function mensaje(tipo, deno) {
	var mensaje = "";
	if (tipo == 1)
		mensaje = "las marcas disponibles";
	if (tipo == 2)
		tipo = 4;
	if (tipo == 3)
		mensaje = "el CIF";
	if (tipo == 4)
		mensaje = "todos los datos de contacto";	
	if (tipo == 5)
		mensaje = "la valoración de riesgo";	
	if (tipo == 6)
		mensaje = "los dirigentes y administradores";	
	if (tipo == 7)
		mensaje = "los accionistas";	
	if (tipo == 8)
		mensaje = "el total de activo";
	if (tipo == 9)
		mensaje = "el teléfono";
	if (tipo == 10)
		mensaje = "la dirección";
	if (tipo == 11)
		mensaje = "el fax";
	
	if(tipo==8 || tipo==7 || tipo==6 || tipo==5)
		alert("Regístrese de forma gratuita en www.einforma.com para acceder a un informe ampliado de \n" + deno);
	else
		alert("Regístrese de forma gratuita en www.eInforma.com para ver " + mensaje + " así como para acceder a un informe ampliado de \n" + deno);	
	
	document.getElementById("promo_new_nombre").focus();
}

function coletilla() {
	document.write('<tr><td colspan="3" valign="top" width="55%" bgcolor="#ffffff" STYLE="text-align:justify;padding-left:5px;padding-top:10px;padding-right:5px;"><div class="verdana9gris" STYLE="text-align:justify;"><font color="#AAAAAA">El contenido de la informaci&#243;n procede de la base de datos de INFORMA D&#38;B, S.A., de fuentes p&#250;blicas (Registro Mercantil, boletines oficiales, prensa econ&#243;mica, etc...),  y la informaci&#243;n es tratada y suministrada por INFORMA D&#38;B, S.A. En caso de encontrar cualquier dato que pueda ser susceptible de revisi&#243;n, por favor no dude en comunicarse con INFORMA D&#38;B, S.A, con el Dpto. de Atenci&#243;n al Cliente, en Avenida de la Industria, 32, Alcobendas, Madrid 28108 o en el tel&#233;fono 902 10 11 32. En todo caso, la informaci&#243;n que proporcionamos debe ser tenida en cuenta s&#243;lo como un elemento m&#225;s a considerar a la hora de adoptar decisiones comerciales y no debe por tanto determinar las mismas.</font><br /><br /></div></td></tr>');
}

function coletilla1() {
	document.write('<input type="checkbox" value="3" style="width:10px;height:10px;" name="controlPub" onclick="cambiaPub();" checked="checked" />&#160;Seleccione esta casilla si desea recibir ofertas promocionales por email de <font class="verdana10rojo"><b>e</b></font>Informa o de los sectores indicados en la cláusula 16 de las Condiciones');
}

function coletilla2(direccion) {
	document.write('<input type="checkbox" id="aceptar_condiciones" name="aceptar_condiciones"/>&#160;He leído y acepto las <a class="verdana9gris" href="javascript:abrirEjemplo();">Condiciones Generales</a>');
}

function cambiaPub() {
	if (document.getElementById('controlPublicidad').value == '3') {
		document.getElementById('controlPublicidad').value = '0';
	} else {
		document.getElementById('controlPublicidad').value = '3';
	}
}
function abreInfo_ML(prod, idioma) {
	abreInfo_ancla(prod, '', '1', idioma);
}

function abrirEjemplo() {
	// url="/servlet/app/portal/ENTP/prod/SHOW_PAGE_NO_FRAMES/pagina/nw_condiciones_generales_registro.html";
	url = "/templates/portales/entp/html/nw_condiciones_generales_registro.html";
	var w = (screen.width - 666) / 2;
	var h = (screen.height - 535) / 2;
	var ventana = window.open(url, 'info3', 'width=506,height=325,scrollbars=0,toolbars=0,top=' + h + ',left=' + w);
	ventana.focus();
}

function abreInfo_ancla(prod, ancla, scrollB, idioma) {
	var w = screen.width;
	var h = screen.height;
	var xx = 410;
	var yy = (document.layers) ? 404 : 400;
	var x = (w / 2) - (xx / 2);
	var y = (h / 2) - (yy / 2);
	y_ventana = (h / 2) - (yy / 2) - 100;
	var direccion = 'resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '';
	if (scrollB == '1') {
		direccion = direccion + ',scrollbars=1';
	}
	var win = window.open('/templates/html/n_web/' + idioma + '/ayuda_' + prod + '.html#' + ancla, 'windowshtml', direccion);
	win.focus();
}
function validacion() {
	if (verificaCamposPromo()) {
		if (document.getElementById('aceptar_condiciones').checked == false) {
			var respuesta = confirm('Para registrarse, debe previamente aceptar\n' + 'las condiciones generales.\n' + 'Haga clic en "Aceptar" si las ha leido y aceptado.');
			if (respuesta == false) {
				document.forReg.aceptar_condiciones.focus();
			} else if (respuesta == true) {
				document.forReg.aceptar_condiciones.checked = true;
				document.forReg.action = document.getElementById("direccion").value;
				document.forReg.submit();
			}
		} else {
			document.forReg.aceptar_condiciones.checked = true;
			document.forReg.action = document.getElementById("direccion").value;
			document.forReg.submit();
		}
	}
}

function local(direccion) {
	document.location.href = direccion;
}

function ejemplo() {
	// URL="/servlet/app/portal/ENTP/prod/SHOW_PAGE_NO_FRAMES/pagina/condiciones_uso_web.html";
	URL = "/templates/portales/entp/html/condiciones_uso_web.html";
	var wi = (screen.width - 700) / 2;
	var he = (screen.height - 535) / 2;
	var ventana = window.open(URL, 'info3', 'width=700,height=535,scrollbars=0,toolbars=0,resizable=1,top=' + he + ',left=' + wi);
	ventana.focus();

}

/*******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
 * ************* ******** ******* ** * verifica los campos de un formulario para registrarse en una promocion. devuelve TRUE si son todos correctos, para podes hacer el submit
 ******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
function verificaCamposPromo() {

	if (document.getElementById("promo_new_nombre").value == "") {
		alert("Debe rellenar el nombre.");
		document.getElementById("promo_new_nombre").select();
		document.getElementById("promo_new_nombre").focus();
		return false;
	}
	if (document.getElementById("promo_new_apellidos").value == "") {
		alert("Debe rellenar el apellido.");
		document.getElementById("promo_new_apellidos").select();
		document.getElementById("promo_new_apellidos").focus();
		return false;
	}
	document.getElementById("promo_new_cif").value = limpiarCIFNIF(document.getElementById("promo_new_cif").value);
	if (!esCIFoNIF(document.getElementById("promo_new_cif").value)) {
		alert("Debe rellenar el CIF/NIF y debe ser válido.\nEj: A00000000\nEj: 00000000A");
		document.getElementById("promo_new_cif").select();
		document.getElementById("promo_new_cif").focus();
		return false;
	}
	if (document.getElementById("promo_new_cif").value.substring(1) == '00000000') {
		alert("Debe rellenar el CIF/NIF y debe ser válido.");
		document.getElementById("promo_new_cif").select();
		document.getElementById("promo_new_cif").focus();
		return false;
	}
	if (!comprobarEmail2(document.getElementById("promo_new_email").value)) {
		alert("Debe rellenar el e-mail correctamente.\nEj: xxx@xxx.xx");
		document.getElementById("promo_new_email").select();
		document.getElementById("promo_new_email").focus();
		return false;
	}
	if (!comprobarNumeroTelf(document.getElementById("promo_new_telefono").value)) {
		alert("Debe rellenar correctamente el teléfono\nEj: 910000000");
		document.getElementById("promo_new_telefono").select();
		document.getElementById("promo_new_telefono").focus();
		return false;
	}
	return true;
}

var cadenaNumeros = "1234567890";
var errorCampoObligatorioVacio = "El campo NOMBRE_CAMPO no puede estar vacio";
var cadenaAlfabetoASCII = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var errorSoloNumerosNIF = "El campo NOMBRE_CAMPO sólo admite números en sus 8 primeras posiciones";
var errorSoloLetrasNIF = "El campo NOMBRE_CAMPO sólo admite letras sin acentos ni signos en su última posición";
var errorValidacionNIF = "El campo NOMBRE_CAMPO no contiene un NIF válido";
var errorCaracteresNoAdmitidosCIF = "El campo NOMBRE_CAMPO no contiene un CIF válido";
var errorValidacionCIF = "El campo NOMBRE_CAMPO no contiene un CIF válido";
var errorNoAdmiteEspacios = "El campo NOMBRE_CAMPO no admite espacios";
var errorNoAlcanzaLongitudMinima = "El campo NOMBRE_CAMPO ocupa LONGITUD_CAMPO posiciones y no alcanza la longitud mínima, establecida en LONGITUD_CORRECTA posiciones";
var errorExcedeLongitudMaxima = "El campo NOMBRE_CAMPO ocupa LONGITUD_CAMPO posiciones y excede la longitud máxima, establecida en LONGITUD_CORRECTA posiciones";
var cambioLogin = "El cambio de E-Mail implica el cambio de Login.\nRecibirá un mail con el nuevo login.\nA continuación se desconectará.\nDesea continuar?";
var vacio = "vacío";
var Poblacion = "Población";
var Telefono = "Teléfono";

function esCIFoNIF(obj) {
	if (obj.lenght = '10' && obj.substring(0, 1) == '0') {
		obj = obj.substring(1, obj.lenght);
	}
	if (obj.lenght = '10' && (obj.substring(1, 2) == ' ' || obj.substring(1, 2) == '-') || obj.substring(1, 2) == '.') {
		obj = obj.substring(0, 1) + obj.substring(2, obj.lenght);
	}
	return (esNIF(obj) || esCIF(obj));
}

function limpiarCIFNIF(obj) {
	var retorno = '';
	var i = 0;
	for (i = 0; i < obj.length; i++) {
		if ((obj.charAt(i) != ' ') && (obj.charAt(i) != '-') && (obj.charAt(i) != '.') && (obj.charAt(i) != '/')) {
			retorno += obj.charAt(i);
		}
	}

	return retorno;
}

function esNIF(obj) {
	return isNIF(obj, 'NIF', true, false, false);
}
function esCIF(obj) {
	return isCIF(obj, 'CIF', true, false, false);
}
function isNIF(obj, nom, obl, msg, foc) {
	var args = isNIF.arguments;
	var cad = getInputString(obj);
	var errors = new Array();
	if ((obl == false) && (cad == "")) {
		return processErrors(obj, msg, foc, errors);
	}
	if (obl != null) {
		errors = addErrors(checkCompulsory(cad, nom, obl), errors);
	}
	errors = addErrors(checkSpaces(cad, nom, false), errors);
	errors = addErrors(checkMinLength(cad, nom, 2), errors);
	errors = addErrors(checkMaxLength(cad, nom, 9), errors);
	if (errors.length == 0) {
		var check = true;
		var numero = cad.substring(0, cad.length - 1);
		var extran = cad.substring(0, 1);
		if ((extran == 'X') || (extran == 'x')) {
			numero = cad.substring(1, cad.length - 1);
		}
		var letra = cad.substring(cad.length - 1, cad.length);
		errors = addErrors(checkInString(numero, nom, cadenaNumeros, errorSoloNumerosNIF), errors);
		errors = addErrors(checkInString(letra, nom, cadenaAlfabetoASCII, errorSoloLetrasNIF), errors);
		if (parseInt(numero, 10) == 0) {
			check = false;
		}
		var index = parseInt(numero, 10) % 23;
		var letrasNIF = new Array('T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E', 'T');
		if (letra.toUpperCase() != letrasNIF[index]) {
			check = false;
		}
		if (!check) {
			errors[errors.length] = changeMsg(errorValidacionNIF, nom, null, null, null, null);
		}
	}
	return processErrors(obj, msg, foc, errors);
}

function isCIF(obj, nom, obl, msg, foc) {
	var args = isCIF.arguments;
	var cad = getInputString(obj);
	var errors = new Array();
	if ((obl == false) && (cad == "")) {
		return processErrors(obj, msg, foc, errors);
	}
	if (obl != null) {
		errors = addErrors(checkCompulsory(cad, nom, obl), errors);
	}
	errors = addErrors(checkSpaces(cad, nom, false), errors);
	errors = addErrors(checkMinLength(cad, nom, 9), errors);
	errors = addErrors(checkMaxLength(cad, nom, 9), errors);
	errors = addErrors(checkInString(cad, nom, cadenaNumeros + cadenaAlfabetoASCII, errorCaracteresNoAdmitidosCIF), errors);
	if (errors.length == 0) {
		var check = false;
		cad = cad.toUpperCase();
		var letrasCIF = new Array('J', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I');
		var sumap = 0;
		var sumai = 0;
		var p;
		var r;
		var dc;
		sumap = parseInt(cad.substring(2, 3)) + parseInt(cad.substring(4, 5)) + parseInt(cad.substring(6, 7));
		for (n = 1; n <= 8; n++) {
			p = 2 * parseInt(cad.substring(n, n + 1));
			if (p > 9) {
				sumai += parseInt((p / 10), 10) + (p % 10);
			} else {
				sumai += p;
			}
			n++;
		}
		r = sumap + sumai;
		dc = r % 10;
		dc = 10 - dc;
		if (dc == 10) {
			dc = 0;
		}
		if (!isDigit(cad.charAt(8))) {
			if (letrasCIF[dc] == cad.charAt(8).toUpperCase()) {
				check = true;
			}
		} else {
			if (dc == parseInt(cad.substring(8, 9))) {
				check = true;
			}
		}
		if (!check) {
			errors[errors.length] = changeMsg(errorValidacionCIF, nom, null, null, null, null);
		}
	}
	return processErrors(obj, msg, foc, errors);
}
function processErrors(obj, msg, foc, errors) {
	var cad = "";
	if (errors.length > 0) {
		for (n = 0; n < errors.length; n++) {
			cad += errors[n];
			if (n != errors.length - 1) {
				cad += "\n";
			}
		}
		if (msg == true) {
			alert(cad);
		}
		if ((foc == true) && (obj != null)) {
			obj.focus();
		}
		if (msg == null) {
			return errors;
		}
		return false;
	}
	if (msg == null) {
		return errors;
	}
	return true;
}
function changeMsg(descError, nom, longitud, longitudCorrecta, valor, valorCorrecto) {
	var cad = descError.replace(/NOMBRE_CAMPO/g, nom);
	if (longitud != null) {
		cad = cad.replace(/LONGITUD_CAMPO/g, longitud)
	}
	if (longitudCorrecta != null) {
		cad = cad.replace(/LONGITUD_CORRECTA/g, longitudCorrecta)
	}
	if (valor != null) {
		cad = cad.replace(/VALOR_CAMPO/g, valor)
	}
	if (valorCorrecto != null) {
		cad = cad.replace(/VALOR_CORRECTO/g, valorCorrecto)
	}
	return cad;
}
function getInputString(obj) {
	var cad = ""
	if (obj.value) {
		cad = obj.value;
	} else {
		if (obj.value == "") {
			cad = obj.value
		} else {
			cad = obj;
		}
	}
	return cad;
}

function checkInString(cad, nom, cadComparar, cadError) {
	var errors = new Array();
	var check = true;
	for (n = 0; n < cad.length; n++) {
		for (m = 0; m < cadComparar.length; m++) {
			if (cad.charAt(n) == cadComparar.charAt(m)) {
				break;
			}
		}
		if (m == cadComparar.length) {
			check = false;
			break;
		}
	}
	if (!check) {
		errors[errors.length] = changeMsg(cadError, nom, null, null, null, null);
	}
	return errors;
}
function checkCompulsory(cad, nom, obl) {
	var errors = new Array()
	if ((obl == true) && (cad == "")) {
		errors[errors.length] = changeMsg(errorCampoObligatorioVacio, nom, null, null, null, null);
	}
	return errors;
}

function checkSpaces(cad, nom, spa) {
	var errors = new Array();
	if (spa == false) {
		for (n = 0; n < cad.length; n++) {
			if (cad.charAt(n) == " ") {
				errors[errors.length] = changeMsg(errorNoAdmiteEspacios, nom, null, null, null, null);
				break;
			}
		}
	}
	return errors;
}

function checkMinLength(cad, nom, min) {
	var errors = new Array();
	if (cad.length < min) {
		errors[errors.length] = changeMsg(errorNoAlcanzaLongitudMinima, nom, cad.length, min, null, null);
	}
	return errors;
}

function checkMaxLength(cad, nom, max) {
	var errors = new Array();
	if (cad.length > max) {
		errors[errors.length] = changeMsg(errorExcedeLongitudMaxima, nom, cad.length, max, null, null);
	}
	return errors;
}
function addErrors(errorsArr, errorsTotalArr) {
	for (n = 0; n < errorsArr.length; n++) {
		errorsTotalArr[errorsTotalArr.length] = errorsArr[n];
	}
	return errorsTotalArr;
}
function isDigit(car) {
	return ((car >= "0") && (car <= "9"));
}

function comprobarEmail2(email) {
	email = email.toLowerCase();
	if (email.indexOf('@', 0) == -1 || email.indexOf('.', 0) == -1 || email.indexOf(' ', 0) != -1 || email.indexOf('/', 0) != -1 || email.indexOf(';', 0) != -1 || email.indexOf('<', 0) != -1 || email.indexOf('>', 0) != -1 || email.indexOf('*', 0) != -1 || email.indexOf('|', 0) != -1 || email.indexOf('`', 0) != -1 || email.indexOf('&', 0) != -1 || email.indexOf('$', 0) != -1 || email.indexOf('!', 0) != -1 || email.indexOf('"', 0) != -1 || email.indexOf('¡', 0) != -1 || email.indexOf('%', 0) != -1 || email.indexOf('#', 0) != -1 || email.indexOf('(', 0) != -1 || email.indexOf('(', 0) != -1 || email.indexOf('=', 0) != -1 || email.indexOf('ñ', 0) != -1 || email.indexOf('Ñ', 0) != -1 || email.indexOf('á', 0) != -1 || email.indexOf('à', 0) != -1 || email.indexOf('é', 0) != -1 || email.indexOf('è', 0) != -1 || email.indexOf('í', 0) != -1 || email.indexOf('ì', 0) != -1 || email.indexOf('ó', 0) != -1 || email.indexOf('ò', 0) != -1 || email.indexOf('ú', 0) != -1 || email.indexOf('ù', 0) != -1 || email.indexOf(':', 0) != -1 || email.indexOf(';', 0) != -1 || email.indexOf('..', 0) != -1 || email.indexOf('@@', 0) != -1 || email.indexOf("asdf") != -1 || email.indexOf('@', 0) == 0 || email.indexOf('@.', 0) != -1 || email.indexOf('.@', 0) != -1 || email.indexOf("xxx@xxx.xx") != -1 || email.indexOf(',', 0) != -1) {
		// alert("Email Invalido");
		return false;
	}
	if (compruebaDominioMail(email)) {
		// alert("Email Valido");
		return true;
	} else {
		return false;
	}
}

/**
 * comprueba que el email no sea de uno de los dominios invalidos deinidos
 */
function compruebaDominioMail(email) {
	if (email.indexOf("asdf") != -1)
		return false;

	var dominio = email.substring(email.indexOf('@'));

	var falsos = new Array();
	falsos.push("nobulk");
	falsos.push("spamfree24.info");
	falsos.push("spamfree24.net");
	falsos.push("spamfree24.com");
	falsos.push("spamfree24.org");
	falsos.push("nullbox.info");
	falsos.push("inbox2.info");
	falsos.push("gorillaswithdirtyarmpits");
	falsos.push("maileater");
	falsos.push("guerrillamail");
	falsos.push("pookmail");
	falsos.push("mailinator");
	falsos.push("jetable");
	falsos.push("spambox");
	falsos.push("temporaryinbox");
	falsos.push("bugmenot");
	falsos.push("tempinbox");
	falsos.push("spaml");
	falsos.push("spamgourmet");
	falsos.push("spambob");
	falsos.push("spamday");
	falsos.push("temporaryinbox");
	falsos.push("spammotel");
	// falsos.push("asdf");

	var i = 0;
	for (i = 0; i < falsos.length; i++) {
		if (dominio.indexOf(falsos[i]) != -1)
			return false;
	}

	return true;
}
function comprobarNumeroTelf(telefono) {

	var telf = telefono;
	if (validarEntero(telf) == "")
		return false;
	if (telf.length < 9)
		return false;
	for (var i = 0; i < telf.length; i++) {
		var ch = telf.substring(i, i + 1);
		if (ch < "0" || ch > "9") {
			return false;
		}
		if (i == 0 && telf.length == 9) {
			if (ch != "6" && ch != "9") {
				return false;
			}
		}
	}
	return true;
}

// FUNCIÓN encargada de ver que es un entero.
function validarEntero(valor) {
	if (valor == 0) {
		return valor;
	} else {
		// intento convertir a entero.
		// si era un entero no le afecta, si no lo era lo intenta convertir
		valor = parseInt(valor);

		// Compruebo si es un valor numérico
		if (isNaN(valor)) {
			// entonces (no es numero) devuelvo el valor cadena vacia
			return "";
		} else {
			// En caso contrario (Si era un número) devuelvo el valor
			return valor;
		}
	}
}

function textClear(input) {
	if (input.value == input.defaultValue) {
		input.value = "";
	}
}
function textClear2(uno, dos) {
	valor1 = document.getElementById(uno);
	valor2 = document.getElementById(dos);
	if (valor1.value == valor1.defaultValue) {
		document.getElementById("acc").value = "1";
		valor1.value = "";
		valor2.value = "";
	}
}

function textRestore2(uno, dos) {
	valor1 = document.getElementById(uno);
	valor2 = document.getElementById(dos);
	if (valor1.value == "") {
		document.getElementById("acc").value = "0";
		valor1.value = valor1.defaultValue;
		valor2.value = valor2.defaultValue;
	}
}
function textRestore(input) {
	if (input.value == "") {
		input.value = input.defaultValue;
	}
}

function cambiaColor(posicion, nombre) {
	var nombrenuevo;
	switch (posicion) {
		case '0' : // off
			nombrenuevo = nombre.substr(0, nombre.length - 1);
			for (var i = 0; i < 3; i++) {
				document.getElementById(nombrenuevo + i).className = 'box';
			}
			break;
		case '1' : // on
			nombrenuevo = nombre.substr(0, nombre.length - 1);
			for (var i = 0; i < 3; i++) {
				document.getElementById(nombrenuevo + i).className = 'box1';
			}
			break;
	}
}

function accion() {
	document.getElementById("razonsocial").value = trimBuscador(eliminaCaracteresEspeciales(document.getElementById("razonsocial").value));
	if (document.getElementById("razonsocial").value != "") {
		var nombre = document.getElementById("razonsocial").value;
		nt = new String("");
		nc = new String("");
		for (var q = 0; q < nombre.length; q++) {
			var nombreDes = nombre.charAt(q);
			if (nombre.charAt(q) == ' ')
				nt += '-';
			else if (nombreDes == '&#38;' || nombreDes == '&#33;' || nombreDes == '&#34;' || nombreDes == '&#35;' || nombreDes == '&#36;' || nombreDes == '&#37;' || nombreDes == '&#38;' || nombreDes == '&#40;' || nombreDes == '&#41;' || nombreDes == '&#42;' || nombreDes == '&#43;' || nombreDes == '&#44;' || nombreDes == '&#47;' || nombreDes == '&#58;' || nombreDes == '&#59;' || nombreDes == '&#60;' || nombreDes == '&#61;' || nombreDes == '&#62;' || nombreDes == '&#63;' || nombreDes == '&#91;' || nombreDes == '&#93;' || nombreDes == '&#94;' || nombreDes == '&#123;' || nombreDes == '&#96;' || nombreDes == '&#180;' || nombreDes == '&#93;' || nombreDes == "'" || nombreDes == '?' || nombreDes == '¿' || nombreDes == '|' || nombreDes == '&#92;' || nombreDes == '&') {
				nt += nt.substr(q + 1, 1);
			} else
				nt += nombre.charAt(q);
		}

		var cadena = formatea(nt);

		document.lista_empresas.action = "/Listado_empresas_" + cadena + ".html";
		document.lista_empresas.submit();
	} else
		alert("Por favor, escriba un nombre de empresa");
}

function formatea(input) {
	CARACTERES = ("ñÑáéíóúàèìòùâêîôûÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛüÜçÇ'/");
	CARACTERES_SUSTITUIR = ("nNaeiouaeiouaeiouAEIOUAEIOUAEIOUuucC-");
	var cadena = "";
	var found = false;
	for (var i = 0; i < input.length; i++) {
		var chr = input.charAt(i);
		found = false;
		for (var j = 0; j < CARACTERES.length; j++) {
			if (chr == CARACTERES.charAt(j)) {
				cadena += CARACTERES_SUSTITUIR.charAt(j);
				found = true;
			}// if
		}// for j
		if (!found) {
			cadena += chr;
		}// if
	}// for i
	return cadena;
}// formatea

function formatea(input) {
	CARACTERES = ("ñÑáéíóúàèìòùâêîôûÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛüÜçÇ'/");
	CARACTERES_SUSTITUIR = ("nNaeiouaeiouaeiouAEIOUAEIOUAEIOUuucC-");
	var cadena = "";
	var found = false;
	for (var i = 0; i < input.length; i++) {
		var chr = input.charAt(i);
		found = false;
		for (var j = 0; j < CARACTERES.length; j++) {
			if (chr == CARACTERES.charAt(j)) {
				cadena += CARACTERES_SUSTITUIR.charAt(j);
				found = true;
			}// if
		}// for j
		if (!found) {
			cadena += chr;
		}// if
	}// for i
	return cadena;
}// formatea

/* Nos permite eliminar tanto espacios en blanco como caracteres especiales en los extremos */
function trimBuscador(cadena) {
	for(i=0; i<cadena.length; ) {
		var ascii = cadena.charCodeAt(i);
		/** 
		 * CODIGO ASCII:
		 * 		48-57:  Numeros del 0 al 9
		 * 		65-90:  Letras mayusculas de la A a la Z
		 * 		97-122: Letras minusculas de la A a la Z
		 * **/
		if(cadena.charAt(i) == " ")
			cadena=cadena.substring(i+1, cadena.length);
		else if ( ((ascii < 48) || (ascii > 57)) && ((ascii < 65) || (ascii > 90)) && ((ascii < 97) || (ascii > 122)))
			cadena=cadena.substring(i+1, cadena.length);
		else
			break;
	}

	for(i=cadena.length-1; i>=0; i=cadena.length-1)	{
		if(cadena.charAt(i) == " ")
			cadena=cadena.substring(0,i);
		else
			break;
	}
	
	return cadena;
}

function eliminaCaracteresEspeciales(input) {
	CARACTERES = ("*<>?ºª!\"#$%&/()=^+.:,;-_{}¨[]@");
	CARACTERES_SUSTITUIR = ("                               ");
	var cadena = "";
	var found = false;
	for (var i = 0; i < input.length; i++) {
		var chr = input.charAt(i);
		found = false;
		for (var j = 0; j < CARACTERES.length; j++) {
			if (chr == CARACTERES.charAt(j)) {
				cadena += CARACTERES_SUSTITUIR.charAt(j);
				found = true;
			}// if
		}// for j
		if (!found) {
			cadena += chr;
		}// if
	}// for i
	return cadena;
}
