/**********************************************************************************
****** Funciones JavaScript utilizadas en las páginas de la sección NOTICIAS
***********************************************************************************/
function print(id)
{
	var myUrl = (isInternetExplorer()) ? "" : "charlas/";
	myUrl += "imprimirHilo07.asp?id=" + id;

	var windowName = "Imprimir";
	var windowOption = "toolbar=0,location=0,scrollbars=1,directories=0,status=0,menubar=0,resizable=1"; 
	var w = 790;
	var h = 550;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	windowOption += ",height=" + h + ",width=" + w + ",top=" + wint + ",left=" + winl + "resizable=0";
	window.open(myUrl,windowName,windowOption);
}

function adjustResolution(width)
{
	var pagination = document.getElementById("pages");
	var content    = document.getElementById("page_content");
	if (screen.width < 900 && screen.height < 700)
	{
		if (pagination != null)
			pagination.style.width = "" + width + "px";
		content.style.width = "" + width + "px";
	}
}

function participate(show,parent)
{
	var myUrl = (isInternetExplorer()) ? "" : "charlas/";
	myUrl += "alta_foros07.asp?parent=" + parent + "&show=" + show;
	document.location.href = myUrl;
}

function threadClosed()
{
	alert("Esta charla ha sido cerrada expresamente por el Administrador.\nSi, a pesar de ello, quieres seguir tratando este tema deberás\nabrir una charla nueva sin utilizar seudónimos");
}
var MAXIMUM_RESPONSES = 0;
var NUMBER_OF_DAYS_RESPONSE_NEW = 0;
var arrayParent;
var currentPosition = 0;
var numberOfThreads = 0;
var numberOfNewRows = 0;
function buildUI(ids,maxResponses,maxNew)
{
	MAXIMUM_RESPONSES = maxResponses;
	NUMBER_OF_DAYS_RESPONSE_NEW = maxNew;
	arrayParent = ids;
	numberOfThreads = ids.length;
	getChildren(arrayParent[currentPosition]);
}

var currentThread;
var currentState;
var objXML = false;
var newsId;
var parentId;
var isClosed;
var tooMuchResponses;
var isInProcess = false;
var zIndexCounter = 100;

function getText(id,parentThread,closed,responses)
{
	newsId = id;
	parentId = parentThread;
	isClosed = closed;
	tooMuchResponses = responses;
	rowLayer = "thread_" + id;

	if (!isDeployed(rowLayer))
	{
		if (!isInProcess)
		{
			try
			{
				objXML = new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch (e2)
			{
				objXML = false;
			}

			if (window.XMLHttpRequest)
				objXML = new XMLHttpRequest();

			if (!objXML && typeof XMLHttpRequest != 'undefined')
				objXML = new XMLHttpRequest();

			var URL = "charlas/getTexto.asp?id=" + newsId;
			if (objXML)
			{
				isInProcess = true;
				objXML.open('GET', URL, true);
				objXML.onreadystatechange = handleResponse;
				objXML.send(null);
			}
		}
	}
	else
		onOffDiv(rowLayer);
}

function getChildren(thread)
{
	currentThread = thread[0];
	currentState = thread[1];
	var currentTime = (new Date()).getTime();
	var param= 'id=' + currentThread + '&timestamp=' + currentTime;
	var URL = 'charlas/getChildren07.asp?' + param;

	if (!isInProcess)
	{
		try
		{
			objXML = new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch (e2)
		{
			objXML = false;
		}

		if (window.XMLHttpRequest)
			objXML = new XMLHttpRequest();

		if (!objXML && typeof XMLHttpRequest != 'undefined')
			objXML = new XMLHttpRequest();

		if (objXML)
		{
			isInProcess = true;
			objXML.open('GET', URL, true);
			objXML.onreadystatechange = buildThread;
			objXML.send(null);
		}
	}
}

function buildThread()
{
	if (objXML.readyState == 4)
	{
		isInProcess = false;
		var rowsJSON = eval("(" + objXML.responseText + ")");
		var numberOfRows = rowsJSON.data.length;
		var HTML = "";
		var IMAGE_NEW_HTML = "";

		if (numberOfRows > 0)
		{
			var theTable = (document.all) ? document.all.charlas : document.getElementById("charlas");
			var theTableBody = theTable.tBodies[0];

			document.getElementById("row_" + currentThread).style.display = "none";
			var rowclass = document.getElementById("row_" + currentThread).className;

			// Recorremos la lista de respuestas al thread principal que estamos cargando
			for (var i = 0; i < numberOfRows; i++)
			{
				// Construimos el TR correspondiente a la respueta i
				var newRow = theTableBody.insertRow(currentPosition * 6 + 5 + numberOfNewRows); // before 7 -> after 5
				newRow.height = 25;
				newRow.style.height = "25px";
				//newRow.className = rowclass;
				//newRow.className = (i % 2 == 0) ? "comunes_filaimpar" : "comunes_filapar";
				newRow.className = (currentPosition % 2 == 0) ? "comunes_filaimpar" : "comunes_filapar";
				iconColor = (i % 2 == 0) ? "blue" : "blue";
				var firstCell = document.getElementById("firstRowspan_" + currentThread);
				firstCell.rowSpan = parseInt(firstCell.rowSpan, 10) + 2;
				var lastCell  = document.getElementById("lastRowspan_" + currentThread);
				lastCell.rowSpan = parseInt(lastCell.rowSpan, 10) + 2;


				if (dateDiff(rowsJSON.data[i].fechas,"D") < NUMBER_OF_DAYS_RESPONSE_NEW)
					IMAGE_NEW_HTML = "<img border=\"0\" src=\"imagenes/estrellanuevo.gif\">";
				else
					IMAGE_NEW_HTML = "<img border=\"0\" src=\"imagenes/document_" + iconColor + ".gif\">";

				var newData = ["<img src=\"imagenes/transparent.gif\" width=\"15\" alt=\"\" />",
				               IMAGE_NEW_HTML, 
				               rowsJSON.data[i].titulo, 
				               "<img src=\"imagenes/transparent.gif\" width=\"15\" height=\"1\" alt=\"\" />",
							   rowsJSON.data[i].quien,
							   "<img src=\"imagenes/transparent.gif\" width=\"15\" height=\"1\" alt=\"\" />",
							   rowsJSON.data[i].fechas];

				// Cada columna de la nueva fila tiene unas características especiales
			   for (var j = 0; j < newData.length; j++)
				{
					var newCell = newRow.insertCell(j);
					newCell.innerHTML = newData[j];
					switch (j)
					{
						case 1:
							newCell.valign = "middle";
							break;
						case 2:
							var txtFunction = "getText(" + rowsJSON.data[i].id + "," + rowsJSON.data[i].padre + "," + currentState + "," + (numberOfRows >= MAXIMUM_RESPONSES) + ");";
							newCell.className = "charlas_titulo_secundario";
							newCell.innerHTML = "<span onclick=\"" + txtFunction + "\" class=\"charlas_titulo_secundario\">" + newData[j] + "</span>";
							break;
						case 4:
							newCell.className = "charlas_autor";
							break;
						case 6:
							newCell.className = "charlas_fecha";
							break;
					}
				}

				// Insertamos una fila adicional por cada respuesta para mostrar el contenido de la intervención cuando el webero haga click sobre el título
				newRow = theTableBody.insertRow(currentPosition * 6 + 5 + numberOfNewRows + 1); // before 7 -> after 5
				newRow.id = "thread_" + rowsJSON.data[i].id;
				newRow.style.display = "none";
				if (isInternetExplorer() && getIEVersion() < 8)
				{
					firstCell.rowSpan = parseInt(firstCell.rowSpan, 10) + 1;
					lastCell.rowSpan = parseInt(lastCell.rowSpan, 10) + 1;
				}
				newCell = newRow.insertCell(0);
				newCell.innerHTML = "<img src=\"imagenes/transparent.gif\" width=\"15\" alt=\"\" />";
				newCell = newRow.insertCell(1);
				newCell.className = "charlas_borde_secundario";
				newCell.innerHTML = "<div id=\"cell_" + rowsJSON.data[i].id + "\" class=\"charlas_contenido\"></div>";
				newCell.colSpan = 6;

				newRow = theTableBody.insertRow(currentPosition * 6 + 5 + numberOfNewRows + 2); // before 7 -> after 5
				newCell = newRow.insertCell(0);
				newCell.innerHTML = "<img src=\"imagenes/transparent.gif\" width=\"1\" height=\"1\" alt=\"\" />";
				newCell.colSpan = 7;
			}
			numberOfNewRows += 3 * numberOfRows;
		}
		else
		{
			document.getElementById("row_" + currentThread).style.display = "none";
		}

		currentPosition++;
		if (currentPosition < numberOfThreads)
			getChildren(arrayParent[currentPosition]);

	}
}

function handleResponse()
{
	isInProcess = false;
	if (objXML.readyState == 4)
	{
		var text = objXML.responseText;
		text = decodeAnchor(objXML.responseText);
		text = replaceAll(text, "&quot;", "\"");
		threadLayer = "thread_" + newsId;
		cellLayer = "cell_" + newsId;

		var x = document.getElementsByTagName('tr');
		for (var i=0;i<x.length;i++)
		{
			if (x[i].id.indexOf('thread_') > -1)
				x[i].style.display = "none";
		}

		onOffDiv(threadLayer);
		/*
		text += "&nbsp;&nbsp;<a href='#' onclick='print(" + newsId + ");return false;'>" +
		        "<img src='imagenes/print07.jpg' border='0' alt='Versión para imprimir' align='middle'></a>" +
		*/

		document.getElementById(cellLayer).innerHTML = "<br>" + text + "<br><br>";

		/*
		if (!isInternetExplorer() && parentId != 0)
		{
			var increment = (document.getElementById(threadLayer).style.display == "none") ? -1 : 1;
			var firstCell = document.getElementById("firstRowspan_" + parentId);
			var lastCell  = document.getElementById("lastRowspan_" + parentId);
			if (firstCell != null)
				firstCell.rowSpan = parseInt(firstCell.rowSpan, 10) + increment;
			if (lastCell != null)
				lastCell.rowSpan = parseInt(lastCell.rowSpan, 10) + increment;
		}
		*/
	}
}

function getParent(id)
{
	newsId = id;

	if (!isInProcess)
	{
		try
		{
			objXML = new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch (e2)
		{
			objXML = false;
		}

		if (window.XMLHttpRequest)
			objXML = new XMLHttpRequest();

		if (!objXML && typeof XMLHttpRequest != 'undefined')
			objXML = new XMLHttpRequest();

		var URL = "charlas/getTexto.asp?id=" + newsId + "&full=1";
		if (objXML)
		{
			isInProcess = true;
			objXML.open('GET', URL, true);
			objXML.onreadystatechange = processParent;
			objXML.send(null);
		}
	}
}

function processParent()
{
	isInProcess = false;
	if (objXML.readyState == 4)
	{
		onOffDiv("parent");
		var rowsJSON = eval("(" + objXML.responseText + ")");
		document.getElementById("parent-titulo").innerHTML = rowsJSON.data[0].titulo;
		document.getElementById("parent-autor").innerHTML = rowsJSON.data[0].quien;
		document.getElementById("parent-fecha").innerHTML = rowsJSON.data[0].fechas;
		document.getElementById("parent-texto").innerHTML = rowsJSON.data[0].texto;
	}
}

function resetTable(table)
{
	var numberOfRows = table.rows.length;
	for (var i = numberOfRows - 1; i > -1; i--)
		table.deleteRow(i);
}

/*
	Funciones que se utilizan en el formulario de alta de charlas
*/
function valida()
{
	updateRTE('rte');
	document.forms[0].elements["texto"].value = document.forms[0].elements["rte"].value;

	var titulo = document.forms[0].elements["titulo"].value;
	var texto  = document.forms[0].elements["texto"].value;

	titulo = LTrim(titulo);
	texto = LTrim(texto);

	if (document.forms[0].elements["quien"] != null)
	{
		var quien  = document.forms[0].elements["quien"].value;
		quien = LTrim(quien);

		if (quien == "")
		{
			alert("El nombre y los apellidos son obligatorios");
			document.forms[0].elements["quien"].focus();
			return false;
		}
	}
	if (titulo == "")
	{
		alert("El título es obligatorio");
		document.forms[0].elements["titulo"].focus();
		return false;
	}
	if (texto == "")
	{
		alert("El texto es obligatorio");
		//document.forms[0].elements["texto"].focus();
		return false;
	}

	return true;
}

/**  Funciones comunes Bug Internet Explorer  **/
/*
	Código especial para el menú de navegación
*/
var firstLeftTD = 0;

function isInternetExplorer()
{
	var output = true;

	try
	{
		var navegador = navigator.appName;
		output = (navegador == "Microsoft Internet Explorer");
	}
	catch(err)
	{
		txt="Se ha producido un error en isInternetExplorer.\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return output;
}
function getIEVersion()
{
	var output = 0;

	try
	{
		var navegador = navigator.appName;
		var appVersion = navigator.appVersion;
		if (appVersion.lastIndexOf("MSIE") > 0)
		{
			regExpresion = /MSIE\s(\d)/
			var match = regExpresion.exec(appVersion);
			if (match != null)
			{
				output = parseInt(match[1], 10);
			}
		}
	}
	catch(err)
	{
		txt="Se ha producido un error en isInternetExplorer.\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		alert(txt);
	}

	return output;
}
function getDisplayProperty()
{
	var output = "block";

	try
	{
		output = (isInternetExplorer()) ? "block" : "table-row";
	}
	catch(err)
	{
		txt="Se ha producido un error en getDisplayProperty.\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return output;
}
function isHome()
{
	var output = false;

	try
	{
		output = (document.location.href.indexOf("portada07.asp") > -1);
	}
	catch(err)
	{
		txt="Se ha producido un error en isHome.\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}
	
	return output;
}
/*

	Funciones para manejo de capas

*/
function onOffCursor(layer)
{
	try
	{
		var handValue = (document.all) ? "hand" : "pointer";
		if (document.getElementById(layer).style.cursor == handValue)
			document.getElementById(layer).style.cursor = "default";
		else
			document.getElementById(layer).style.cursor = handValue;
	}
	catch(err)
	{
		txt="Se ha producido un error en onOffCursor(" + layer + ").\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}
}
function onOffDiv(layer)
{
	try
	{
		if (!isDeployed(layer))
			document.getElementById(layer).style.display = getDisplayProperty();
		else
			document.getElementById(layer).style.display = "none";

		/*
		if (layer == 'asociacion' || layer.indexOf("row") > -1)
		{
			document.getElementById('leftlayermenu').style.height = firstLeftTD + "px";
			//document.getElementById("transparentImage").style.height = firstLeftTD + "px";
			//alterMenuHeight();
		}
		*/
	}
	catch(err)
	{
		txt="Se ha producido un error en onOffDiv(" + layer + ").\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}
}

function alterDiv(layer,title,link)
{
	try
	{
		var HTML = "<img src=\"imagenes/transparent.gif\" width=\"20\" height=\"12\" align=\"absmiddle\">";
		HTML += "<a class=\"PortadaEnlace\" href=\"" + link + "\">" + title + "</a>";

		document.getElementById(layer).innerHTML = HTML;
	}
	catch(err)
	{
		txt="Se ha producido un error en alterDiv(" + layer + "," + title + "," + link + ").\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}
}

function isDeployed(layer)
{
	var deployed = false

	try
	{
		var displayStatus = document.getElementById(layer).style.display;
		deployed = (displayStatus != "none" && displayStatus != "");
	}
	catch(err)
	{
		txt="Se ha producido un error en isDeployed(" + layer + ").\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return deployed;	
	
}


function alterMenuHeight()
{
	//alert("En alterMenuHeight");
	var h12 = 0;
}

function alterContentHeight()
{
	try
	{
		// TABLE 	-> full_page (todo html)
		// TD 	-> lower_frame (menu de la derecha)
		// SCROLL 	-> page_content (capa con scroll)

		var availH = 0;
		if (isInternetExplorer())
			availH = document.documentElement.clientHeight;
		else
			availH = window.innerHeight;


		var fullPageHeight   = document.getElementById('full_page').offsetHeight;
		var layerMenuHeight = document.getElementById('layermenu').offsetHeight;
		var contentHeight = document.getElementById('page_content').style.height;
		if (isNaN(contentHeight))
		{
			var position = contentHeight.lastIndexOf("px");
			contentHeight = parseInt(contentHeight.substring(0, position), 10);
		}
		var extraOffset = (layerMenuHeight - contentHeight > 130) ? layerMenuHeight - contentHeight - 130  : 0; 

		var newHeight = contentHeight + (availH - fullPageHeight) + extraOffset - 20;

//alert("contentHeight " + contentHeight + "\navailH " + availH + "\nfullPageHeight " + fullPageHeight  + "\nnewHeight " + newHeight);
		document.getElementById('page_content').style.height = newHeight + "px";

	}
	catch(err)
	{
		txt="Se ha producido un error en alterContentHeight.\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}
}

function dateDiff(date,unit)
{
	var re = /(\d{1,2})\/(\d{1,2})\/(\d{4})\s(\d{1,2})\:(\d{1,2})/
	var m = re.exec(date);
	var date1 = new Array();
	if (m != null)
	{
		date1[0] = parseInt(m[1],10);
		date1[1] = parseInt(m[2],10) - 1;
		date1[2] = parseInt(m[3],10);
		date1[3] = parseInt(m[4],10);
		date1[4] = parseInt(m[5],10);
		date1[5] = 0;
	}
	else
	{
		re = /(\d{1,2})\/(\d{1,2})\/(\d{4})\s(\d{1,2})\:(\d{1,2}):(\d{1,2})/
		m = re.exec(date);
		if (m != null)
		{
			date1[0] = parseInt(m[1],10);
			date1[1] = parseInt(m[2],10) - 1;
			date1[2] = parseInt(m[3],10);
			date1[3] = parseInt(m[4],10);
			date1[4] = parseInt(m[5],10);
			date1[5] = parseInt(m[6],10);
		}
		else
		{
			date = date.split("/");
			date1[0] = parseInt(date1[0],10);
			date1[1] = parseInt(date1[1],10) - 1;
			date1[2] = parseInt(date1[2],10);
			date1[3] = 0;
			date1[4] = 0;
			date1[5] = 0;
		}
	}

	var myDate1 = new Date();
	myDate1.setFullYear(date1[2],date1[1],date1[0],date1[3],date1[4],date1[5]);

	var myDate2 = new Date();

	var seconds = 1000;
	var minutes = seconds * 60;
	var hours = minutes * 60;
	var days = hours * 24;
	var months = days * 30;
	var years = days * 365;

	var ratio = 1;
	switch (unit)
	{
		case 'Y':
			ratio = years;
			break;
		case 'M':
			ratio = months;
			break;
		case 'D':
			ratio = days;
			break;
		case 'H':
			ratio = hours;
			break;
		case 'm':
			ratio = minutes;
			break;
		case 'S':
			ratio = seconds;
			break;
		default:
			ratio = days;
			break;
	}

	var numberOfMiliseconds = myDate1.getTime() - myDate2.getTime();
	numberOfMiliseconds = (numberOfMiliseconds < 0) ? -numberOfMiliseconds : numberOfMiliseconds;
	return Math.round(numberOfMiliseconds / ratio);
}

function clean()
{
	document.forms[0].reset();
	if (document.forms[0].elements["texto"] != null)
	{
		document.forms[0].elements["texto"].value = "";
	}
	if (document.forms[0].elements["rte"] != null)
	{
		document.forms[0].elements["rte"].value = "";
	}
	if (frames["rte"] != null)
	{
		frames["rte"].document.body.innerHTML = "";
	}
}

function alterMenuHeightOnLoad()
{
	try
	{
		var parentTD = document.getElementById('layermenu').offsetHeight;
		var childTD  = document.getElementById('childlayermenu').offsetHeight;
		var leftTD   = document.getElementById('leftlayermenu').offsetHeight;
		var newHeight = leftTD + (parentTD - childTD);

		if (firstLeftTD == 0)
			firstLeftTD = leftTD;

		document.getElementById("bannerAdjust").height = document.getElementById("bannerAdjust").height + (parentTD - childTD);
	}
	catch(err)
	{
		txt="Se ha producido un error en alterMenuHeightOnLoad.\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}
}


/*

	Funciones para manipulación de cadenas

*/
function LTrim(s)
{
	// Devuelve una cadena sin los espacios del principio
	var cadena = s;

	try
	{
		while (cadena.substring(0,1) == ' ')
		{
			cadena = cadena.substring(1,cadena.length);
		}
	}
	catch(err)
	{
		txt="Se ha producido un error en LTrim(" + s + ").\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return cadena;
}

function ltrim(s)
{
	var cadena = s;

	try
	{
		cadena = s.replace(/^\s+/, "");
	}
	catch(err)
	{
		txt="Se ha producido un error en ltrim(" + s + ").\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return cadena;
}

function rtrim(s)
{
	var cadena = s;

	try
	{
		cadena = s.replace(/\s+$/, "");
	}
	catch(err)
	{
		txt="Se ha producido un error en rtrim(" + s + ").\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return cadena;
}

function trim(s)
{
	var cadena = s;

	try
	{
		cadena = rtrim(ltrim(s));
	}
	catch(err)
	{
		txt="Se ha producido un error en trim(" + s + ").\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return cadena;
}

function repeatString(string, times)
{
	var output = "";

	try
	{
		for (var i = 0; i < times; i++)
			output += string;
	}
	catch(err)
	{
		txt="Se ha producido un error en repeatString(" + string + "," + times + ").\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return output;
}

function replaceAll(oldStr,findStr,repStr)
{
	var newStr = oldStr;

	try
	{
		var srchNdx = 0;  // srchNdx will keep track of where in the whole line
						  // of oldStr are we searching.
		var newStr = "";  // newStr will hold the altered version of oldStr.
		while (oldStr.indexOf(findStr,srchNdx) != -1)  
						// As long as there are strings to replace, this loop
						// will run. 
		{
			newStr += oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
							// Put it all the unaltered text from one findStr to
							// the next findStr into newStr.
			newStr += repStr;
							// Instead of putting the old string, put in the
							// new string instead. 
			srchNdx = (oldStr.indexOf(findStr,srchNdx) + findStr.length);
							// Now jump to the next chunk of text till the next findStr.           
		}
		newStr += oldStr.substring(srchNdx,oldStr.length);
						// Put whatever's left into newStr.             
	}
	catch(err)
	{
		//txt="Se ha producido un error en replaceAll(" + oldStr + "," + findStr + "," + repStr + ").\n\n";
		txt="Se ha producido un error en replaceAll.\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return newStr;
}

function decodeAnchor(anchor)
{
	//var strHTML = anchor.toLowerCase();
	var strHTML = anchor;

	try
	{
		strHTML = replaceAll(strHTML, "href=&quot;", "href=\"");
		if (strHTML.indexOf("++target=+_blank&quot;>") == -1)
			strHTML = replaceAll(strHTML, "++target=+_blank\">", "\" target=\"_blank\">");
		else
			strHTML = replaceAll(strHTML, "++target=+_blank&quot;>", "\" target=\"_blank\">");
	}
	catch(err)
	{
		//txt="Se ha producido un error en decodeAnchor(" + anchor + ").\n\n";
		txt="Se ha producido un error en decodeAnchor.\n\n";
		txt+="Descripción: " + err.description + "\n\n";
		txt+="Nacho, toma una captura de esta pantalla.\n\n";
		alert(txt);
	}

	return strHTML;
}
