
function parserBloqueLugarReportaje(xml,strObjCont,accionFicha,rutaImagenesModulo) {
	var html = '';
	var objCont = document.getElementById(strObjCont);
	// Obtenemos toda la lista de item's esperados en el documento recibido
	var listaLugares = xml.getElementsByTagName('lugar');
	// Itemramos para todo elemento obtenido en la lista, y procesamos según el tag (por nombre)
	for (i=0;i<listaLugares.length;i++) {
		lugarNodo = listaLugares[i].childNodes;
		id = listaLugares[i].getAttribute('id'); 
		titulo = ''; logo = ''; direccion = ''; poblacion = ''; ptosmc = 1;
		//
		for (j=0;j<lugarNodo.length;j++) {
			switch (lugarNodo[j].nodeName) {
				case 'nombre': titulo = lugarNodo[j].firstChild.nodeValue;break;
				case 'direccion': direccion = lugarNodo[j].firstChild.nodeValue;break;
				case 'poblacion': poblacion = lugarNodo[j].firstChild.nodeValue;break;
				case 'ptosmc': ptosmc = lugarNodo[j].firstChild.nodeValue;break;
				// El caso de la imagen es especial.
				case 'img':
					// Obtenemos sus atributos para saber a que tipo nos referimos => Sólo cuando el conj. es desconocido
					//attImage = noticiaNodo[j].attributes;
					if (lugarNodo[j].getAttribute('type') == 'logo')
						logo = lugarNodo[j].getAttribute('src');
				break
			}
		}
		enlaceContenido = accionFicha + "&IDLugar="+id+"&TituloFicha="+titulo;
		//alert("Título: " + title + ", Categorias: " + category.length);alert("Link: " + links);alert("Comments: " + comments);alert("Pubdate: " + pubDate);
		if (logo!='')
			html = '<div style="margin-top:15px;"><a href="'+enlaceContenido+'" target="_blank"><img src="'+logo+'" border="0"></a></div>';
		else
			html = '<div class="titulo"><a href="'+enlaceContenido+'" target="_blank">'+titulo+'</a></div>';
		html += '<div class="contReportaje">'+direccion+' - '+poblacion+'</div>';
		html += '<div class="contReportaje">';
		for (iPto=1;iPto<=ptosmc;iPto++) {
			html += '<img src="'+rutaImagenesModulo+'EstrellaMC.gif" border="0">';
		}
		html += '</div>';
		html += '<hr size="1" color="Black" style="margin-top:10px;" />';
		
		// Encapsulamos en el bloque contenedor del destacado
		//html = '<div class="lugarReportaje">' + html + '</div>';
		
		// -- Añadimos el objeto al DOM
		//if(!document.getElementById('item-'+i)) {
		if (!document.getElementById('id-'+i)) {
			// Creamos el nuevo elemento DIV contenedor de una noticia
			var nuevoNodo = document.createElement('div');
			// Seteamos propiedades id y class
			nuevoNodo.id = "id-"+i;
			nuevoNodo.className = "lugarReportaje";
			// Añadimos al HTML del documento
			objCont.appendChild(nuevoNodo);
			/* Para añadir justo detrás de un elemento sería:  document.body.insertBefore(newDiv, my_div); */
			//alert("Nuevo nodo creado, ID: "+nuevoNodo.id);
			// Accedemos al objeto:
		divItem = document.getElementById('id-'+i);
		// Añadimos el contenido HTML al DIV
		divItem.innerHTML = html;
			
		}
		
	}
}


function parserNoticias(xml) {
	var numMax = parseInt(document.miForm.numMax.value); 
	var finItera = numMax;
	
	// Obtenemos toda la lista de item 'item' y RECORREMOS TODO ITEM
	var listaNoticias = xml.getElementsByTagName('item');
	if (listaNoticias.length > numMax) finItera = listaNoticias.length;
	for (i=0;i<numMax;i++) {
		title='';links='';comments='';pubDate='';description=''; category = new Array(); iCat = 0;
		noticiaNodo = listaNoticias[i].childNodes; // guardamos el item noticia en curso
		// 1. Obtenemos los datos de cada NODO NOTICIA
		for (j=0;j<noticiaNodo.length;j++) {
			switch (noticiaNodo[j].nodeName) {
				case 'title': title = noticiaNodo[j].firstChild.nodeValue;break;
				case 'link': links = noticiaNodo[j].firstChild.nodeValue;break;
				case 'comments': comments = noticiaNodo[j].firstChild.nodeValue;break;
				case 'description': description = noticiaNodo[j].firstChild.nodeValue;break;
				case 'pubDate': pubDate = noticiaNodo[j].firstChild.nodeValue;break;
				case 'category':
					category[iCat] = noticiaNodo[j].firstChild.nodeValue;
					iCat++;
				break;
			}
		}
				
		// 2. ------------ Mostranos/Refrescamos la noticia: -----------
		// Si existe el item-Noticia => se accede y modifica el contenido HTML del DIV
		// Si no existe el contenedor item-i => CREAMOS EL OBJETO DIV
		if(!document.getElementById('item-'+i)) {
			// Creamos el nuevo elemento DIV contenedor de una noticia
			var nuevoNodo = document.createElement('div');
			// Seteamos propiedades id y class
			nuevoNodo.id = "item-"+i;
			nuevoNodo.className = "boxNoticia";
			// Añadimos al HTML del documento
			objDestino.appendChild(nuevoNodo);
			/* Para añadir justo detrás de un elemento sería:  document.body.insertBefore(newDiv, my_div); */
			//alert("Nuevo nodo creado, ID: "+nuevoNodo.id)
		}
		// Accedemos al objeto:
		divNoticia = document.getElementById('item-'+i);
		// Añadimos el contenido HTML al DIV
		divNoticia.innerHTML = mostrarNoticia(title,links,description,pubDate,category);
	}
	
	// 3. Se eliminan los DIV contenedores de noticias sobrantes
	inicio = i;
	for (i=inicio;i<listaNoticias.length;i++) {
		if(!document.getElementById('item-'+i)) { }
		else {
			// Si existe => accede
			divNoticia = document.getElementById('item-'+i);
			// elimina
			eliminarElement('item-'+i,'data');
		}
	}
}

// -------- Aquí podriamos considerar las funciones de libreria para interacción DOM ---------

/*
function mostrarNoticia(title,links,description,pubDate,category) {
	// Devuelve el código HTML correspondiente a un DIV contenedor de la noticia
	//alert("Título: " + title + ", Categorias: " + category.length);alert("Link: " + links);alert("Comments: " + comments);alert("Pubdate: " + pubDate);
	html = '';
	html += '<div>'+pubDate+'</div>';
	html += '<div><b>'+title+'</b></div>';
	html += '<div style="text-align:justify;">'+description+'</div><br />'
	html += '<div><a href="'+links+'" target="_blank">Leer más</a></div>';
	return html;
}

function cambiarTexto(obj,texto) {
	obj.innerHTML = texto;
}

function eliminarElement(obj,contenedor) {
	fi = document.getElementById(contenedor);
	fi.removeChild(document.getElementById(obj));
}

*/

