// Navegador
var ie = document.all ? 1 : 0;
var ns = document.layers ? 1 : 0;
// Popups
//------------------------------------------------------------------------------------------------
var ventana;
function abrePop(cual, nombre, alto, ancho, ajustable, scroll) {
	var donde_x, donde_y;
	donde_x = (screen.width - ancho) / 2;
	donde_y = (screen.height - alto) / 2;
	if (ie) {
		ventana = window.open(cual, nombre, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars='+scroll+', resizable='+ajustable+', copyhistory=no, width='+ancho+', height='+alto+', top='+donde_y+', left='+donde_x+'');
	} else if (ns) {
		ventana = window.open(cual, nombre, 'width='+ ancho +', height='+ alto +', location=no,toolbar=no, directories=no, menubar=no, resizable='+ajustable+', scrollbars='+ scroll +', status=no, top='+donde_y+', left='+donde_x+'');
	} else {
		ventana = window.open(cual, nombre, 'left='+ donde_x +', top='+ donde_y +', width='+ ancho +', height='+ (alto+5) +', location=no, toolbar=no, directories=no, resizable='+ ajustable +', scrollbars='+ scroll +', status=no');
	}
	ventana.focus();
}

// función GENÉRICA para cualquier formulario
//------------------------------------------------------------------------------------------------
function chekea(cual) {
	var i, tipo, valor;
	if (cual.elements) {
		for (i=0; i<cual.elements.length; i++) {
			if (cual.elements[i].name != null) {
				if (cual.elements[i].name.substr(0,4) == "chk|") {
					tipo = cual.elements[i].name.split("|");
					valor = cual.elements[i].value;
					//if (valor != null) alert(valor);
					switch (tipo[2]) {
						case "editor":
							valor = tinyMCE.getContent();
							// Primero veo si es obligatorio RELLENARLO
							if ((valor.length == 0) && tipo[5] == "true") {
								alert("El campo \""+tipo[6]+"\" es OBLIGATORIO");
								tinyMCE.execCommand("mceFocus", cual.elements[i].name);// ERROR: no sitúa el cursor
								return false;
							}
							// Después veo si es menor que el mínimo
							if (tipo[5] == "true" && valor.length < parseInt(tipo[3],10)) {
								alert("El campo \""+tipo[6]+"\" NO puede ser menor de "+tipo[3]+" caracteres");				
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Y por último si es mayor que el máximo
							if (valor.length > parseInt(tipo[4],10)) {
								alert("El campo \""+tipo[6]+"\" NO puede ser mayor de "+tipo[4]+" caracteres");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							break;
						case "str":
							// Primero veo si es obligatorio RELLENARLO
							if ((valor.length == 0) && tipo[5] == "true") {
								alert("El campo \""+tipo[6]+"\" es OBLIGATORIO");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Después veo si es menor que el mínimo
							if (tipo[5] == "true" && valor.length < parseInt(tipo[3],10)) {
								alert("El campo \""+tipo[6]+"\" NO puede ser menor de "+tipo[3]+" caracteres");				
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Y por último si es mayor que el máximo
							if (valor.length > parseInt(tipo[4],10)) {
								alert("El campo \""+tipo[6]+"\" NO puede ser mayor de "+tipo[4]+" caracteres");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							break;
						case "int":
							// Primero veo si es obligatorio RELLENARLO
							if ((valor.length == 0) && tipo[5] == "true") {
								alert("El campo \""+tipo[6]+"\" es OBLIGATORIO");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Después compruebo que sea NUMÉRICO
							if (!(esnumerico(valor))) {
								alert("El campo \""+tipo[6]+"\" debe ser NUMÉRICO");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
									cual.elements[i].select();
								}
								return false;
							}
							// Después veo si es menor que el mínimo
							if (parseInt(valor,10) < parseInt(tipo[3],10)) {
								alert("El campo \""+tipo[6]+"\" NO puede ser menor que "+tipo[3]);
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Y por último si es mayor que el máximo
							if (parseInt(valor,10) > parseInt(tipo[4],10)) {
								alert("El campo \""+tipo[6]+"\" NO puede ser mayor que "+tipo[4]);
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
									cual.elements[i].select();
								}
								return false;
							}
							break;
						case "date":
							// Primero veo si es obligatorio RELLENARLO
							if ((valor.length == 0) && tipo[5] == "true") {
								alert("El campo \""+tipo[6]+"\" es OBLIGATORIO");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Después compruebo que sea FECHA
							if (esfecha(valor) != "si" && valor != "") {
								alert("El campo \""+tipo[6]+"\" debe ser de tipo fecha: DD/MM/AAAA\n"+esfecha(valor));
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Después veo si es menor que el mínimo
							if (convierteFecha(valor) < convierteFecha(tipo[3])) {
								alert("El campo \""+tipo[6]+"\" NO puede ser menor de "+tipo[3]);
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Después veo si es mayor que el máximo
							if (convierteFecha(valor) > convierteFecha(tipo[4])) {
								alert("El campo \""+tipo[6]+"\" NO puede ser mayor de "+tipo[4]);
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							break;
						case "eml":	//E-mail
							// Primero veo si es obligatorio RELLENARLO
							if ((tipo[5] == "true") && (valor.length == 0)) {
								alert("El campo \""+tipo[6]+"\" es OBLIGATORIO");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Después compruebo que sea EMAIL válido
							if ((esMail(valor)!=true) && (valor!="")){
								alert("El campo \""+tipo[6]+"\" debe ser una dirección de correo válida");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							break;
						case "alf": // Es el tipo alfanumérico
							// Primero veo si es obligatorio RELLENARLO
							if ((valor.length == 0) && tipo[5] == "true") {
								alert("El campo \""+tipo[6]+"\" es OBLIGATORIO");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Después veo si es menor que el mínimo
							if (tipo[5] == "true" && valor.length < parseInt(tipo[3],10)) {
								alert("El campo \""+tipo[6]+"\" NO puede ser menor de "+tipo[3]+" caracteres");				
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Y por último si es mayor que el máximo
							if (valor.length > parseInt(tipo[4],10)) {
								alert("El campo \""+tipo[6]+"\" NO puede ser mayor de "+tipo[4]+" caracteres");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							// Después compruebo que sea alfanumerico
							if ((esAlfanumerico(valor)!=true) && (valor!="")){
								alert("El campo \""+tipo[6]+"\" debe estar formado por letras y numeros");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}
							break;
						case "file":
							// Primero veo si es obligatorio RELLENARLO
							if ((valor == "") && tipo[5] == "true") {
								alert("El campo \""+tipo[6]+"\" es OBLIGATORIO");
								if (cual.elements[i].type!="hidden"){
									cual.elements[i].focus();
								}
								return false;
							}		
							break;
						default:
							alert("No existen restricciones de tipo \""+tipo[2]+"\"");
							return false;
							break;
					}
				}
			}
		}
	}
	return true;
}


//COMPRUEBA las fechas de un buscadores
//------------------------------------------------------------------------------------------------
function chekeaFrmBsq(cual, mensaje){

	var seguir=true;
	var valor = cual.elements["bsqFechaDesde"].value;
	if (esfecha(valor) != "si" && valor != "") {
		alert(mensaje);
		cual.elements["bsqFechaDesde"].focus();
		seguir = false;
	}

	valor = cual.elements["bsqFechaHasta"].value;
	if (esfecha(valor) != "si" && valor != "" && seguir==true) {
		alert(mensaje);
		cual.elements["bsqFechaHasta"].focus();
		seguir = false;
	}

	return seguir;
}


//COMPRUEBA que el campo sea fecha
//------------------------------------------------------------------------------------------------
function esfecha(dato) {
	var fecha_split;
	var i;
	var tdia, tmes, tano;

	fecha_split = dato.split('.');

	if(fecha_split.length != 3) {return "Debe tener DD.MM.AAAA";}
	
	tdia = parseInt(fecha_split[0],10);
	tmes = parseInt(fecha_split[1],10);
	tano = parseInt(fecha_split[2],10);

	if ((fecha_split[0].length!=2) || (!esNumeroEstricto(fecha_split[0])) ) {return "El día no es correcto. Formato: DD.MM.AAAA";}
	if ((fecha_split[1].length!=2) || (!esNumeroEstricto(fecha_split[1])) ) {return "El mes no es correcto. Formato: DD.MM.AAAA";}
	if ((fecha_split[2].length!=4) || (!esNumeroEstricto(fecha_split[2])) ) {return "el año no es correcto. Formato: DD.MM.AAAA";}

	// Comprobamos que sean 3 elementos
		// Comprobamos que no sean ceros
		for (i=0; i<fecha_split.length; i++) {
			if (parseInt(fecha_split[i],10) == 0) return "No existe la fecha: 0";
		}
		// Comprobamos que el AÑO tenga 4 dígitos
		//if(fecha_split[2].length != 4) aux="El año debe tener 4 dígitos: AAAA";
		// Comprobamos que sea dia/mes/año: 28/02/1997
		var f = convierteFecha(dato);
		if(f.getDate() != tdia) return "El día no es correcto";
		if(f.getMonth() != (tmes-1)) return "El mes no es correcto";
		if(f.getFullYear() != tano) return "El año no es correcto";

	return "si";
}


//DEVUELVE una FECHA
//------------------------------------------------------------------------------------------------
function convierteFecha(quien) {
	var fecha_split;	
	var tdia, tmes, tano;

	fecha_split = quien.split('.');


	tdia = parseInt(fecha_split[0],10);
	tmes = parseInt(fecha_split[1],10);
	tano = parseInt(fecha_split[2],10);
	return date = new Date(tano,tmes-1,tdia);
}

//COMPRUEBA que el dato sea un número
//------------------------------------------------------------------------------------------------
function esNumeroEstricto(dato){
	var i;
	for(i=0;i<dato.length;i++){
		if (dato.charAt(i)>'9' || dato.charAt(i)<'0') { return false;}
	}
	return true;
}

// Recarga la página añadiendo una variable al querystring
// -----------------------------------------------------------------------------------------------
function recargaPagina(todo, varQuery, varQueryValor) {
	if(todo.indexOf("?") == -1){
		window.location = ""+todo+"?"+varQuery+"="+varQueryValor;
	}else{
		window.location = ""+todo+"&"+varQuery+"="+varQueryValor;
	}
}

// MUESTRA o no una capa mediante la propiedad display
// ------------------------------------------------------------------------------------------------
function abrirCerrarCapa(capa){
	if(document.getElementById(capa).style.display=='none'){
		document.getElementById(capa).style.display='block';
		if(document.getElementById("btnAbrirCerrar")){
			document.getElementById("btnAbrirCerrar").src="img/btnFlechaAr.gif";
		}
	}else{
		document.getElementById(capa).style.display='none';
		if(document.getElementById("btnAbrirCerrar")){
			document.getElementById("btnAbrirCerrar").src="img/btnFlechaAb.gif";
		}
	}
}

// VALIDA un email
//------------------------------------------------------------------------------------------------
function esMail(texto){
    var valido = true;             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";
    var arroba = texto.indexOf("@", 0);
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1;
    var punto = texto.lastIndexOf(".");
	var i;
    for (i=0 ;i<texto.length;i++){
		if (cadena.indexOf(texto.substr(i, 1),0) == -1){
			valido = false;
			break;
    	}
    }
	if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (valido == true) && (texto.indexOf("..",0) == -1)){
    	valido = true;
	}else{
		valido = false;
	}
    return valido;
}


// REDIRIGE un banner
//------------------------------------------------------------------------------------------------
function abreBanner(enlace){
	window.open(enlace);
//	window.location = enlace;
}

//	MUESTRA un banner con enlaces (se llama directamente desde el banner)
//----------------------------------------------------------------------------------------------------------------------
function muestraBannerEnlaces(enlaces){
	var aux, clase;
	aux=desordenar(enlaces);
	document.write("<table cellpadding=\"0\" cellspacing=\"0\" class=\"tblBannerEnlaces\" border=\"0\">");
	for(i=0;i<aux.length;i++){
		if(i<aux.length-1){clase="separador"}else{clase="";}
		document.write("<tr><td class=\""+clase+"\">"+aux[i]+"</td></tr>");
	}
	document.write("</table>"); 
}

//	DESORDENAR un array
//----------------------------------------------------------------------------------------------------------------------
function desordenar(array){
    var aux=array;
	var i=aux.length;
	var j;
	var tmp;
    while(i--){
        j=Math.floor( Math.random() * (i+1) );
        tmp=aux[i];
        aux[i]=aux[j];
        aux[j]=tmp;
    }
	return aux;
}

// VALIDA un texto de tipo alfanumerico
// -----------------------------------------------------------------------------------------------
function esAlfanumerico(texto){
    var valido = true;             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890";
	var i;
    for (i=0 ;i<texto.length;i++){
		if (cadena.indexOf(texto.substr(i, 1),0) == -1){
			valido = false;
			break;
    	}
    }
    return valido;
}

// INICIA el editor de textos para textareas
// -----------------------------------------------------------------------------------------------
function iniciaEditor(btnMostrar, cssMostrar, hojaCss, enlace){
	tinyMCE.init({
	mode : "textareas",							//dónde actuará
	editor_selector : "mceEditor",				//<textarea class="mceEditor"> convierte un textarea en editor
	entity_encoding : "raw", 					//para que no sustituya tildes por &...
	theme : "plexus", 							//tipo
	language : "es",							//idioma
	docs_language : "es",						//idioma de la ayuda
	convert_newlines_to_brs : false,
	force_br_newlines : false,
	popups_css : hojaCss,						//hoja de estilos que cogerán las pop-ups
	//auto_resize : true,						//el editor se redimensiona para ocupar todo el espacio del q dispone (quita el scroll)
	theme_plexus_layout_manager: "SimpleLayout",//para redimensionar
	theme_plexus_statusbar_location :"bottom",	//para redimensionar
	theme_plexus_resizing : true,				//para redimensionar
	theme_plexus_resize_horizontal : false,		//para no redimensionar horizontalmente
	theme_plexus_path : false,					//no queremos path
	content_css : hojaCss,
	theme_plexus_styles : cssMostrar,			// estilos para el combo
	theme_plexus_buttons1 : btnMostrar, 		//botones activos
	theme_enlace: enlace,
	relative_urls: false,  						// El path debe ser absoluto
	plugins : "searchreplace",					//plugins: botón de reemplazar
	height : "200",
	width:"625",
//	etiquetas válidas e inválidas
//	valid_elements : "strong/b,em/i,strike,-ul,-li"
//	invalid_elements como referencia porque el script funciona con las que que son válidas
//	invalid_elements : "-div[id|dir|class|align|style]"
	invalid_elements : ""
	});
}


// RECARGA la pagina al seleccionar un año o un mes distinto en el combo del calendario
// ---------------------------------------------------------------------------------------
function recargaCalendario(destino){
	var ano, mes, fechaIni, fechaFin;
	
	ano=document.frmCalendario.anoCalendario.value;
	mes=document.frmCalendario.mesCalendario.value;
	
	fechaIni="01."+numDosCifras(mes)+"."+ano;
	fechaFin=nDiasMes(ano, mes)+"."+numDosCifras(mes)+"."+ano;

//	con esta opcion enviamos tambien las fechas del primer y último día del mes seleccionado
//	window.location.href = destino+"&anoCalendario="+ano+"&mesCalendario="+mes+"&bsqFechaDesde="+fechaIni+"&bsqFechaHasta="+fechaFin;
	
//	con esta opcion solo enviamos el mes y año del calendario para posicionarlo en esa posicion al recargar la página
	if(destino.indexOf("?") != -1){
		window.location.href = destino+"&anoCalendario="+ano+"&mesCalendario="+mes;
	}else{
		window.location.href = destino+"?anoCalendario="+ano+"&mesCalendario="+mes;
	}
}

// DEVUELVE el nº de días de un mes
// -----------------------------------------------------------------------------------------------
function nDiasMes(ano, mes){
	var msDia, msFecha, fecha;
	msDia = 86400000;	//nº de ms de un dia
	msFecha = new Date(ano, mes, 1).getTime();// nº de ms hasta el dia 1 del mes siguiente al seleccionado
	fecha = new Date(msFecha - msDia);	// fecha del último día del mes
	return fecha.getDate();
}

// AÑADE un 0 a la izda de un nº de una cifra
// -----------------------------------------------------------------------------------------------
function numDosCifras(num){
	var aux =num;
	if (num < 10){
		aux = "0" + aux;
	}
	return aux;
}

// AUMENTA O DISMINUYE el texto que hay dentro de un div
// -----------------------------------------------------------------------------------------------
function zoomTexto(accion, elemento, maximo){
//inicializaciones
	if(document.getElementById(elemento)){
		obj=document.getElementById(elemento);
		if (obj.style.fontSize==""){
			valor=parseInt(maximo);
			obj.style.fontSize=valor+"%";
		}
	
		actual=parseInt(obj.style.fontSize); //valor actual del tamaño del texto
		incremento=10;// el valor del incremento o decremento en el tamaño
	
	//accion sobre el texto
		if(accion=="reestablecer"){
			valor=parseInt(maximo);
			obj.style.fontSize=valor+"%"
		}
		if(accion=="aumentar" && actual<=150){
			valor=actual+incremento;
			obj.style.fontSize=valor+"%"
		}
		if(accion=="disminuir" && actual>=50){
			valor=actual-incremento;
			obj.style.fontSize=valor+"%"
		}
	}
}

// CREA un objeto para AJAX según disponibilidad del navegador
// -----------------------------------------------------------------------------------------------
function GetXmlHttpObject() {
	var objXMLHttp = null;
	if (window.XMLHttpRequest) {
		objXMLHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}
//
// -----------------------------------------------------------------------------------------------
function consultaAjax(destino, funcion) {
	var devolver;
	devolver = "";
	var xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("El navegador no soporta la tecnología empleada");
		//return;
	}
	xmlHttp.onreadystatechange = function(){
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
				if (xmlHttp.responseText == -1000){ // id incorrecto
					devolver = "";
				}else{	// id correcto
					devolver = xmlHttp.responseText;
				}
				if(funcion != ""){
					eval(funcion)(devolver);
					//alert(funcion+" - "+devolver);
				}
			}
		};
		//alert("consultaAjax.php"+ destino);
		xmlHttp.open("GET", destino , true);
		xmlHttp.send(null);
}

// CAMBIA la información de un bloque
// -----------------------------------------------------------------------------------------------
function cambiaInfoBloq(idBloque, cuantos, direccion, seccion){
	var i;
	for(i=0; i < cuantos; i++){
		if(document.getElementById("cntBloque_"+ idBloque +"_"+ cuantos +"_"+ i).style.display == ""){
			seleccionado = i;
		}
	}
	if(document.getElementById("cntBloque_"+ idBloque +"_"+ cuantos +"_"+ eval(seleccionado + direccion))){
		document.getElementById("cntBloque_"+ idBloque +"_"+ cuantos +"_"+ seleccionado).style.display = "none";
		
		document.getElementById("cntBloque_"+ idBloque +"_"+ cuantos +"_"+ eval(seleccionado + direccion)).style.display = "";
	}
	seleccionado = eval(seleccionado + direccion);
	if(seleccionado <= 0){
		document.getElementById("flIzdaBloq_"+ idBloque +"_"+ seleccionado +"_-1").style.visibility = "hidden";
	}else{
		document.getElementById("flIzdaBloq_"+ idBloque +"_"+ seleccionado +"_-1").style.visibility = "";
	}
	if(seleccionado >= (cuantos-1)){
		document.getElementById("flDchaBloq_"+ idBloque +"_"+ seleccionado +"_1").style.visibility = "hidden";
	}else{
		document.getElementById("flDchaBloq_"+ idBloque +"_"+ seleccionado +"_1").style.visibility = "";
	}
	actualizaVisitaOJD(seccion);
}

// CAMBIA la pestaña de un bloque
// -----------------------------------------------------------------------------------------------
function cambiaInfoBloqPestana(idBloque, idPestana, cuantos, direccion, seccion){
	var i;
	for(i=0;i<=cuantos;i++){
		if(i==idPestana){
			if(document.getElementById("cntPestana_"+idBloque+"_"+i)){
				document.getElementById("cntPestana_"+idBloque+"_"+i).className="sel";
			}
			if(document.getElementById("cntBloque_"+idBloque+"_"+i)){
				document.getElementById("cntBloque_"+idBloque+"_"+i).style.display="block";
			}
		}else if(document.getElementById("cntPestana_"+idBloque+"_"+i)){
			document.getElementById("cntPestana_"+idBloque+"_"+i).className="";
			document.getElementById("cntBloque_"+idBloque+"_"+i).style.display="none";
		}
	}
	actualizaVisitaOJD(seccion);
}


// CAMBIA el contenido de un bloque foto noticia
// -----------------------------------------------------------------------------------------------
function recargaFotoNoticia(devuelto){
	var datos = devuelto.split("|||");
	try{
		document.getElementById("cntBloque_"+ datos[0]).innerHTML = datos[1];
	}catch(e){
		setTimeout('recargaFotoNoticia('+ devuelto +')', 10);
	}
}
/*
// CARGA el contenido para un bloque de foto noticia
// -----------------------------------------------------------------------------------------------
function cargaFotoNoticia(idEdicion, idMenu, idBloque, orden, seccion){
	if(document.getElementById("imgCarga_"+ idBloque)){
		document.getElementById("img_"+ idBloque).style.display = "none";
		document.getElementById("imgCarga_"+ idBloque).style.display = "";
	}
	var destino = "?cual=fotoNoticia&idEdicion="+ idEdicion +"&idMenu="+ idMenu +"&idBloque="+ idBloque +"&orden="+ orden;
	setTimeout('consultaAjax("'+ destino +'", "recargaFotoNoticia")', 1000);
	if(seccion != ""){ actualizaVisitaOJD(seccion); }
}*/

// RECARGA una fotonoticia
// -----------------------------------------------------------------------------------------------
function cargaFotoNoticia(rutaIndex, rutaImg, idBloque, cual, totalRs, bloqueActual){
	if(document.getElementById("imgCarga_"+ idBloque)){
		document.getElementById("img_"+ idBloque).style.display = "none";
		document.getElementById("imgCarga_"+ idBloque).style.display = "";
	}
	// recuperamos el valor
	var enlace		= rutaIndex + eval("aFotoNoticia_"+ idBloque +"[0]["+ cual +"]");
	var titulo		= eval("aFotoNoticia_"+ idBloque +"[1]["+ cual +"]");
	var subtitulo	= eval("aFotoNoticia_"+ idBloque +"[2]["+ cual +"]");
	var imagen		= eval("aFotoNoticia_"+ idBloque +"[3]["+ cual +"]");
	var imagenAlt	= eval("aFotoNoticia_"+ idBloque +"[5]["+ cual +"]");
	var OJD			= eval("aFotoNoticia_"+ idBloque +"[6]["+ cual +"]");
	var idEstilo	= eval("aFotoNoticia_"+ idBloque +"[7]["+ cual +"]");
	// construímos el bloque
	codHTML = "<a href=\""+ enlace +"\"><img class=\"imgVisible\" id=\"img_"+ idBloque +"\" src=\""+ imagen +"\" alt=\""+ imagenAlt +"\" title=\""+ imagenAlt +"\" /></a>";
	codHTML+= "<div class=\"bloqueFotoNoticiaImgCarga\" id=\"imgCarga_"+ idBloque +"\" style=\"display:none;\"><img src=\""+ rutaImg +"loading.gif\" /></div>";
	codHTML+= "<h1 class=\"estilo_"+idEstilo+"\"><a href=\""+ enlace +"\">"+ titulo +"</a></h1>";
	codHTML+= "<p id=\"lSubtitulo_"+ idBloque +"\">"+ subtitulo +"</p>";
	/* construímos la paginación
	bloque 			: nº de páginas que se muestran en la paginación
	bloqueActual	: bloque actual de la paginación */
	bloque = 5;
	//alert(totalRs);
	posI = (bloqueActual * bloque);
	if(isNaN(posI) || posI <= 0){ posI = 0; }
	
	if(totalRs < bloque){
		posF = totalRs;
	}else{
		if((posI + bloque) > totalRs){
			posF = totalRs;
			posI = totalRs - (bloque);
		}else{
			posF = posI + bloque;
		}
	}
		
	if(totalRs > 1){
		//alert(cual +" - "+ bloque + " + "+ bloqueActual);
		codHTML+= "<ul class=\"paginacionBloque\">";
		if(bloqueActual > 0){
			codHTML+= "<li><a class=\"bloque\" href=\"javascript:cargaFotoNoticia('"+ rutaIndex +"', '"+ rutaImg +"', "+ idBloque +", "+ posI +", "+ totalRs +", "+ (bloqueActual-1) +");\"><img class=\"anterior\" src=\""+ rutaImg +"btnFlechaIz.gif\" title=\"anterior\" /></a></li>";
		}
		for(var i=posI;i<posF;i++){
			codHTML+= "<li>";
			if((i+1) == cual){
				codHTML+= "<span class=\"sel\">"+ (i+1) +"</span>";
			}else{
				codHTML+= "<a class=\"pag\" href=\"javascript:cargaFotoNoticia('"+ rutaIndex +"', '"+ rutaImg +"', "+ idBloque +", "+ (i+1) +", "+ totalRs +", "+ bloqueActual +");\">"+ (i+1) +"</a>";
			}
			codHTML+= "</li>";
		}
		if(posF < totalRs && totalRs > bloque){
			codHTML+= "<li><a class=\"bloque\" href=\"javascript:cargaFotoNoticia('"+ rutaIndex +"', '"+ rutaImg +"', "+ idBloque +", "+ (posF+1) +", "+ totalRs +", "+ (bloqueActual+1) +");\"><img class=\"siguiente\" src=\""+ rutaImg +"btnFlechaDe.gif\" title=\"siguiente\" /></a></li>";
		}
		codHTML+= "</ul><div style=\"clear:both;\"></div>";
	}
	try{
		actualizaVisitaOJD('');
		document.getElementById("cntBloque_"+ idBloque).innerHTML = codHTML;
	}catch(e){
		setTimeout("cargaFotoNoticia('"+ rutaIndex +"', '"+ rutaImg +"', "+ idBloque +", "+ i +", "+ totalRs +", "+ bloqueActual +")", 1000);
	}
}

// SUMA la visita al contador OJD
// -----------------------------------------------------------------------------------------------
function actualizaVisitaOJD(seccion){
	trac.slideEvent('slideshow');
}

// COMPRUEBA si se ha pulsado alguna opcion de un formulario
// -----------------------------------------------------------------------------------------------
function validaEncuesta(frm, alerta){
	var enviar = false;
	for(i=0;i<frm.elements.length;i++){
		if(frm.elements[i].type=="radio" && frm.elements[i].checked==true){
			enviar = true;
		}
	}
	if(enviar == false){
		alert(alerta);
	}
	return enviar;
}


// Hace el history.back tantas veces como el valor de la variable
// -----------------------------------------------------------------------------------------------
function volver(){
	history.go(contadorHistoria);
}