function abrirVentana(url, nombre, width, height, resizable, status, scrollbars, toolbar) {
	var w = (screen.width - width) / 2;
	var h = (screen.height - height) / 2;

	var nombreVentan = window.open('', nombre, 'width=' + width + ',height=' + height + ',resizable=' + resizable + ',status=' + status + ',scrollbars=' + scrollbars + ',toolbar=' + toolbar + ',top=' + h + ',left=' + w);
	nombreVentan.document.location.href = url;
}
function abrirVentanaRelativa(url, nombre, width, height, resizable, status, scrollbars, toolbar) {
	var w = (screen.width - width) / 2;
	var h = (screen.height - height) / 2;

	var nombreVentan = window.open('', nombre, 'width=' + width + ',height=' + height + ',resizable=' + resizable + ',status=' + status + ',scrollbars=' + scrollbars + ',toolbar=' + toolbar + ',top=' + h + ',left=' + w);
	
	nombreVentan.document.location.href =document.location.protocol+"//"+document.location.host+url;
}

function abrirVentanaCompleta(url, nombre, width, height, resizable, status, scrollbars, toolbar, menubar, directories, fullscreen, titlebar) {
	// window.open(url,nombre,'width=' + width + ',height=' + height + ',resizable=' + resizable + ',status=' + status + ',scrollbars=' + scrollbars + ',toolbar=' + toolbar + ',menubar=' + menubar + ',directories=' + directories + ',fullscreen=' + fullscreen + ',titlebar=' + titlebar);
	var w = (screen.width - width) / 2;
	var h = (screen.height - height) / 2;
	var ventana = window.open('', nombre, 'width=' + width + ',height=' + height + ',resizable=' + resizable + ',status=' + status + ',scrollbars=' + scrollbars + ',toolbar=' + toolbar + ',menubar=' + menubar + ',directories=' + directories + ',fullscreen=' + fullscreen + ',titlebar=' + titlebar + ',top=' + h + ',left=' + w);
	ventana.document.location.href = url;
}
function abrirVentanaVacia(nombre, width, height, resizable, status, scrollbars, toolbar) {
	var w = (screen.width - width) / 2;
	var h = (screen.height - height) / 2;
	var nombreVentan = window.open('', nombre, 'width=' + width + ',height=' + height + ',resizable=' + resizable + ',status=' + status + ',scrollbars=' + scrollbars + ',toolbar=' + toolbar + ',top=' + h + ',left=' + w);
	nombreVentan.focus();
	// nombreVentan.document.location.href=url;
}
function abrirVentanaMailAmigo(url) {
	var w = screen.width;
	var h = screen.height;
	var xx = 498;
	var yy = (document.layers) ? 407 : 403;
	var x = (w / 2) - (xx / 2);
	var y = (h / 2) - (yy / 2);
	y_ventana = (h / 2) - (yy / 2) - 100;
	var parametros = 'resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '';
	var ventana = window.open(url, "_blank", parametros);
	ventana.focus();
}
/* Funcion que realiza una busqueda de un CIF o RAZON SOCIAL, actuando segun lo que recibe */
function search2en1(url) {
	var frm = document.lista_empresas;
	var cif_o_razonsocial;
	var IndexProv;
	var valorProv;
	var textoIntroducido = frm.razonsocial.value;
	// var paisConsultado = frm.pais.value;
	// alert(paisConsultado);
	// Casos: Espacio inicio texto
	// Espacio final texto.
	// Varios espacios concatenados.
	// Se elimina caracteres espacio del inicio y final. En JS no hay
	// funciones rtrim, trim y ltrim, por lo que usamos expresiones regulares
	inicioEspacio = /^ / // El ^ indica principio cadena
	finEspacio = / $/ // El $ indica final cadena
	variosEspacios = /[ ]+/g // El global (g) es xa obtener todas combinaciones posibles

	// Importante el orden de estas 3 sentencias, multiples espacios primero lo deja en uno
	// que luego puede ser, segun caso, que sea el de inicio de cadena o fin
	textoIntroducido = textoIntroducido.replace(variosEspacios, " ");
	textoIntroducido = textoIntroducido.replace(inicioEspacio, "");
	textoIntroducido = textoIntroducido.replace(finEspacio, "");

	if (esCIFoNIF(textoIntroducido)) {
		if (textoIntroducido != '') {
			url = url + '/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/' + textoIntroducido;
		}
	} else {
		if (textoIntroducido != '') {
			url = url + '/screen/SProducto/prod/PESQUISA_EMPRESAS/razonsocial/' + formatea(textoIntroducido);
			IndexProv = frm.provincia.selectedIndex;
			valorProv = frm.provincia.options[IndexProv].value;
			url = url + '/provincia/' + valorProv;
			// if(paisConsultado == 'PT') url = url+'/pais/PT';
		} else {
			var IndexProv = frm.provincia.selectedIndex;
			var valorProv = frm.provincia.options[IndexProv].value;
			url = url + '/prod/PESQUISA_EMPRESAS/prod_mostrar/ETIQUETA_EMPRESA/provincia/' + valorProv
		}
	}
	document.location.href = url;

}

/* Funcion que realiza una busqueda de un CIF o RAZON SOCIAL, actuando segun lo que recibe, cuando llama desde el CIF */
function search2en1cif(url) {
	var frm = document.busca_cif;
	var cif_o_razonsocial;
	var IndexProv;
	var valorProv;
	var textoIntroducido = frm.nif.value;

	// Casos: Espacio inicio texto
	// Espacio final texto.
	// Varios espacios concatenados.
	// Se elimina caracteres espacio del inicio y final. En JS no hay
	// funciones rtrim, trim y ltrim, por lo que usamos expresiones regulares
	inicioEspacio = /^ / // El ^ indica principio cadena
	finEspacio = / $/ // El $ indica final cadena
	variosEspacios = /[ ]+/g // El global (g) es xa obtener todas combinaciones posibles

	// Importante el orden de estas 3 sentencias, multiples espacios primero lo deja en uno
	// que luego puede ser, segun caso, que sea el de inicio de cadena o fin
	textoIntroducido = textoIntroducido.replace(variosEspacios, " ");
	textoIntroducido = textoIntroducido.replace(inicioEspacio, "");
	textoIntroducido = textoIntroducido.replace(finEspacio, "");

	if (esCIFoNIF(textoIntroducido)) {
		if (textoIntroducido != '') {
			url = url + '/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/' + textoIntroducido;
		}
	} else {
		if (textoIntroducido != '') {
			var frm2 = document.lista_empresas;
			url = url + '/screen/SProducto/prod/PESQUISA_EMPRESAS/razonsocial/' + formatea(textoIntroducido);
			IndexProv = frm2.provincia.selectedIndex;
			valorProv = frm2.provincia.options[IndexProv].value;
			url = url + '/provincia/' + valorProv;
		}
	}
	document.location.href = url;

}

function search(url) {
	var frm = document.lista_empresas;
	if (frm.razonsocial.value != '')
		url = url + '/razonsocial/' + formatea(frm.razonsocial.value);
	var IndexProv = frm.provincia.selectedIndex;
	var valorProv = frm.provincia.options[IndexProv].value;
	url = url + '/provincia/' + valorProv
	document.location.href = url;
}

function comprobarFormatoCIF(texto) {
	return (esCIFoNIF(texto));
}

function searchNifRazonSocial(url) {
	var frm = document.lista_empresas;
	var nif_o_razonsocial = frm.texto.value;
	var IndexSeleccionado = frm.prod.selectedIndex;
	var valorSeleccionado;
	var nuevoIndex;

	if (comprobarFormatoCIF(nif_o_razonsocial) == true) {
		nuevoIndex = 1;
	} else {
		nuevoIndex = 0;
	}
	valorSeleccionado = frm.prod.options[nuevoIndex].value;
	url = url + '/prod/' + valorSeleccionado;

	if (valorSeleccionado == "ETIQUETA_EMPRESA") {
		if (frm.texto.value != '') {
			url = url + '/nif/' + frm.texto.value;
		}

	} else {
		if (frm.texto.value != '')
			url = url + '/razonsocial/' + formatea(frm.texto.value);

		var IndexProv = frm.PROVINCIA.selectedIndex;
		var valorProv = frm.PROVINCIA.options[IndexProv].value;
		url = url + '/provincia/' + valorProv
	}
	document.location.href = url;
}

function searchRazonSocial(url) {
	var frm = document.buscar_razon_social;
	if (frm.razonsocial.value != '') {
		url = url + '/prod/PESQUISA_EMPRESAS/razonsocial/' + formatea(frm.razonsocial.value);
		var IndexProv = frm.provincia.selectedIndex;
		var valorProv = frm.provincia.options[IndexProv].value;
		url = url + '/provincia/' + valorProv;
		document.location.href = url
	}
}

function searchAvanzado(url) {
	var frm = document.lista_empresas;
	if (frm.razonsocial.value != '')
		url = url + '/razonsocial/' + formatea(frm.razonsocial.value);
	var IndexProv = frm.provincia.selectedIndex;
	var valorProv = frm.provincia.options[IndexProv].value;
	url = url + '/provincia/' + valorProv
	if (frm.calle.value != '')
		url = url + '/calle/' + formatea(frm.calle.value);
	if (frm.numerocalle.value != '')
		url = url + '/numerocalle/' + formatea(frm.numerocalle.value);
	if (frm.localidad.value != '')
		url = url + '/localidad/' + formatea(frm.localidad.value);
	if (frm.cpostal.value != '')
		url = url + '/cpostal/' + formatea(frm.cpostal.value);
	document.location.href = url;
}

function searchAdministrador(url) {
	var frm = document.busca_administradores;
	if (frm.nombre.value != '')
		url = url + '/nombre/' + formatea(frm.nombre.value);
	if (frm.apellidos.value != '')
		url = url + '/apellidos/' + formatea(frm.apellidos.value);
	document.location.href = url;
}

function formatea(input) {
	CARACTERES = ("ñÑáéíóúàèìòùâêîôûÁÉÍÓÚÀÈÌÒÙÂÊÎÔÛçÇ?\' /");
	CARACTERES_SUSTITUIR = ("nNaeiouaeiouaeiouAEIOUAEIOUAEIOUcC++++");
	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 limpia_(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;
}// limpia_
function limpiaB(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;
}// limpia_
function nueva_ventana(url) {
	var w = (screen.width - 500) / 2;
	var h = (screen.height - 500) / 2;
	var pp = window.open(url, popup, 'resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=500,screenX=10,screenY=10,height=500, top=' + h + ',left=' + w);
	pp.focus();
}

function nueva_ventanaNoPopup(url) {
	var w = (screen.width - 500) / 2;
	var h = (screen.height - 500) / 2;
	var pp = window.open(url, 'Ventana', 'resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=500,screenX=10,screenY=10,height=500, top=' + h + ',left=' + w);
	pp.focus();
}

function ayuda(popup) {
	var w = screen.width;
	var h = screen.height;
	var xx = 500;
	yy = 300;
	var x = (w / 2) - (xx / 2);
	var y = (h / 2) - (yy / 2) - 75;
	var pp = window.open('/templates/html/ayuda_' + popup + '.html', popup, 'resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '');
	pp.focus();
}

function ayuda_PDF(popup) {
	var w = screen.width;
	var h = screen.height;
	var xx = 500;
	yy = 350;
	var x = (w / 2) - (xx / 2);
	var y = (h / 2) - (yy / 2) - 75;
	var pp = window.open('/templates/html/n_web/ayuda_' + popup + '.html', popup, 'resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '');
	pp.focus();
}
function ayuda_PXR(popup) {
	var w = screen.width;
	var h = screen.height;
	var xx = 500;
	yy = 350;
	var x = (w / 2) - (xx / 2);
	var y = (h / 2) - (yy / 2) - 75;
	var pp = window.open('/templates/html/ayuda_' + popup + '.html', popup, 'resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '');
	pp.focus();
}

function comprobar(producto, theURL, estilo, precio, mostrar) {
	var winName = 'info3';
	var features = 'top=200,left=200,width=245,height=148,scrollbars=0,toolbar=0,resizable=0,menubar=0';
	if ((mostrar == 1) && (precio != 0) && (precio != -1)) {
		document.location.href = theURL + '/precio/' + precio + '/prod/AVISO_CONSUMO/prod_mostrar/' + producto + '/fromindex/0/estilo/' + estilo;
	} else {
		document.location.href = theURL;
	}
}

function comprobarPeq(producto, theURL, estilo, precio, mostrar) {
	var winName = 'info3';
	var features = 'top=200,left=200,width=245,height=148,scrollbars=0,toolbar=0,resizable=0,menubar=0';
	if ((mostrar == 1) && (precio != 0) && (precio != -1)) {
		document.location.href = theURL + '/precio/' + precio + '/prod/AVISO_CONSUMO_PEQ/prod_mostrar/' + producto + '/fromindex/0/estilo/' + estilo;
	} else {
		document.location.href = theURL;
	}
}
function comprobarTop(producto, theURL, estilo, precio, mostrar) {
	var winName = 'info3';
	var features = 'top=200,left=200,width=245,height=148,scrollbars=0,toolbar=0,resizable=0,menubar=0';
	if ((mostrar == 1) && (precio != 0) && (precio != -1)) {
		top.location.href = theURL + '/precio/' + precio + '/prod/AVISO_CONSUMO/prod_mostrar/' + producto + '/fromindex/0/estilo/' + estilo;

	} else {
		top.location.href = theURL;
	}
}
function abreInfo(prod) {
	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 win = window.open('/templates/html/ayuda_' + prod + '.html', 'windowshtml', 'resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '');
	win.focus();
}
function abreInfoNoLogo(prod) {
	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 win = window.open('/templates/html/ayuda_no_logo/ayuda_' + prod + '.html', 'windowshtml', 'resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '');
	win.focus();
}

function textClear(input) {
	if (input.value == input.defaultValue) {
		input.value = "";
	}
}

function textRestore(input) {
	if (input.value == "") {
		input.value = input.defaultValue;
	}
}

function abrirEjemplo(URL, winName, features) {
	var w = (screen.width - 666) / 2;
	var h = (screen.height - 535) / 2;
	var ventana = window.open(URL, winName, features + ',resizable=1,top=' + h + ',left=' + w);
	ventana.focus();
	// var w=(screen.width - 700)/2;
	// ventana.moveTo(w,0);
}

function asignarNombre() {
	fecha = new Date()
	window.name = fecha.getMilliseconds() + "" + fecha.getSeconds() + "" + fecha.getMilliseconds() - fecha.getSeconds();
}
function go(url) {
	document.location.href = url
}
function condiciones_generales() {
	if (document.formulario.condiciones.checked == false) {
		var respuesta = confirm('Para solicitar un informe internacional, debe previamente conocer\n' + 'las condiciones generales de acceso a este servicio.\n' + 'Haga clic en "Aceptar" si las ha leído y aceptado.');
		if (respuesta == false) {
			document.getElementById('zonacolor').style.color = "white";
			document.getElementById('zonacolor').style.backgroundColor = "red";
			document.getElementById('zonacolor').style.visibility = "visible";
		} else {
			document.formulario.condiciones.checked = true;
			document.getElementById('zonacolor').style.color = "blue";
			document.getElementById('zonacolor').style.backgroundColor = "white";
			document.formulario.submit();
		}
	} else {
		document.getElementById('zonacolor').style.color = "blue";
		document.getElementById('zonacolor').style.backgroundColor = "white";
		document.formulario.submit();
	}
}

function esCIFoNIF(obj) {
	if (obj.length = '10' && obj.substring(0, 1) == '0') {
		obj = obj.substring(1, obj.length);
	}
	if (obj.length = '10' && (obj.substring(1, 2) == ' ' || obj.substring(1, 2) == '-') || obj.substring(1, 2) == '.') {
		obj = obj.substring(0, 1) + obj.substring(2, obj.length);
	}
	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"));
}

// //////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////
// //Funciones que estaban en alta_contrato_tj.html, pero que pueden valer para mas//////////////
// //archivos y ademas que no conviene que sena vistos por el usuario////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////

// 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 validarEntero2(valor) {
	if (valor == 0 || valor == null || valor == '') {
		return true;
	} else {
		// Compruebo si es un valor numérico
		if (isNaN(valor)) {
			// entonces (no es numero) devuelvo el valor cadena vacia
			return true;
		} else {
			// En caso contrario (Si era un número) devuelvo el valor
			return false;
		}
	}
}

// FUNCIÓN que verifica que el cp introducido corresponde a un número y por tanto es un posible CP Válido
// Además este número para ser un CP válido de España ha de tener 5 números
/*
 * Función que se encarga de comprobar que el campo de texto contiene 5 caracteres. Se recorren todos los caracteres para ver que todos son enteros. Se parte de la base de que se trata de un código postal válido, y si la comprobación falla, se pone a false la variable correspondiente
 */
// RETORNA true o false
function comprobarPosibleCPvalido(cp_introducido) {
	var CPcorrecto = true;
	var cp_caracter;
	// habrá de estar compuesto por 5 caracteres
	if (cp_introducido.length != 5)
		CPcorrecto = false;
	else {
		for (var i = 0; i < 5; i++) {
			cp_caracter = cp_introducido.charAt(i);
			if (validarEntero(cp_caracter) == "") {
				CPcorrecto = false;
				break;
			}
		}
	}
	return CPcorrecto;
}

function limpiarTelefono(telefono) {
	var telf = telefono.value;
	var telefonoLimpio = "";
	for (var i = 0; i < telf.length; i++) {
		var ch = telf.substring(i, i + 1);
		if (validarEntero(ch) != "" && ch != " ") {
			telefonoLimpio = "" + telefonoLimpio + ch;
		}
	}
	telefono.value = telefonoLimpio;
	return telefonoLimpio;
}

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 cambiaTitulo(text) */
function cambiaTitulo(texto) {
	document.title = texto;
}

/*
 * FUNCIÓN comprobarEmail2(email) var email: Variable del tipo text Verifica que la dirección e-mail introducida es válida. Para ello, deberá contener el símbolo arroba (@) y que ninguno de los caracteres siguientes: ; / : < > * | ' & $ ! # ( ) [ ] { } ' " Sólo comprueba que el dato introducido no contenga estos valores
 */
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("spaml.com");
	falsos.push("mierdamail.com");
	falsos.push("trashymail.com");
	falsos.push("mailexpire.com");
	// falsos.push("asdf");

	var i = 0;
	for (i = 0; i < falsos.length; i++) {
		if (dominio.indexOf(falsos[i]) != -1)
			return false;
	}

	return true;
}

/*
 * FUNCIÓN comprobarFormatoCIF(var text) Comprueba que el formato del CIF es válido
 */
function comprobarFormatoCIF2(texto) {
	return true;
	var pares = 0, impares = 0, suma, ultima, ultimo_numero;
	var ultima_letra = new Array("J", "A", "B", "C", "D", "E", "F", "G", "H", "I");
	var xxx;

	texto = texto.toUpperCase();

	var regular = /^[ABCDEFGHKLMNPQS]\d\d\d\d\d\d\d[0-9,A-J]$/g;
	if (!regular.exec(texto))
		return false;

	ultima = texto.substr(8, 1);

	for (var cont = 1; cont < 7; cont++) {
		xxx = (2 * parseInt(texto.substr(cont++, 1))).toString() + 0;
		impares += parseInt(xxx.substr(0, 1)) + parseInt(xxx.substr(1, 1));
		pares += parseInt(texto.substr(cont, 1));
	}
	xxx = (2 * parseInt(texto.substr(cont, 1))).toString();
	impares += parseInt(xxx.substr(0, 1)) + parseInt(0 + xxx.substr(1, 1));

	suma = (pares + impares).toString();
	ultimo_numero = parseInt(suma.substr(suma.length - 1, 1));
	ultimo_numero = (10 - ultimo_numero).toString();
	if (ultimo_numero == 10)
		ultimo_numero = 0;
	if ((ultima == ultimo_numero) || (ultima == ultima_letra[ultimo_numero])) {
		return true;
	} else {
		return false;
	}
}

/*
 * FUNCIÓN comprobarFormatoCIF(var text) Comprueba que el formato del CIF es válido
 */

function comprobarFormatoNIF2(nif) {
	var dni = nif.substring(0, nif.length - 1)
	var letra1 = nif.charAt(nif.length - 1)
	if (!isNaN(letra1)) {
		return false;
	} else {
		cadena = "TRWAGMYFPDXBNJZSQVHLCKET";
		posicion = dni % 23;
		var letra = cadena.substring(posicion, posicion + 1);
		if (letra != letra1.toUpperCase()) {
			return false;
		}
	}
	return true;
}

/*
 * Con este script podremos validar la dirección de email, del lado del cliente. El código obliga que se ingrese un dirección correctamente: al estilo nombre@dominio.com o bien nombre@[ip]. Verificar si el email tiene el formato user@dominio.
 */

function comprobarEmail(emailStr) {
	emailStr = emailStr.replace(/^\s*|\s*$/g, "");
	/*
	 * La siguiente plantilla se usa par chequear que la dirección introducida sigue el formato user@domain. También se usará para separar el username del dominio
	 */
	var emailPat = /^(.+)@(.+)$/;
	/*
	 * Verificar la existencia de caracteres especiales que no queremos permitir en la dirección, que son los que no son válidos en los e-mail, es decir . ( ) < > @ , ; : \ " . [ ] # $ % ? ¿
	 */
	var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
	/*
	 * Verifica los caracteres que son válidos en una dirección de email It really states which chars aren't allowed
	 */
	var validChars = "\[^\\s" + specialChars + "\]";
	/*
	 * Se aplicará esta plantilla para el caso de direcciones de email con los nombres de usuarios que lleven " ", en cuyo caso no es posible reglas sobre qué caracteres son permitidos, Ejemplo: "nombre apellido "@e-informa.es
	 */
	var quotedUser = "(\"[^\"]*\")";
	/*
	 * Verifica si la dirección de email está representada con una dirección IP Válida EJEMPLO: e-informa@[127.0.0.1] ,es un e-mail válido, siendo los [] necesarios
	 */
	var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	/* Verificar caracteres inválidos */
	var atom = validChars + '+';
	/* Un word en el username. El word es tanto un átomo o un quotedUser */
	var word = "(" + atom + "|" + quotedUser + ")";
	/* Lo siguiente plantilla describe la estructura del nombre usuario */
	var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
	/* Descripción de un nombre de dominio, como el ipDomainPat mostrado arriba */
	var domainPat = new RegExp("^" + atom + "(\\." + atom + ")*$");
	/* La dirección user@domain la separamos en diferentes partes */
	var matchArray = emailStr.match(emailPat);
	if (matchArray == null) {
		// alert(i++);
		/*
		 * Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address.
		 */
		alert("Endereço de email incorrecto.");
		return false;
	}
	var user = matchArray[1];
	var domain = matchArray[2];
	// Si el user "user" es valido
	if (user.match(userPat) == null) {
		// Si no
		alert("Endereço de email incorrecto.")
		return false;
	}
	/* Si la dirección IP del e-mail es válida */
	var IPArray = domain.match(ipDomainPat);
	if (IPArray != null) {
		for (var i = 1; i <= 4; i++) {
			if (IPArray[i] > 255) {
				alert("IP de la dirección e-mail es invalida");
				return false;
			}
		}
		return true;
	}
	// El dominio es un nombre simbólico
	var domainArray = domain.match(domainPat);
	if (domainArray == null) {
		alert("El dominio no es válido.")
		return false;
	}
	/*
	 * Hasta aquí el dominio parece válido, pero tenemos que aseguraranos de que termina con 3 caracteres (como com, gov,edu) o en 2 caracteres (representan países como uk,nl), y que hay un hostname procediendo al nombr del dominio. Trocearemos el dominio para obtener el número de cuántas átomos lo componen
	 */
	var atomPat = new RegExp(atom, "g");
	var domArr = domain.match(atomPat);
	var len = domArr.length;
	if (domArr[domArr.length - 1].length < 2 || domArr[domArr.length - 1].length > 3) {
		alert("Endereço de email incorrecto.");
		return false;
	}
	// Asegurarse que hay un host name precediendo al dominio
	if (len < 2) {
		alert("Endereço de email incorrecto.");
		return false;
	}
	// La dirección de email ingresada es Válida si se llega hasta aquí =)
	return true;
}// End function comprobarEmail (emailStr) -->

/*******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
 * ************* ******** ******* ** * verifica los campos de un formulario para registrarse en una promocion. devuelve TRUE si son todos correctos, para poder hacer el submit
 ******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
function verificaCamposPromo() {

	//Nombre
	if (trim(document.getElementById("promo_new_nombre").value) == "") {
		alert("Indique o seu nome.");
		document.getElementById("promo_new_nombre").select();
		document.getElementById("promo_new_nombre").focus();
		return false;
	}
	
	// NIF
	document.getElementById("promo_new_cif").value = limpiarCIFNIF(document.getElementById("promo_new_cif").value);
	if(document.getElementById("promo_new_cif").value == '' || document.getElementById("promo_new_cif").value == null){
		alert("Indique o seu NIF");
		document.getElementById("promo_new_cif").select();
		document.getElementById("promo_new_cif").focus();
		return false;	
	}
	if(document.getElementById("promo_new_cif").value == '000000000'){
		alert("NIF inv\341lido.");
		document.getElementById("promo_new_cif").select();
		document.getElementById("promo_new_cif").focus();
		return false;	
	}
	if (!esNIFValido(document.getElementById("promo_new_cif").value)) {
		alert("NIF inv\341lido.");
		document.getElementById("promo_new_cif").select();
		document.getElementById("promo_new_cif").focus();
		return false;
	}
	/*
	if (document.getElementById("promo_new_cif").value.substring(1) == '00000000') {  // con el substring(1) lo que hace es coger los 8 ceros de la derecha, es decir, no permitiría tampoco registrarse con nifs como 100000000, 200000000, etc...
		alert("NIF inválido.");
		document.getElementById("promo_new_cif").select();
		document.getElementById("promo_new_cif").focus();
		return false;
	}
	*/
	//Email
	if(document.getElementById("promo_new_email").value == '' || document.getElementById("promo_new_email").value == null){
		alert("Indique o seu email");
		document.getElementById("promo_new_email").select();
		document.getElementById("promo_new_email").focus();
		return false;	
	}
	if (!comprobarEmail2(document.getElementById("promo_new_email").value)) {
		alert("Email inv\341lido.");
		document.getElementById("promo_new_email").select();
		document.getElementById("promo_new_email").focus();
		return false;
	}
	
	//Teléfono
	if(document.getElementById("promo_new_telefono").value == '' || document.getElementById("promo_new_telefono").value == null){
		alert("Indique o seu telefone");
		document.getElementById("promo_new_telefono").select();
		document.getElementById("promo_new_telefono").focus();
		return false;	
	}
	if (validarEntero2(document.getElementById("promo_new_telefono").value)) {
		alert("Telefone inv\341lido");
		document.getElementById("promo_new_telefono").select();
		document.getElementById("promo_new_telefono").focus();
		return false;
	}
	if (!comprobarNumeroTelf(document.getElementById("promo_new_telefono").value)) {
		alert("Telefone inv\341lido");
		document.getElementById("promo_new_telefono").select();
		document.getElementById("promo_new_telefono").focus();
		return false;
	}
	
	if (document.getElementById("alerta_subvenciones") != null && document.getElementById("alerta_subvenciones").checked) {
		var comboSector = document.getElementById("promo_new_sector").selectedIndex;
		var comboAmbito = document.getElementById("promo_new_ambito").selectedIndex;
		if (comboSector == 0 || comboAmbito == 0) {
			alert("Debe seleccionar una categoría y un ámbito de alertas de Subvenciones");
			return false;
		}
	}
	// if (document.getElementById("promo_new_empresa").value == ""){
	// alert("Debe rellenar el nombre de la empresa");
	// return false;
	// }
	// document.forms[0].submit();
	return true;
}

/*
 * Funcion que activa o desactiva el campo del ambito geografico en las pantallas de registro. Originalmente usada en la de infoayudas, la extendemos al resto de productos de registro gratuito.
 * 
 * Muestra y oculta un 'div' asociado a un checkbox.
 * 
 */
function activarText() {
	if (document.getElementById("chekGe").checked) {
		document.getElementById("capaGeog").style.visibility = 'visible';
		document.getElementById("capaGeog").style.display = '';
	} else {
		document.getElementById("capaGeog").style.visibility = 'hidden';
		document.getElementById("capaGeog").style.display = 'none';
	}
}
function muestraText() {
	if (document.getElementById("alerta_ambito").checked)
		document.getElementById("DatoGeograf").style.visibility = "visible";
	else
		document.getElementById("DatoGeograf").style.visibility = "hidden";
}
function trim(str) {
	while ('' + str.charAt(0) == ' ')
		str = str.substring(1, str.length);
	while ('' + str.charAt(str.length - 1) == ' ')
		str = str.substring(0, str.length - 1);
	return str;
}
// Valida que un campo no es nulo o vacio.Si es asi, muestra el mensaje en un alert
function verificaCampoRelleno(objeto, mensaje) {
	var valorObjeto = trim(objeto.value);
	if (valorObjeto == "") {
		alert(mensaje);
		objeto.focus();
		objeto.select();
		return "0";
	} else
		return "1"
}

// //////////////////////////////////////////////////////////////////////////////////////////////
// ////////////////////////////////FIN///////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////////////

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";
/* Fin pruebas */

// FUNCIONES PARA LA NUEVA WEB

/**
 * autofitIframe(id) funcion para ajustar automaticamente la altura de un iframe se la llama en el onLoad() ruben, 19-9-2006
 */
function autofitIframe(id) {
	if (parent.document.getElementById(id)) {
		if (id == 'frameAvisos') {
			var altura = this.document.body.scrollHeight + 31;
			parent.document.getElementById(id).style.height = altura + "px";
		} else
			parent.document.getElementById(id).style.height = this.document.body.scrollHeight + "px";
	}

}
function condiciones_generales_nw() {
	if (document.formulario_int.nombre_razon.value == "" || document.formulario_int.pais.value == "" || document.formulario_int.calle.value == "" || document.formulario_int.ciudad.value == "" || document.formulario_int.urgencia.value == "") {
		alert("Debe rellenar todos los campos obligatorios");
		return false;
	}

	if (document.formulario_int.condiciones.checked == false) {
		var respuesta = confirm('Para solicitar un informe internacional, debe previamente conocer\n' + 'las condiciones generales de acceso a este servicio.\n' + 'Haga clic en "Aceptar" si las ha leído y aceptado.');
		if (respuesta == false) {
			document.getElementById('zonacolor').style.color = "white";
			document.getElementById('zonacolor').style.backgroundColor = "EC2E38";
			document.getElementById('zonacolor').style.visibility = "visible";
		} else {
			document.formulario_int.condiciones.checked = true;
			document.getElementById('zonacolor').style.color = "blue";
			document.getElementById('zonacolor').style.backgroundColor = "white";
			document.formulario_int.submit();
		}
	} else {
		document.getElementById('zonacolor').style.color = "blue";
		document.getElementById('zonacolor').style.backgroundColor = "white";
		document.formulario_int.submit();
	}
}
function ayudan_PXR(popup) {
	var w = screen.width;
	var h = screen.height;
	var xx = 500;
	yy = 350;
	var x = (w / 2) - (xx / 2);
	var y = (h / 2) - (yy / 2) - 75;
	var pp = window.open('/templates/html/n_web/ayuda_' + popup + '.html', popup, 'resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '');
	pp.focus();
}
function comprobar_vigilancia(producto, theURL, estilo, precio, mostrar) {
	var winName = 'info3';
	var features = 'top=200,left=200,width=245,height=148,scrollbars=0,toolbar=0,resizable=0,menubar=0';
	if ((mostrar == 1) && (precio != 0) && (precio != -1)) {
		top.document.location.href = theURL + '/precio/' + precio + '/prod/AVISO_CONSUMO/prod_mostrar/' + producto + '/fromindex/0/estilo/' + estilo;
	} else {
		document.location.href = theURL;
	}
}
function abreInfo_ML(prod, idioma) {
	abreInfo_ancla(prod, '', '1', idioma);
}

function abreInfo_n(prod) {
	abreInfo_ancla(prod, '', '1', '');
}

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);
	var win = window.open('/templates/html/n_web/ajuda_' + prod + '.html#' + ancla, 'windowshtml', direccion);
	win.focus();
}
function abreInfoNoLogo(prod) {
	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 win = window.open('/templates/html/ayuda_no_logo/ayuda_' + prod + '.html', 'windowshtml', 'resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '');
	win.focus();
}

function abreInfoNoLogo_ML(prod, 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 win = window.open('/templates/html/ayuda_no_logo/ayuda_' + prod + '.html', 'windowshtml', 'resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,width=' + xx + ',height=' + yy + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + '');
	win.focus();
}

function muestraCapaInfoayudasRegistro() {
	if (document.getElementById("chekGe").checked == true) {
		document.getElementById("chekGe").value = "1";
		document.getElementById("DivInfoayudas").style.display = 'block';
		document.getElementById("DivInfoayudas").style.visibility = 'visible';
	} else {
		document.getElementById("chekGe").value = "0";
		if (document.getElementById("promo_new_ambito"))
			document.getElementById("promo_new_ambito").value = "";
		document.getElementById("DivInfoayudas").style.display = 'none';
		document.getElementById("DivInfoayudas").style.visibility = 'hidden';
	}
}

/**
 * imprime un div seleccionado ruben 8/11/2006
 */
function imprSelec(nombre) {
	document.getElementById("oculto").style.visibility = "visible";
	document.getElementById("oculto").style.display = "";
	noImpr = document.getElementById("NO_imprimir");
	if (noImpr) {
		noImpr.style.visibility = 'hidden';
		noImpr.style.display = 'none';
	}
	var ficha = document.getElementById(nombre);
	if (ficha == null) {
		window.print();
		return;
	}
	var ventimp = window.open(' ', 'popimpr');
	ventimp.document.write('<link rel="StyleSheet" href="/templates/css/n_web/estilos.css" type="text/css" />');
	ventimp.document.write(ficha.innerHTML);
	ventimp.document.close();
	ventimp.print();
	document.getElementById("oculto").style.visibility = "hidden";
	document.getElementById("oculto").style.display = "none";
	if (noImpr) {
		noImpr.style.visibility = 'visible';
		noImpr.style.display = '';
	}
	ventimp.close();
}

/*
 * ESTA FUNCTION ES PARA LA VENTANA DE INFORMACION, CUANDO SE PASA EL RATON POR EL 'SI' O EL 'NO' existe un div que se llama 'cuadro informa' en cada una de las paginas que esta oculto al final de cada pagina y se muestra al pasar el raton por encima del 'si' o el 'no' *PARAMETROS** - obj = es el objeto al que debemos asociar la capa - texto = testo que pondremos en el cuadro - ADAPTADA PARA INFOAYUDAS --> 3-1-07(ruben)
 */
function ventana_informa(obj, texto) {
	// esto le indica que si el parametro arriba no esta vacia el top del div debe ser de los pixel indicados en 'arriba'
	// alert(obj);
	// alert(texto);

	if (obj != '') {
		document.getElementById("cuadro_informa").style.top = findPosY(obj) - 100;
		document.getElementById("cuadro_informa").style.left = findPosX(obj);
	}

	// si mi div esta oculto lo muestro, si esta visible lo oculto, esto hace las veces del onmouseover y el onmouseout
	if (document.getElementById("cuadro_informa").style.visibility == "visible")
		document.getElementById("cuadro_informa").style.visibility = "hidden";
	else
		document.getElementById("cuadro_informa").style.visibility = "visible";

	document.getElementById("cuadro_informa").innerHTML = '<BR/><b>' + texto + '</b>';

}

// ENNCUENTRA LA POSICION Y DEL OBJETO QUE SE LE PASA COMO PARAMETRO
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y)
		curtop += obj.y;
	return curtop;
}
// ENNCUENTRA LA POSICION x DEL OBJETO QUE SE LE PASA COMO PARAMETRO
function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function escribeMail(eMail, nombreVentana) {

	elDiv = document.getElementById(nombreVentana);
	elDiv.ownerDocument.open();
	elDiv.ownerDocument.write(eMail);

	// alert(document.getElementById(nombreVentana).offsetHeight);
}
function reclaculaTamano(nombreVentana) {
	parent.document.getElementById('frameMensajes').style.height = document.getElementById(nombreVentana).scrollHeight;
}

function ve(_url) {
	var w = (screen.width - 650) / 2;
	var h = (screen.height - 400) / 2;

	var ventana = window.open(_url, 'tour', 'width=650,height=400,resize=no,status=yes,scrollbars=yes,toolbars=yes,top=' + h + ',left=' + w);
	ventana.focus();
	// var w=(screen.width - 650)/2;
	// ventana.moveTo(w,0);
}
function ve2(_url) {
	var w = (screen.width - 500) / 2;
	var h = (screen.height - 420) / 2;

	var ventana = window.open(_url, 'tour', 'width=500,height=420,resize=no,status=yes,scrollbars=yes,toolbars=yes,top=' + h + ',left=' + w);
	ventana.focus();
	// var w=(screen.width - 500)/2;
	// ventana.moveTo(w,0);
}

function esNIFValido(nif){
	var c;
    var checkDigit = 0;
 
	if(nif=='500520658'){
		return false;
	}
	if(nif=='000000000'){
		return false;
	}
	if(nif.length<9){
		return false;
	}

        //Obtem o primeiro número do NIF
        c = nif.charAt(0);
 
        //Verifica se o primeiro número é (1, 2, 5, 6, 8 ou 9)
        if(c == '1' || c == '2' || c == '5' || c == '6' || c == '8' || c == '9')
        {
            //Calculo do Digito de Controle
            checkDigit = c * 9;
            var i = 0;
            for(i = 2; i <= 8; i++)
            {
                checkDigit += nif.charAt(i-1) * (10-i);
            }
            checkDigit = 11 - (checkDigit % 11);
 
            //Se o digito de controle é maior que dez, coloca-o a zero
            if(checkDigit >= 10)
                checkDigit = 0;
 
            //Compara o digito de controle com o último numero do NIF
            //Se igual, o NIF é válido.
            if(checkDigit == nif.charAt(8))
                return true;
        }

    return false;
}
/*
 *Función para permitir sólo números en un campo de texto
 */
function acceptNum(evt){ 
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if (charCode < 48 || charCode > 57) {
		return false;
	}
	return true;
}

function rellenarBlancos(cadena, p){
	var blanco = 32; // espacio en blanco
	var slash = 47; // caracter "/"
	var i = 0;
	
	resultado = "";
	for(i; i<cadena.length; i++){
		if(cadena.charCodeAt(i) == blanco){
			resultado = resultado + "__";
		}
		else if(cadena.charCodeAt(i) == slash){
			resultado = resultado + "[]";
		}
		else if(cadena.charCodeAt(i) == 199){
			resultado = resultado + "|";
		}
		else if(cadena.charCodeAt(i) == 231){
			resultado = resultado + "{";
		}
		else{
			resultado = resultado + cadena.charAt(i);
		}
	}
	return resultado;
}
