function go_einf() {
	document.location.href = "http://www.infoempresas.com.pt";
}
function mensaje(tipo, deno) {
	var mensaje = "";
	if (tipo == 1)
		mensaje = "las marcas disponibles";
	if (tipo == 2)
		tipo = 4;
	if (tipo == 3)
		mensaje = "o NIF";
	if (tipo == 4)
		mensaje = "todos os dados de contacto";

	alert("Registe-se de forma gratuita em www.eInforma.pt para ver " + mensaje + " assim como aceder a um relatório 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 a E-INFORMA, S.A. 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 e-Informa, S.A. o 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') {
		alert("mudei para sim");
		document.getElementById('controlPublicidad').value = '0';
	} else {
		alert("mudei para nao");
		document.getElementById('controlPublicidad').value = '3';
	}
}
function abreInfo_ML(prod, idioma) {
	abreInfo_ancla(prod, '', '1', idioma);
}

function abrirEjemplo(pagina) {
	// url="/servlet/app/portal/ENTP/prod/SHOW_PAGE_NO_FRAMES/pagina/nw_condiciones_generales_registro.html";
	url = pagina;//"/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 (document.frm.controlPublicidad.checked){
		document.frm.BPublicidadUsu.value='S';
	}
	else{
		document.frm.BPublicidadUsu.value=null;
	}

	
	if (verificaCamposPromo()) {
		if (document.getElementById('aceptar_condiciones').checked == false) {
			var respuesta = confirm('Para se registar, deverá aceitar\n' + 'as condições gerais.\n' + 'Clique em "Aceitar" se as tiver aceite.');
			if (respuesta == false) {
				document.frm.aceptar_condiciones.focus();
			} else if (respuesta == true) {
				document.frm.aceptar_condiciones.checked = true;
				document.frm.action = document.getElementById("direccion").value;
				document.frm.submit();
			}
		} else {
			document.frm.aceptar_condiciones.checked = true;
			//document.forReg.action = document.getElementById("direccion").value;
			//alert("publicidade "+document.forReg.BPublicidadUsu.value);
			document.frm.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("Tem que colocar um nome.");
		document.getElementById("promo_new_nombre").select();
		document.getElementById("promo_new_nombre").focus();
		return false;
	}
	/*if (document.getElementById("promo_new_apellidos").value == "") {
		alert("Tem que colocar um apelido.");
		document.getElementById("promo_new_apellidos").select();
		document.getElementById("promo_new_apellidos").focus();
		return false;
	}*/
	if (document.getElementById("promo_new_email").value == "") {
		alert("Endereço de e-mail incorrecto.");
		document.getElementById("promo_new_email").select();
		document.getElementById("promo_new_email").focus();
		return false;
	}
	if (!comprobarEmail2(document.getElementById("promo_new_email").value)) {
		alert("Endereço de e-mail incorrecto.");
		document.getElementById("promo_new_email").select();
		document.getElementById("promo_new_email").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("NIF inválido.");
		document.getElementById("promo_new_cif").select();
		document.getElementById("promo_new_cif").focus();
		return false;
	}
	if (!comprobarNumeroTelf(document.getElementById("promo_new_telefono").value)) {
		alert("Telefone incorrecto");
		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 esCIFoNIFd(obj) {return false;}
function esCIFoNIF(obj) {

	if(obj=='500520658'){
		return false;
	}
	if(obj=='000000000'){
		return false;
	}
	if(obj.length<9){
		return false;
	}
	
	var soma=0;
	var i=0;
	for (i=0;i<8;i++){
		var n= obj.substring(i,i+1);
		soma+=n*(9-i);
	}

	
	var temp = (soma*10)%11;
	
	if(temp == 10)
		temp=0;
	
	if(temp == obj.substring(8))
		return true;
	else
		return false;
}

function ifPublicidade(){
	if (document.forReg.pub_aux.checked){
		alert("checkado");
		document.forReg.BPublicidadUsu.value='S';
	}
	else{
		alert("nao checkado");
		document.forReg.BPublicidadUsu.value='N';
	}
}

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;
		}
	}
	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 accion1() {
	
	if (document.lista_empresas1.razonsocial.value != "") {
		var nombre = document.lista_empresas1.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_empresas1.action = "/Lista_empresas_" + cadena + ".html";
		document.lista_empresas1.submit();
	} else
		alert("Por favor, escreva o nome de uma empresa");
}
function accion2() {
	
	if (document.lista_empresas2.razonsocial.value != "") {
		var nombre = document.lista_empresas2.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_empresas2.action = "/Lista_empresas_" + cadena + ".html";
		document.lista_empresas2.submit();
	} else
		alert("Por favor, escreva o nome de uma empresa");
}

function formatea(input) {
	CARACTERES = ("ãõñÑáéíóúàèìòùâêîôûÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛüÜçÇ'/");
	CARACTERES_SUSTITUIR = ("aonNaeiouaeiouaeiouAEIOUAEIOUAEIOUuucC-");
	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
