var cuadroBuscarUsado = false;
var cuadroIdUsado = false;
var archivoAjaxPhp = "/nl_ajax.php";
var canales;
var contenidoSustitucion = "";

function ajaxConectar() {
	var ajaxPeticion = null;
	try { //Todos, menos Explorer:
		ajaxPeticion = new XMLHttpRequest();
	}
	catch (e) { // Internet Explorer
		try {
			ajaxPeticion = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				ajaxPeticion = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				return null;
			}
		}
	}
	return ajaxPeticion;
}

function ajaxPeticionar(solicitud) {
	var peticion = ajaxConectar();
	peticion.open("POST", archivoAjaxPhp, false);
	peticion.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	peticion.send(solicitud);
	//alert(solicitud);
	//jjj = peticion.responseText;
	//alert(peticion.responseText);
	return peticion.responseXML.documentElement;
}

function cargarSelectLocalidades(pais, idioma, provincia, idSelectLocalidad, codigoLocalidadSeleccionada) {
	var xml = ajaxPeticionar("peticion=lista_localidades&pais=" + pais + "&idioma=" + idioma + "&provincia=" + provincia);
	var cantidadLocalidades = xml.childNodes.length;
	var html = "";
	var x, codigo, opcion;
	var indiceSeleccionado;
	
	//Vacía el SELECT:
	var cantidadActualOpciones = document.getElementById(idSelectLocalidad).options.length;
	//alert(cantidadActualOpciones);
	for (x = 0; x < cantidadActualOpciones; x++) {
		document.getElementById(idSelectLocalidad).remove(0);
	}
	
	//Llena el SELECT:
	for (x = 0; x < cantidadLocalidades; x++) {
		opcion = document.createElement('option');
		opcion.value = xml.childNodes[x].childNodes[0].childNodes[0].nodeValue;
		if (opcion.value == codigoLocalidadSeleccionada) {
			indiceSeleccionado = x;
		}
		
		if (xml.childNodes[x].childNodes[1].childNodes.length == 0) {
			opcion.text = "";
		}
		else {
			opcion.text = xml.childNodes[x].childNodes[1].childNodes[0].nodeValue;
		}
		
		try {
			document.getElementById(idSelectLocalidad).add(opcion, null);
		}
		catch(ex) {
			document.getElementById(idSelectLocalidad).add(opcion);
		}
	}
	
	document.getElementById(idSelectLocalidad).selectedIndex = indiceSeleccionado;
}

function revisarSubidaArchivo(izquierda, tituloIzquierda, derecha, tituloDerecha, borrar, tituloBorrar, mensaje0, mensajeN, retroceso) {
	if (!revisarIframe) {
		revisarIframe = true;
	}
	else {
		var estado;
		if (navigator.appName == "Microsoft Internet Explorer") {
			estado = document.getElementById("marco_ajax").contentWindow.document.getElementsByTagName("span")[0].innerHTML;
		}
		else {
			estado = document.getElementById("marco_ajax").contentDocument.getElementsByTagName("span")[0].innerHTML;
		}
		if (estado == 0) {
			var cantidadErrores;
			if (navigator.appName == "Microsoft Internet Explorer") {
				cantidadErrores = document.getElementById("marco_ajax").contentWindow.document.getElementsByTagName("span")[1].childNodes.length;
			}
			else {
				cantidadErrores = document.getElementById("marco_ajax").contentDocument.getElementsByTagName("span")[1].childNodes.length;
			}
			if (cantidadErrores > 0) {
				var yerro, x;
				for (x = 0; x < cantidadErrores; x++) {
					if (navigator.appName == "Microsoft Internet Explorer") {
						yerro = document.getElementById("marco_ajax").contentWindow.document.getElementsByTagName("span")[1].childNodes[x].childNodes[0].nodeValue;
					}
					else {
						yerro = document.getElementById("marco_ajax").contentDocument.getElementsByTagName("span")[1].childNodes[x].childNodes[0].nodeValue;
					}
					alert(yerro);
				}
			}
		}
		else {
			//Archivo correctamente insertado:
			var nombreArchivo;
			if (navigator.appName == "Microsoft Internet Explorer") {
				nombreArchivo = document.getElementById("marco_ajax").contentWindow.document.getElementsByTagName("span")[1].childNodes[0].nodeValue;
			}
			else {
				nombreArchivo = document.getElementById("marco_ajax").contentDocument.getElementsByTagName("span")[1].childNodes[0].nodeValue;
			}
			var cantidadCeldas = document.getElementById("table_cuadro_gris").rows[0].cells.length;
			document.getElementById("table_cuadro_gris").rows[0].insertCell(cantidadCeldas);
			document.getElementById("table_cuadro_gris").rows[0].cells[cantidadCeldas].className = "table_cuadro_gris";
			
			var html = "<p class=table_cuadro_gris_flechas>";
			html += "<img id='izq_" + (cantidadCeldas / 2) + "' src='" + izquierda + "' alt='" + tituloIzquierda + "' onclick='this.lang = \"xxx\"; moverIzquierda();'>";
			html += "&nbsp;&nbsp;&nbsp;";
			html += "<img id='der_" + (cantidadCeldas / 2) + "' src='" + derecha + "' alt='" + tituloDerecha + "' onclick='this.lang = \"xxx\"; moverDerecha();'>";
			html += "&nbsp;&nbsp;&nbsp;&nbsp;";
			html += "<img id='borrar_" + ((cantidadCeldas - 1) / 2) + "' src='" + borrar + "' alt='" + tituloBorrar + "' onclick='this.lang = \"xxx\"; borrarImagen(\"" + mensaje0 + "\", \"" + mensajeN + "\");'>";
			
			html += "</p>";
			html += "<p>";
			html += "<img class='table_cuadro_gris' src='" + retroceso + nombreArchivo + "' alt=''>";
			html += "</p>";
			
			document.getElementById("table_cuadro_gris").rows[0].cells[cantidadCeldas].innerHTML = html;
			
			cantidadCeldas++;
			
			document.getElementById("table_cuadro_gris").rows[0].insertCell(cantidadCeldas);
			document.getElementById("table_cuadro_gris").rows[0].cells[cantidadCeldas].className = "table_cuadro_gris_borrar";
			
			html = "<img id='borrar_" + ((cantidadCeldas - 1) / 2) + "' class=table_cuadro_gris_borrar src='" + borrar + "' alt='" + tituloBorrar + "' onclick='this.lang = \"xxx\"; borrarImagen(\"" + mensaje0 + "\", \"" + mensajeN + "\");'>";
			
			document.getElementById("table_cuadro_gris").rows[0].cells[cantidadCeldas].innerHTML = html;
			
			//Cambia la cantidad de fotos:
			var restantes;
			if (navigator.appName == "Microsoft Internet Explorer") {
				restantes = document.getElementById("marco_ajax").contentWindow.document.getElementsByTagName("span")[2].childNodes[0].nodeValue;
			}
			else {
				restantes = document.getElementById("marco_ajax").contentDocument.getElementsByTagName("span")[2].childNodes[0].nodeValue;
			}
			document.getElementById("p_cant_fotos").innerHTML = mensajeN.replace("[[[x]]]", restantes).replace("[[[span]]]", "<span class='formulario_cantidad_fotos_numero'>").replace("[[[/span]]]", "</span>");
		}
	}
}

function moverIzquierda() {
	//Busca la posición:
	var elementos = document.getElementsByTagName("img");
	var conteo = -1;
	var posicion, x;
	for (x = 0; x < elementos.length; x++) {
		if (elementos[x].id.indexOf("izq_") == 0) {
			conteo++;
			if (elementos[x].lang == "xxx") {
				elementos[x].lang = "";
				posicion = conteo;
				break;
			}
		}
	}
	var xml = ajaxPeticionar("peticion=mover_imagen_izquierda&imagen=" + posicion);
	var resultado = xml.childNodes[0].childNodes[0].nodeValue;
	if (resultado == 1) {
		var x = document.getElementById("table_cuadro_gris").rows[0].cells[posicion * 2].innerHTML;
		document.getElementById("table_cuadro_gris").rows[0].cells[posicion * 2].innerHTML = document.getElementById("table_cuadro_gris").rows[0].cells[(posicion - 1) * 2].innerHTML;
		document.getElementById("table_cuadro_gris").rows[0].cells[(posicion - 1) * 2].innerHTML = x;
	}
}

function moverDerecha() {
	//Busca la posición:
	var elementos = document.getElementsByTagName("img");
	var conteo = -1;
	var posicion, x;
	for (x = 0; x < elementos.length; x++) {
		if (elementos[x].id.indexOf("der_") == 0) {
			conteo++;
			if (elementos[x].lang == "xxx") {
				elementos[x].lang = "";
				posicion = conteo;
				break;
			}
		}
	}
	var xml = ajaxPeticionar("peticion=mover_imagen_derecha&imagen=" + posicion);
	var resultado = xml.childNodes[0].childNodes[0].nodeValue;
	if (resultado == 1) {
		var x = document.getElementById("table_cuadro_gris").rows[0].cells[posicion * 2].innerHTML;
		document.getElementById("table_cuadro_gris").rows[0].cells[posicion * 2].innerHTML = document.getElementById("table_cuadro_gris").rows[0].cells[(posicion + 1) * 2].innerHTML;
		document.getElementById("table_cuadro_gris").rows[0].cells[(posicion + 1) * 2].innerHTML = x;
	}
}

function borrarImagen(mensaje0, mensajeN) {
	//Busca la posición:
	var elementos = document.getElementsByTagName("img");
	var conteo = -1;
	var posicion, x;
	for (x = 0; x < elementos.length; x++) {
		if (elementos[x].id.indexOf("borrar_") == 0) {
			conteo++;
			if (elementos[x].lang == "xxx") {
				elementos[x].lang = "";
				posicion = conteo / 2;
				break;
			}
		}
	}
	var xml = ajaxPeticionar("peticion=borrar_imagen&imagen=" + posicion);
	var resultado = xml.childNodes[0].childNodes[0].nodeValue;
	if (resultado <= 0) {
		try {
			document.getElementById("table_cuadro_gris").rows[0].deleteCell(posicion * 2);
		}
		catch (ex) {
		
		}
		try {
			document.getElementById("table_cuadro_gris").rows[0].deleteCell(posicion * 2);
		}
		catch (ex) {
		
		}
	}
	
	//Cambia la cantidad de fotos:
	resultado = Math.abs(resultado);
	var maximo = xml.childNodes[1].childNodes[0].nodeValue;
	if (resultado == maximo) {
		document.getElementById("p_cant_fotos").innerHTML = mensaje0.replace("[[[x]]]", resultado).replace("[[[span]]]", "<span class='formulario_cantidad_fotos_numero'>").replace("[[[/span]]]", "</span>");
	}
	else {
		document.getElementById("p_cant_fotos").innerHTML = mensajeN.replace("[[[x]]]", resultado).replace("[[[span]]]", "<span class='formulario_cantidad_fotos_numero'>").replace("[[[/span]]]", "</span>");
	}
}

function operarCuadroBuscar(evento, e, idioma) {
	if (evento == "onfocus" && cuadroBuscarUsado === false) {
		document.getElementById("qs_texto").value = "";
	}
	else if (evento == "onblur" && cuadroBuscarUsado === false) {
		document.getElementById("qs_texto").value = document.getElementById("qs_texto").lang;
	}
	else if (evento == "onkeyup" && e.keyCode == 13) {
		cuadroBuscarUsado = true;
		busquedaRapida(urlPais, idioma);
	}
	else if (evento == "onkeyup" && cuadroBuscarUsado === false && document.getElementById("qs_texto").value != "") {
		cuadroBuscarUsado = true;
	}
}

function conmutar_color_fondo_submit(id, estado) {
	if (estado == "link") {
		document.getElementById(id).className = "formulario_submit";
	}
	else {
		document.getElementById(id).className = "formulario_submit_hover";
	}
}

function conmutar_color_fondo_submit_atras(id, estado) {
	if (estado == "link") {
		document.getElementById(id).className = "formulario_submit_atras";
	}
	else {
		document.getElementById(id).className = "formulario_submit_hover_atras";
	}
}

function traducirTinyMCE(idioma, idCapa) {
	var cantidadElementos, x;
	switch (idioma) {
		case 1: //Castellano:
			cantidadElementos = document.getElementById(idCapa).childNodes.length;
			alert(document.getElementById(idCapa).innerHTML);
			/*
			for (x = 0; x < cantidadElementos; x++) {
				alert(document.getElementById(idCapa).childNodes[x].id);
			}
			*/
			break;
	}
}

function intercambiar(a, b) {
	var x = a;
	a = b;
	b = x;
}

/*function google_afs_request_done() {
	
}*/

function google_afs_request_done(google_ads) {
	try {
		var google_num_ads = google_ads.length;
		
		if (google_num_ads <= 0) {
			return;
		}
		
		var wideAds = "";   // wide ad unit html text
		var narrowAds = "";   // narrow ad unit html text

		var desde, hasta;
		hasta = cantidadAdsense - 1;
		if (hasta > google_num_ads - 1) hasta = google_num_ads - 1;
		desde = hasta - cantidadAvisosPorBloque + 1;
		if (desde < 0) desde = 0;
		
		for(i = 0; i < google_num_ads; i++) {
			if (google_ads[i].type=="text/wide") {
				// render a wide ad
				if (i >= desde && i <= hasta) {
					wideAds+='<a target="_blank" style="border:2px solid yellow;text-decoration:none" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="ad_line1">' + google_ads[i].line1 + '</span></a><br>' +
					'<span class="ad_text">' + google_ads[i].line2 + '</span>' +
					'<a target="_blank" style="text-decoration:none" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="ad_url">' + google_ads[i].visible_url + '</span></a>';
				}
			}
			else {
				var classNoBorder = '';
				if (i == 0) {
					classNoBorder = ' noBorder';
				}
				// render a narrow ad
				if (i >= desde && i <= hasta) {
					narrowAds+='<div class="narrowadNoImage' + classNoBorder + '"><a target="_blank" style="text-decoration:none" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="ad_line1">' + google_ads[i].line1 + '</span></a><br>' +
					'<span class="ad_text">' + google_ads[i].line2 + '</span>' +
					'<span class="ad_text">' + google_ads[i].line3 + '</span> - ' +
					'<a target="_blank" style="text-decoration:none" onmouseover="javascript:window.status=\'' +
					google_ads[i].url + '\';return true;" ' +
					'onmouseout="javascript:window.status=\'\';return true;" ' +
					'href="' + google_ads[i].url + '">' +
					'<span class="ad_url">' + google_ads[i].visible_url + '</span></a></div>'
				}
			}
		}
		
		if (narrowAds != "") {
			narrowAds = '<a target="_blank" style="text-decoration:none" ' +
				'href="http://services.google.com/feedback/online_hws_feedback">' +
				'<span class="ad_header" style="text-align:left">Ads by Google</span></a>' + narrowAds;
		}
		
		if (wideAds != "") {
			wideAds = '<a target="_blank" style="text-decoration:none" ' +
				'href="http://services.google.com/feedback/online_hws_feedback">' +
				'<span class="ad_header" style="text-align:left">Ads by Google</span><br><br></a>' + wideAds;
		}
		
		// Write HTML for wide and narrow ads to the proper <div> elements
		//document.getElementById("wide_ad_unit").innerHTML = wideAds;
		try {
			document.getElementById("narrow_ad_unit_" + canales).innerHTML = narrowAds;
		}
		catch (ex) {}
	}
	catch (ex) {}
}

function graduarImagen(id, anchoContenedor, altoContenedor, autoAjustar, centradoVertical) {
	var anchoImagen;
	var altoImagen;
	if (navigator.appName == "Microsoft Internet Explorer") {
		var nueva = new Image();
		nueva.src = document.getElementById(id).src;
		anchoImagen = nueva.width;
		altoImagen = nueva.height;
	}
	else {
		anchoImagen = document.getElementById(id).width;
		altoImagen = document.getElementById(id).height;
	}
	
	var factor = 0;
	if (anchoImagen >= altoImagen) {
		if (autoAjustar || anchoImagen > anchoContenedor) {
			factor = anchoContenedor / anchoImagen;
			anchoImagen = anchoContenedor;
			altoImagen *= factor;
		}
	}
	else {
		if (autoAjustar || altoImagen > altoContenedor) {
			factor = altoContenedor / altoImagen;
			altoImagen = altoContenedor;
			anchoImagen *= factor;
		}
	}
	if (anchoImagen > anchoContenedor) {
		factor = anchoContenedor / anchoImagen;
		anchoImagen = anchoContenedor;
		altoImagen *= factor;
	}
	if (altoImagen > altoContenedor) {
		factor = altoContenedor / altoImagen;
		altoImagen = altoContenedor;
		anchoImagen *= factor;
	}
	document.getElementById(id).width = anchoImagen;
	document.getElementById(id).height = altoImagen;
	document.getElementById(id).style.position = "static";
	document.getElementById(id).style.visibility = "visible";
	if (navigator.appName == "Microsoft Internet Explorer" && centradoVertical) {
		document.getElementById(id).style.marginTop = Math.ceil((altoContenedor - altoImagen) / 2) + "px";
	}
}

function agregarAFavoritos(codigoAviso, codigoUsuario) {
	var xml = ajaxPeticionar("peticion=agregar_favorito&codigo_aviso=" + codigoAviso + "&codigo_usuario=" + codigoUsuario);
	var resultado = xml.childNodes[0].childNodes[0].nodeValue;
	if (resultado == 1) {
		alert(mensajeFavoritosOk);
	}
	else {
		alert(mensajeFavoritosError);
	}
}

function reportarAbuso(evento, codigoAviso) {
	var idiomaSitio = idiomaIANA.toLowerCase();
	var prefijo;
	
	switch (idiomaSitio) {
		case "pt":
			prefijo = "abuso";
			break;
		case "en":
			prefijo = "abuse";
			break;
		default:
			prefijo = "abuso";
	}
	
	var anchoDiv = 560;
	
	if (navigator.appName == "Microsoft Internet Explorer") {
		var anchuraPantalla = document.body.clientWidth;
	}
	else {
		var anchuraPantalla = window.innerWidth;
	}
	var e = (window.event) ? window.event : evento;
	var izquierda;
	var arriba;
	if (navigator.appName != "Microsoft Internet Explorer") {
		arriba = 70 + window.scrollY;
		izquierda = Math.floor((anchuraPantalla - anchoDiv) / 2) + window.scrollX;
		//document.getElementById("div_abuso").style.position = "fixed";
	}
	else {
		arriba = document.body.scrollTop + 70;
		izquierda = Math.floor((anchuraPantalla - anchoDiv) / 2) + document.body.scrollLeft;
	}
	document.getElementById("div_bloqueo_pagina").style.display = "inline";
	document.getElementById("div_abuso").style.left = izquierda + "px";
	document.getElementById("div_abuso").style.top = arriba + "px";
	document.getElementById("template_header_quick_search").style.visibility = "hidden";
	document.getElementById("div_abuso").style.display = "inline";
	document.getElementById("iframe_abuso").src = "/" + prefijo + "/" + codigoAviso;
}

function cerrarReporteAbuso() {
	try {
		document.getElementById("div_bloqueo_pagina").style.display = "none";
		document.getElementById("template_header_quick_search").style.visibility = "visible";
		document.getElementById("div_abuso").style.display = "none";
	}
	catch (ex) {
		
	}
}

function reubicarReporteAbuso() {
	var anchoDiv = 560;
	
	if (navigator.appName == "Microsoft Internet Explorer") {
		var anchuraPantalla = document.body.clientWidth;
	}
	else {
		var anchuraPantalla = window.innerWidth;
	}
	var izquierda;
	var arriba;
	if (navigator.appName != "Microsoft Internet Explorer") {
		arriba = 70 + window.scrollY;
		izquierda = Math.floor((anchuraPantalla - anchoDiv) / 2) + window.scrollX;
		//document.getElementById("div_abuso").style.position = "fixed";
	}
	else {
		arriba = document.body.scrollTop + 70;
		izquierda = Math.floor((anchuraPantalla - anchoDiv) / 2) + document.body.scrollLeft;
	}
	document.getElementById("div_abuso").style.left = izquierda + "px";
	document.getElementById("div_abuso").style.top = arriba + "px";
}

function galeriaMostrarImagen(idMiniatura, idContenedor, anchoImagenFichaAviso, altoImagenFichaAviso) {
	var arreglo = idMiniatura.split("_");
	var posicion = arreglo[arreglo.length - 1];
	
	if (imagenesCargadas) {
		if (navigator.appName != "Microsoft Internet Explorer") {
			document.getElementById(idContenedor).innerHTML = "<img class='modificable' id='imagen_item' src='" + galeria[posicion] + "' onload='graduarImagen(this.id, " + anchoImagenFichaAviso + ", " + altoImagenFichaAviso + ", false, true);'>";
		}
		else {
			document.getElementById("imagen_item").src = galeria[posicion];
		}
	}
}

function decimalHexadecimal(valor) {
	var signo = ((valor < 0) ? -1 : 1);
	var cociente, resto;
	valor = Math.abs(valor);
	var resultado = "";
	while (true) {
		cociente = Math.floor(valor / 16);
		resto = valor % 16;
		if (resto <= 9)
			resultado = String(resto) + resultado;
		else
			resultado = String.fromCharCode(65 + (resto - 10)) + resultado;
		if (cociente == 0) break;
		valor = cociente;
	}
	if (signo == -1) resultado = "-" + resultado;
	return resultado;
}

function urlencode_modificada(texto) {
	var listaDeCaracteres = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ € ‚ƒ„…†‡ˆ‰Š‹Œ Ž  ‘’“”•–—˜™š›œ žŸ ¡¢£ ¥|§¨©ª«¬¯®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ";
	var caracteresInalterables = "!\"$'()*,-.0123456789;<>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~";
	var caracteres_1_encoding = "";
	var longitud = texto.length;
	var resultado = "";
	var hexa;
	var caracter;
	var codigoCaracter;
	for (var posicion = 0; posicion < longitud; posicion++) {
		caracter = texto.substr(posicion, 1);
		if (caracter == " ") {
			caracter = "+";
		}
		else if (caracteresInalterables.indexOf(caracter) == -1) { //Carácter que necesita modificación.
			codigoCaracter = listaDeCaracteres.indexOf(caracter) + 32;
			if (codigoCaracter == 31) { //El carácter no es válido o su ASCII es menor que 31.
				if (caracter.charCodeAt(0) > 0 && caracter.charCodeAt(0) < 32) {
					hexa = decimalHexadecimal(caracter.charCodeAt(0));
					if (hexa.length == 1) hexa = "0" + "" + hexa;
					if (caracteres_1_encoding.indexOf(caracter) == -1) {
						caracter = "%25" + hexa;
					}
					else {
						caracter = "%" + hexa;
					}
				}
				else {
					//Es un carácter cuyo código es superior a 255:
					//caracter = "%26%23" + caracter.charCodeAt(0) + ";";
					caracter = "%2526%2523" + caracter.charCodeAt(0) + ";";
				}
			}
			else {
				hexa = decimalHexadecimal(codigoCaracter);
				if (hexa.length == 1) hexa = "0" + "" + hexa;
				if (caracteres_1_encoding.indexOf(caracter) == -1) {
					caracter = "%25" + hexa;
				}
				else {
					caracter = "%" + hexa;
				}
			}
		}
		resultado += caracter;
	}
	
	return resultado;
}

function despacharMensaje(codigo, msgEnviado) {
	var nombre = document.getElementById("posting_nombre").value;
	var mail = document.getElementById("posting_mail").value;
	var comentarios = document.getElementById("posting_comentarios").value;
	var captcha = document.getElementById("posting_captcha_ingresado").value;
	var xml = ajaxPeticionar("peticion=contactar_anunciante&codigo=" + codigo + "&nombre=" + urlencode_modificada(nombre) + "&mail=" + urlencode_modificada(mail) + "&comentarios=" + urlencode_modificada(comentarios) + "&captcha_ingresado=" + captcha);
	var resultado = xml.childNodes[0].childNodes[0].nodeValue;
	document.getElementById("view_item_errores").rows[0].cells[0].innerHTML = "";
	if (resultado == 0) {
		//Hay errores:
		document.getElementById("view_item_mail_enviado").style.display = "none";
		if (xml.childNodes.length > 1) {
			//Hay descripción de los errores:
			var errores = "";
			var cantidadErrores = xml.childNodes[1].childNodes.length;
			var x;
			for (x = 0; x < cantidadErrores; x++) {
				errores += ("<p>" + xml.childNodes[1].childNodes[x].childNodes[0].nodeValue + "</p>");
			}
			document.getElementById("view_item_errores").rows[0].cells[0].innerHTML += errores;
			document.getElementById("view_item_errores").style.display = "inline";
		}
		else {
			document.getElementById("view_item_errores").style.display = "none";
		}
		
		return false;
	}
	else {
		document.getElementById("view_item_errores").style.display = "none";
		document.getElementById("posting_nombre").value = "";
		document.getElementById("posting_mail").value = "";
		document.getElementById("posting_comentarios").value = "";
		document.getElementById("posting_captcha_ingresado").value = "";
		document.getElementById("captcha").src = "";
		document.getElementById("captcha").src = "nl_captcha.php?aleatorio=" + String(Math.random()) + String(Math.random()) + String(Math.random()) + String(Math.random()) + String(Math.random()) + String(Math.random()) + String(Math.random()) + String(Math.random()) + String(Math.random()) + String(Math.random());
		//document.getElementById("view_item_mail_enviado").style.display = "inline";
		alert(msgEnviado);
		
		return false;
	}
}

function armarUrlBusquedaRapida(texto, categoria, provincia, pagina, idioma) {
	var urlBasica;
	if (categoria == "") {
		alert(mensajeAusenciaCategoriaBusqueda);
		return false;
	}
	
	switch (idioma) {
		case 1:
			urlBasica = "clasificados";
			break;
		case 2:
			urlBasica = "classificados";
			break;
		case 3:
			urlBasica = "free-clasiffieds-ads";
			break;
	}
	
	if (pagina == "") pagina = 1;
	if (texto == "" && categoria == "" && pagina > 1) {
		urlBasica += ("-p" + pagina);
	}
	else if (texto == "" && categoria != "" && pagina == 1) {
		urlBasica += ("-" + categoria);
	}
	else if (texto == "" && categoria != "" && pagina > 1) {
		urlBasica += ("-" + categoria + "-p" + pagina);
	}
	else if (texto != "" && categoria == "") {
		urlBasica += ("-p" + pagina + "-vl-" + urlencode_modificada(texto));
	}
	else if (texto != "" && categoria != "") {
		urlBasica += ("-p" + pagina + "-vl-" + urlencode_modificada(texto) + "-sh-" + categoria.substr(1, categoria.indexOf("-") - 1));
	}
	
	if (provincia != "") {
		urlBasica += ("/" + urlencode_modificada(provincia));
	}
	
	return urlBasica;
}

function busquedaRapida(dominioBase, idioma) {
	//Captura los datos del buscador rápido, genera la URL correspondiente y la carga.
	var texto;
	var subdominioFinal;
	var x1, x2;
	
	if (cuadroBuscarUsado == false) {
		texto = "";
	}
	else {
		texto = document.getElementById("qs_texto").value;
	}
	
	var categoria = document.getElementById("qs_categoria").options[document.getElementById("qs_categoria").selectedIndex].value;
	var provincia = document.getElementById("qs_provincia").options[document.getElementById("qs_provincia").selectedIndex].value;
	var url = armarUrlBusquedaRapida (texto, categoria, provincia, 1, idioma);
	
	if (provincia == "") {
		subdominioFinal = dominioBase.replace("<subdominio>", "").replace("</subdominio>", "");
	}
	else {
		x1 = dominioBase.indexOf(">");
		x2 = dominioBase.indexOf("<", x1);
		subdominioFinal = String(dominioBase.substr(0, x1 + 1) + provincia + "." + dominioBase.substr(x2)).replace("<subdominio>", "").replace("</subdominio>", "");
	}
	
	if (url !== false) location.href = subdominioFinal + url;
}

function reconvertirEspeciales(texto) {

}

function obtenerVisitas(codigo) {
	var xml = ajaxPeticionar("peticion=obtener_visitas&codigo=" + codigo);
	var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
	if (resultado == 1) {
		return xml.childNodes[0].nodeValue;
	}
	else {
		return "";
	}
}

function imprimirEnlacesUsuario(especial) {
	var xml = ajaxPeticionar("peticion=enlaces_usuario&especial=" + especial);
	return xml.childNodes[0].childNodes[0].nodeValue;
}

function imprimirEnlacesUsuarioPie(especial) {
	var xml = ajaxPeticionar("peticion=enlaces_usuario_pie&especial=" + especial);
	return reemplazarTodo("&#160;", " ", reemplazarTodo("&nbsp;", " ", xml.childNodes[0].childNodes[0].nodeValue));
}

function imprimirEnlacesUsuarioPieSinUsoFacebook(especial) {
	var xml = ajaxPeticionar("peticion=enlaces_usuario_pie&para_nl=1&especial=" + especial);
	return reemplazarTodo("&#160;", " ", reemplazarTodo("&nbsp;", " ", xml.childNodes[0].childNodes[0].nodeValue));
}

function imprimirEnlacesUsuarioPieFbSuperior(especial) {
	var xml = ajaxPeticionar("peticion=enlaces_usuario_pie&fb_superior=1&especial=" + especial);
	return reemplazarTodo("&#160;", " ", reemplazarTodo("&nbsp;", " ", xml.childNodes[0].childNodes[0].nodeValue));
}

function reemplazarTodo(textoBuscado, textoSustituto, cadena) {
	return cadena.split(textoBuscado).join(textoSustituto);
}

function mostrarMenu(id) {
	//Obtiene la cantidad de menús:
	var menus = document.getElementsByTagName("div");
	var cantidadMenus = 0;
	for (var x = 0; x < menus.length; x++) {
		if (menus[x].id.indexOf("menu_") >= 0) cantidadMenus++;
	}
	for (x = 0; x < cantidadMenus; x++) {
		if (x == id) {
			document.getElementById("menu_" + x).style.visibility = "visible";
		}
		else {
			document.getElementById("menu_" + x).style.visibility = "hidden";
		}
	}
}

function arrayQuitarDuplicados(arreglo) {
	var longitud = arreglo.length;
	var temporal, ultimoValor, proximaPosicion;
	if (longitud > 0) {
		arreglo.sort();
		temporal = arreglo;
		ultimoValor = temporal[0];
		arreglo = new Array();
		arreglo[0] = temporal[0];
		for (var x = 1; x < longitud; x++) {
			if (temporal[x] !== ultimoValor) {
				ultimoValor = temporal[x];
				proximaPosicion = arreglo.length;
				arreglo[proximaPosicion] = temporal[x];
			}
		}
	}
	
	return arreglo;
}

function arrayBuscar(arreglo, valor) {
	var longitud = arreglo.length;
	for (var x = 0; x < longitud; x++) {
		if (arreglo[x] == valor) return x;
	}
	
	return false;
}

function backofficeMarcarTodos() {
	var elementos = document.getElementsByTagName("input");
	var cantidad = elementos.length;
	for (var x = 0; x < cantidad; x++) {
		if (elementos[x].type == "checkbox" && elementos[x].id.indexOf("chk_registro_") == 0) {
			elementos[x].checked = true;
		}
	}
}

function backofficeDesmarcarTodos() {
	var elementos = document.getElementsByTagName("input");
	var cantidad = elementos.length;
	for (var x = 0; x < cantidad; x++) {
		if (elementos[x].type == "checkbox" && elementos[x].id.indexOf("chk_registro_") == 0) {
			elementos[x].checked = false;
		}
	}
}

function armarUrlBackofficeAvisos(filtro, orden, pagina) {
	return "/backoffice/administrar-aviso/" + filtro + "/" + orden + "/" + pagina;
}

function armarUrlBackofficeAvisosConBusqueda(filtro, orden, pagina, campoBusqueda, textoBusqueda) {
	return "/backoffice/administrar-aviso/" + filtro + "/" + orden + "/" + pagina + "/" + campoBusqueda + "/" + urlencode_modificada(textoBusqueda);
}

function backofficeReordenarAvisos(filtro, pagina) {
	var opcion = document.getElementById("backoffice_orden").options[document.getElementById("backoffice_orden").selectedIndex].value;
	location.href = armarUrlBackofficeAvisos(filtro, opcion, pagina);
}

function backofficeFiltrarAvisos(orden, pagina) {
	var opcion = document.getElementById("backoffice_filtro").options[document.getElementById("backoffice_filtro").selectedIndex].value;
	location.href = armarUrlBackofficeAvisos(opcion, orden, pagina);
}

function backofficeBuscarAvisos(filtro, orden, pagina) {
	var opcion = document.getElementById("backoffice_campo").options[document.getElementById("backoffice_campo").selectedIndex].value;
	var texto = document.getElementById("backoffice_texto").value;
	location.href = armarUrlBackofficeAvisosConBusqueda(filtro, orden, pagina, opcion, texto);
}

function backofficeObtenerCodigosAvisos() {
	var elementos = document.getElementsByTagName("input");
	var cantidad = elementos.length;
	var codigos = new Array();
	var arreglo;
	var contador = 0;
	for (var x = 0; x < cantidad; x++) {
		if (elementos[x].type == "checkbox" && elementos[x].id.indexOf("chk_registro_") == 0 && elementos[x].checked) {
			arreglo = elementos[x].id.split("_");
			codigos[contador] = arreglo[arreglo.length - 2] * 1;
			contador++;
		}
	}
	if (codigos.length == 0) {
		return "";
	}
	else {
		return arrayQuitarDuplicados(codigos).join(",");
	}
}

function fechaHoraActualServidor(idioma) {
	var xml = ajaxPeticionar("peticion=fecha_hora_actual&idioma=" + idioma);
	var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
	return resultado;
}

function backofficeAprobarAvisos(codigosAvisos) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=aprobar_avisos&codigos=" + codigosAvisos);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("backoffice_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[0].childNodes[0].id.split("_");
				codigo = codigo[codigo.length - 2];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						tabla.rows[x].cells[y].className = "backoffice_administrar_avisos_vigente";
						if (tabla.rows[x].cells[y].lang == 1) tabla.rows[x].cells[y].className += " backoffice_administrar_avisos_spam";
						if (y > 0) {
							if (tabla.rows[x].cells[y].childNodes.length > 0) {
								try {
									tabla.rows[x].cells[y].childNodes[0].className = "backoffice_administrar_avisos_vigente";
								}
								catch (ex) {
								
								}
							}
							if (tabla.rows[x].cells[y].lang == 1) tabla.rows[x].cells[y].childNodes[0].className += " backoffice_administrar_avisos_spam";
						}
					}
					tabla.rows[x].cells[16].innerHTML = "&nbsp;";
					tabla.rows[x].cells[17].innerHTML = "&nbsp;";
					tabla.rows[x].cells[18].innerHTML = "&nbsp;";
				}
			}
		}
	}
}

function backofficeMarcarComoPendientes(codigosAvisos) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=marcar_avisos_pendientes&codigos=" + codigosAvisos);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("backoffice_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[0].childNodes[0].id.split("_");
				codigo = codigo[codigo.length - 2];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						tabla.rows[x].cells[y].className = "backoffice_administrar_avisos_pendiente";
						if (tabla.rows[x].cells[y].lang == 1) tabla.rows[x].cells[y].className += " backoffice_administrar_avisos_spam";
						if (y > 0) {
							if (tabla.rows[x].cells[y].childNodes.length > 0) {
								try {
									tabla.rows[x].cells[y].childNodes[0].className = "backoffice_administrar_avisos_pendiente";
								}
								catch (ex) {
								
								}
							}
							if (tabla.rows[x].cells[y].lang == 1) tabla.rows[x].cells[y].childNodes[0].className += " backoffice_administrar_avisos_spam";
						}
					}
					tabla.rows[x].cells[16].innerHTML = "&nbsp;";
					tabla.rows[x].cells[17].innerHTML = "&nbsp;";
					tabla.rows[x].cells[18].innerHTML = "&nbsp;";
				}
			}
		}
	}
}

function backofficeBorrarAvisosMotivos(codigosAvisos, urlMotivos) {
	if (ventanaMotivos !== false || codigosAvisos == "") return;
	
	//Exhibe la ventana de causas de baja:
	var parametros = new Array();
	parametros["ancho"] = 500;
	parametros["alto"] = 200;
	parametros = centrarVentana(parametros["ancho"], parametros["alto"]);
	
	ventanaMotivos = window.open(urlMotivos, "", "left=" + parametros["izquierda"] + ",top=" + parametros["arriba"] + ",width=" + parametros["ancho"] + ",height=" + parametros["alto"]);
}

function backofficeBorrarAvisos(codigosAvisos, causaDeBaja) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=borrar_avisos&codigos=" + codigosAvisos + "&motivo=" + causaDeBaja);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("backoffice_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[0].childNodes[0].id.split("_");
				codigo = codigo[codigo.length - 2];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						tabla.rows[x].cells[y].className = "backoffice_administrar_avisos_borrado";
						if (tabla.rows[x].cells[y].lang == 1) tabla.rows[x].cells[y].className += " backoffice_administrar_avisos_spam";
						if (y > 0) {
							if (tabla.rows[x].cells[y].childNodes.length > 0) {
								try {
									tabla.rows[x].cells[y].childNodes[0].className = "backoffice_administrar_avisos_borrado";
								}
								catch (ex) {
								
								}
							}
							if (tabla.rows[x].cells[y].lang == 1) tabla.rows[x].cells[y].childNodes[0].className += " backoffice_administrar_avisos_spam";
						}
					}
					tabla.rows[x].cells[16].innerHTML = usuarioLogeado;
					tabla.rows[x].cells[17].innerHTML = fechaHoraActualServidor(idiomaActual);
					tabla.rows[x].cells[18].innerHTML = arrayMotivosBaja[causaDeBaja];
				}
			}
		}
	}
}

function reiniciarContadorSpam(codigosAvisos) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=reiniciar_contador_spam&codigos=" + codigosAvisos);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("backoffice_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[0].childNodes[0].id.split("_");
				codigo = codigo[codigo.length - 2];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						tabla.rows[x].cells[y].lang = 0;
						tabla.rows[x].cells[y].className = tabla.rows[x].cells[y].className.substr(0, tabla.rows[x].cells[y].className.indexOf(" "));
						if (y > 0) {
							if (tabla.rows[x].cells[y].childNodes.length > 0) {
								try {
									tabla.rows[x].cells[y].childNodes[0].className = tabla.rows[x].cells[y].childNodes[0].className.substr(0, tabla.rows[x].cells[y].childNodes[0].className.indexOf(" "));
								}
								catch (ex) {
								
								}
							}
							if (tabla.rows[x].cells[y].childNodes[0].childNodes.length > 0) {
								if (tabla.rows[x].cells[y].childNodes[0].childNodes[0].lang == codigo) {
									tabla.rows[x].cells[y].childNodes[0].childNodes[0].innerHTML = 0;
								}
							}
						}
					}
				}
			}
		}
	}
}

function backofficeMarcarComoModerado(codigosAvisos) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=marcar_avisos_moderados&codigos=" + codigosAvisos);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("backoffice_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[1].id.split("_");
				codigo = codigo[codigo.length - 2];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						if (tabla.rows[x].cells[y].lang.indexOf("<img") == 0) {
							tabla.rows[x].cells[y].innerHTML = tabla.rows[x].cells[y].lang;
						}
					}
				}
			}
		}
	}
}

function backofficeDesmarcarComoModerado(codigosAvisos) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=desmarcar_avisos_moderados&codigos=" + codigosAvisos);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("backoffice_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[1].id.split("_");
				codigo = codigo[codigo.length - 2];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						if (tabla.rows[x].cells[y].lang.indexOf("<img") == 0) {
							tabla.rows[x].cells[y].innerHTML = "&nbsp;";
						}
					}
				}
			}
		}
	}
}

function armarUrlBackofficeUsuarios(filtro, orden, pagina) {
	return "/backoffice/administrar-usuarios/" + filtro + "/" + orden + "/" + pagina;
}

function armarUrlBackofficeUsuariosConBusqueda(filtro, orden, pagina, campoBusqueda, textoBusqueda) {
	return "/backoffice/administrar-usuarios/" + filtro + "/" + orden + "/" + pagina + "/" + campoBusqueda + "/" + urlencode_modificada(textoBusqueda);
}

function backofficeFiltrarUsuarios(orden, pagina) {
	var opcion = document.getElementById("backoffice_filtro").options[document.getElementById("backoffice_filtro").selectedIndex].value;
	location.href = armarUrlBackofficeUsuarios(opcion, orden, pagina);
}

function backofficeBuscarUsuarios(filtro, orden, pagina) {
	var opcion = document.getElementById("backoffice_campo").options[document.getElementById("backoffice_campo").selectedIndex].value;
	var texto = document.getElementById("backoffice_texto").value;
	location.href = armarUrlBackofficeUsuariosConBusqueda(filtro, orden, pagina, opcion, texto);
}

function backofficeReordenarUsuarios(filtro, pagina) {
	var opcion = document.getElementById("backoffice_orden").options[document.getElementById("backoffice_orden").selectedIndex].value;
	location.href = armarUrlBackofficeUsuarios(filtro, opcion, pagina);
}

function backofficeObtenerCodigosUsuarios() {
	var elementos = document.getElementsByTagName("input");
	var cantidad = elementos.length;
	var codigos = new Array();
	var arreglo;
	var contador = 0;
	for (var x = 0; x < cantidad; x++) {
		if (elementos[x].type == "checkbox" && elementos[x].id.indexOf("chk_registro_") == 0 && elementos[x].checked) {
			arreglo = elementos[x].id.split("_");
			codigos[contador] = arreglo[arreglo.length - 1] * 1;
			contador++;
		}
	}
	if (codigos.length == 0) {
		return "";
	}
	else {
		return arrayQuitarDuplicados(codigos).join(",");
	}
}

function backofficeHabilitarUsuario(codigosAvisos) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=habilitar_usuarios&codigos=" + codigosAvisos);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("backoffice_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[0].childNodes[0].id.split("_");
				codigo = codigo[codigo.length - 1];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						tabla.rows[x].cells[y].className = "backoffice_administrar_avisos_vigente";
						if (tabla.rows[x].cells[y].lang == 1) {
							tabla.rows[x].cells[y].childNodes[0].className = "backoffice_administrar_avisos_vigente";
						}
					}
				}
			}
		}
	}
}

function backofficeBloquearUsuario(codigosAvisos) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=bloquear_usuarios&codigos=" + codigosAvisos);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("backoffice_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[0].childNodes[0].id.split("_");
				codigo = codigo[codigo.length - 1];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						tabla.rows[x].cells[y].className = "backoffice_administrar_avisos_borrado";
						if (tabla.rows[x].cells[y].lang == 1) {
							tabla.rows[x].cells[y].childNodes[0].className = "backoffice_administrar_avisos_borrado";
						}
					}
				}
			}
		}
	}
}

function backofficeActivarCuentaUsuario(codigosAvisos) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=activar_cuentas_usuarios&codigos=" + codigosAvisos);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("backoffice_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[0].childNodes[0].id.split("_");
				codigo = codigo[codigo.length - 1];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						if (tabla.rows[x].cells[y].lang == 2) {
							tabla.rows[x].cells[y].innerHTML = "[X]";
						}
					}
				}
			}
		}
	}
}

function armarUrlMisAvisos(pagina, filtro, orden, tipo_orden, id, idioma) {
	var urlBasica;
	
	switch (idioma) {
		case 1:
			urlBasica = "/mis-avisos";
			break;
		case 2:
			urlBasica = "/meus-anuncios";
			break;
		case 3:
			urlBasica = "/my-ads";
			break;
	}
	
	
	if (pagina == "") pagina = 1;
	if (filtro == "") filtro = "todos";
	if (orden == "") orden = "fecha";
	if (tipo_orden == "") tipo_orden = "desc";
	if (id == "") id = 0;
	
	return urlBasica + "/" + pagina + "/" + filtro + "/" + orden + "/" + tipo_orden + "/" + id;
}

function miCuentaFiltrarAvisos(pagina, orden, tipo_orden, id, idioma) {
	var opcion = document.getElementById("mi_cuenta_filtro").options[document.getElementById("mi_cuenta_filtro").selectedIndex].value;
	location.href = armarUrlMisAvisos(pagina, opcion, orden, tipo_orden, id, idioma);
}

function miCuentaReordenarAvisos(pagina, filtro, tipo_orden, id, idioma) {
	var opcion = document.getElementById("mi_cuenta_orden").options[document.getElementById("mi_cuenta_orden").selectedIndex].value;
	location.href = armarUrlMisAvisos(pagina, filtro, opcion, tipo_orden, id, idioma);
}

function miCuentaReordenarAvisosTipoOrden(pagina, filtro, orden, id, idioma) {
	var opcion = document.getElementById("mi_cuenta_tipo_orden").options[document.getElementById("mi_cuenta_tipo_orden").selectedIndex].value;
	location.href = armarUrlMisAvisos(pagina, filtro, orden, opcion, id, idioma);
}

function miCuentaBuscarId(pagina, filtro, orden, tipo_orden, idioma) {
	var valor = document.getElementById("mi_cuenta_tipo_id").value;
	if (!isNaN(valor)) {
		valor = parseInt(valor);
		if (valor < 0 || valor > 18446744073709551616) {
			valor = 0;
		}
	}
	else {
		valor = 0;
	}
	
	location.href = armarUrlMisAvisos(pagina, filtro, orden, tipo_orden, valor, idioma);
}

function miCuentaMarcarTodos() {
	var elementos = document.getElementsByTagName("input");
	var cantidad = elementos.length;
	for (var x = 0; x < cantidad; x++) {
		if (elementos[x].type == "checkbox" && elementos[x].id.indexOf("chk_aviso_") == 0) {
			elementos[x].checked = true;
		}
	}
}

function miCuentaDesmarcarTodos() {
	var elementos = document.getElementsByTagName("input");
	var cantidad = elementos.length;
	for (var x = 0; x < cantidad; x++) {
		if (elementos[x].type == "checkbox" && elementos[x].id.indexOf("chk_aviso_") == 0) {
			elementos[x].checked = false;
		}
	}
}

function operarCuadroId(evento, e) {
	if (evento == "onfocus" && cuadroIdUsado === false) {
		document.getElementById("mi_cuenta_tipo_id").value = "";
	}
	else if (evento == "onblur" && cuadroIdUsado === false) {
		document.getElementById("mi_cuenta_tipo_id").value = document.getElementById("mi_cuenta_tipo_id").lang;
	}
	else if (evento == "onkeyup" && e.keyCode == 13) {
		cuadroIdUsado = true;
		document.getElementById("mi_cuenta_button").click();
	}
	else if (evento == "onkeyup" && cuadroIdUsado === false && document.getElementById("mi_cuenta_tipo_id").value != "") {
		cuadroIdUsado = true;
	}
}

function miCuentaObtenerCodigosAvisos() {
	var elementos = document.getElementsByTagName("input");
	var cantidad = elementos.length;
	var codigos = new Array();
	var arreglo;
	var contador = 0;
	for (var x = 0; x < cantidad; x++) {
		if (elementos[x].type == "checkbox" && elementos[x].id.indexOf("chk_aviso_") == 0 && elementos[x].checked) {
			arreglo = elementos[x].id.split("_");
			codigos[contador] = arreglo[arreglo.length - 1] * 1;
			contador++;
		}
	}
	if (codigos.length == 0) {
		return "";
	}
	else {
		return arrayQuitarDuplicados(codigos).join(",");
	}
}

function miCuentaBorrarAvisos(codigosAvisos, imagenInactivo, altInactivo) {
	if (codigosAvisos.length > 0) {
		var xml = ajaxPeticionar("peticion=autogestion_borrar_avisos&codigos=" + codigosAvisos);
		var resultado = xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var codigos = xml.getElementsByTagName("codigos")[0].childNodes[0].nodeValue.split(",");
			var tabla = document.getElementById("mi_cuenta_desglose_avisos");
			var filas = tabla.rows.length;
			var celdas, y;
			var codigo;
			for (var x = 1; x < filas; x++) {
				codigo = tabla.rows[x].cells[0].childNodes[0].id.split("_");
				codigo = codigo[codigo.length - 1];
				if (arrayBuscar(codigos, codigo) !== false) {
					celdas = tabla.rows[x].cells.length;
					for (y = 0; y < celdas; y++) {
						if (tabla.rows[x].cells[y].lang == 3) {
							tabla.rows[x].cells[y].childNodes[0].src = imagenInactivo;
							tabla.rows[x].cells[y].childNodes[0].alt = altInactivo;
							tabla.rows[x].cells[y].childNodes[0].title = altInactivo;
						}
					}
				}
			}
		}
	}
}

function eliminarFavorito(codigoAviso, codigoUsuario) {
	var xml = ajaxPeticionar("peticion=quitar_favorito&codigo_aviso=" + codigoAviso + "&codigo_usuario=" + codigoUsuario);
	location.reload();
}

function mostrarCamposQuickSearch() {
	document.getElementById("qs_texto").style.display = "inline";
	document.getElementById("qs_categoria").style.display = "inline";
	document.getElementById("qs_provincia").style.display = "inline";
}

function consentimientoAdulto() {
	var xml = ajaxPeticionar("peticion=consentimiento_adulto");
}

function obtenerConsentimientoAdulto() {
	var xml = ajaxPeticionar("peticion=obtener_consentimiento_adulto");
	return xml.getElementsByTagName("resultado")[0].childNodes[0].nodeValue;
}

function seleccionarURL(izquierda, tituloIzquierda, derecha, tituloDerecha, borrar, tituloBorrar, mensaje0, mensajeN, mensajeEntrada) {
	var nuevaURL = prompt(mensajeEntrada);
	if (nuevaURL == null) return;
	
	var longitud = nuevaURL.length;
	if (longitud > 0) {
		var URLAdaptada = "";
		var x;
		for (x = 0; x < longitud; x++) {
			URLAdaptada = URLAdaptada + ("" + nuevaURL.charCodeAt(x) + "@");
		}
		URLAdaptada = URLAdaptada.substr(0, URLAdaptada.length - 1);
		
		var xml = ajaxPeticionar("peticion=insertar_url_nexoanunciante&url=" + URLAdaptada);
		var resultado = xml.childNodes[0].childNodes[0].childNodes[0].nodeValue;
		if (resultado == 1) {
			var cantidadCeldas = document.getElementById("table_cuadro_gris").rows[0].cells.length;
			document.getElementById("table_cuadro_gris").rows[0].insertCell(cantidadCeldas);
			document.getElementById("table_cuadro_gris").rows[0].cells[cantidadCeldas].className = "table_cuadro_gris";
			
			var html = "<p class=table_cuadro_gris_flechas>";
			html += "<img id='izq_" + (cantidadCeldas / 2) + "' src='" + izquierda + "' alt='" + tituloIzquierda + "' onclick='this.lang = \"xxx\"; moverIzquierda();'>";
			html += "&nbsp;&nbsp;&nbsp;";
			html += "<img id='der_" + (cantidadCeldas / 2) + "' src='" + derecha + "' alt='" + tituloDerecha + "' onclick='this.lang = \"xxx\"; moverDerecha();'>";
			html += "&nbsp;&nbsp;&nbsp;&nbsp;";
			html += "<img id='borrar_" + ((cantidadCeldas - 1) / 2) + "' src='" + borrar + "' alt='" + tituloBorrar + "' onclick='this.lang = \"xxx\"; borrarImagen(\"" + mensaje0 + "\", \"" + mensajeN + "\");'>";
			
			html += "</p>";
			html += "<p>";
			html += "<img class='table_cuadro_gris' src='" + nuevaURL + "' alt=''>";
			html += "</p>";
			
			document.getElementById("table_cuadro_gris").rows[0].cells[cantidadCeldas].innerHTML = html;
			
			cantidadCeldas++;
			
			document.getElementById("table_cuadro_gris").rows[0].insertCell(cantidadCeldas);
			document.getElementById("table_cuadro_gris").rows[0].cells[cantidadCeldas].className = "table_cuadro_gris_borrar";
			
			html = "<img id='borrar_" + ((cantidadCeldas - 1) / 2) + "' class=table_cuadro_gris_borrar src='" + borrar + "' alt='" + tituloBorrar + "' onclick='this.lang = \"xxx\"; borrarImagen(\"" + mensaje0 + "\", \"" + mensajeN + "\");'>";
			
			document.getElementById("table_cuadro_gris").rows[0].cells[cantidadCeldas].innerHTML = html;
			
			//Cambia la cantidad de fotos:
			var restantes = xml.getElementsByTagName("restantes")[0].childNodes[0].nodeValue;
			document.getElementById("p_cant_fotos").innerHTML = mensajeN.replace("[[[x]]]", restantes).replace("[[[span]]]", "<span class='formulario_cantidad_fotos_numero'>").replace("[[[/span]]]", "</span>");
		}
		else {
			//Imprime los mensajes de error:
			var cantMensajes = xml.getElementsByTagName("mensaje");
			longitud = cantMensajes.length;
			for (x = 0; x < longitud; x++) {
				alert(cantMensajes[x].childNodes[0].nodeValue);
			}
		}
	}
}

function eliminarEstatizado(codigoAviso, pais, mensajeOk, mensajeError) {
	var cod = codigoAviso * 1;
	if (cod < 1 || isNaN(cod) || cod == Infinity) return mensajeError;
	var xml = ajaxPeticionar("peticion=eliminar_estatizado&aviso=" + codigoAviso + "&pais=" + pais);
	var resultado = xml.childNodes[0].nodeValue;
	if (resultado == 1) {
		return mensajeOk;
	}
	else {
		return mensajeError;
	}
}

function adsenseBusquedaTestCronometro() {
	//alert(document.getElementById("iframe_adsense_busqueda").contentDocument.getElementById("fin_proceso").value);
}

function adsenseBusquedaTest(codigosPaises, etIframe, paginaTest, paisReporte) {
	var x;
	iframeTest = etIframe;
	paginaDelTest = paginaTest;
	paisDelReporte = paisReporte;
	
	if (codigosPaises[0] === undefined) {
		//Para todos los países:
		paisesTest = paises;
	}
	else {
		//Ciertos códigos de países, que deben llegar como un array:
		cantidadPaises = codigosPaises.length;
		paisesTest = new Array();
		
		for (x = 0; x < cantidadPaises; x++) {
			paisesTest[x] = paises[codigosPaises[x]];
		}
	}
	
	cantidadPaises = paisesTest.length;
	
	cronometroAdsense = setInterval("adsenseBusquedaTestNuevoPais();", 1000);
}

function adsenseBusquedaTestNuevoPais() {
	var trabajando = document.getElementById("trigger_adsense").value;
	var pasajePais = new Array();
	
	if (trabajando == 0) {
		if (paisActualTest === false) {
			paisActualTest = 0;
		}
		else {
			paisActualTest++;
		}
		
		if (paisActualTest >= cantidadPaises) {
			clearInterval(cronometroAdsense);
			document.body.style.cursor = "default";
			alert("Hecho");
		}
		else {
			pasajePais = paisesTest[paisActualTest];
			adsenseBusquedaTest2(pasajePais, iframeTest, paginaDelTest, paisDelReporte);
		}
	}
}

function adsenseBusquedaTest2(paisPorElaborar, etIframe, paginaTest, paisReporte) {
	document.getElementById("trigger_adsense").value = 1;
	document.body.style.cursor = "progress";
	
	var tablaReporteNormales = document.getElementById("adsense_busqueda_test_resultado_normales");
	var cantFilasNormales;
	cantFilasNormales = tablaReporteNormales.rows.length;
	
	var tablaReporteCriticas = document.getElementById("adsense_busqueda_test_resultado_criticas");
	var cantFilasCriticas;
	cantFilasCriticas = tablaReporteCriticas.rows.length;
	
	tablaReporteNormales.insertRow(cantFilasNormales);
		tablaReporteNormales.rows[cantFilasNormales].insertCell(0);
		tablaReporteNormales.rows[cantFilasNormales].cells[0].className = "adsense_busqueda_test_resultado_titulo";
		tablaReporteNormales.rows[cantFilasNormales].cells[0].colSpan = 5;
		tablaReporteNormales.rows[cantFilasNormales].cells[0].innerHTML = paisPorElaborar['nombre'];
		
	tablaReporteNormales.insertRow(cantFilasNormales + 1);
		tablaReporteNormales.rows[cantFilasNormales + 1].insertCell(0);
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[0].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[0].innerHTML = idioma_codigo;
			
		tablaReporteNormales.rows[cantFilasNormales + 1].insertCell(1);
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[1].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[1].innerHTML = idioma_categoria;
			
		tablaReporteNormales.rows[cantFilasNormales + 1].insertCell(2);
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[2].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[2].innerHTML = idioma_1;
			
		tablaReporteNormales.rows[cantFilasNormales + 1].insertCell(3);
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[3].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[3].innerHTML = idioma_2;
			
		tablaReporteNormales.rows[cantFilasNormales + 1].insertCell(4);
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[4].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteNormales.rows[cantFilasNormales + 1].cells[4].innerHTML = idioma_3;
		
	tablaReporteCriticas.insertRow(cantFilasCriticas);
		tablaReporteCriticas.rows[cantFilasCriticas].insertCell(0);
		tablaReporteCriticas.rows[cantFilasCriticas].cells[0].className = "adsense_busqueda_test_resultado_titulo";
		tablaReporteCriticas.rows[cantFilasCriticas].cells[0].colSpan = 7;
		tablaReporteCriticas.rows[cantFilasCriticas].cells[0].innerHTML = paisPorElaborar['nombre'];
		
	tablaReporteCriticas.insertRow(cantFilasCriticas + 1);
		tablaReporteCriticas.rows[cantFilasCriticas + 1].insertCell(0);
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[0].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[0].innerHTML = idioma_codigo;
			
		tablaReporteCriticas.rows[cantFilasCriticas + 1].insertCell(1);
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[1].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[1].innerHTML = idioma_categoria;
			
		tablaReporteCriticas.rows[cantFilasCriticas + 1].insertCell(2);
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[2].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[2].innerHTML = idioma_1;
			
		tablaReporteCriticas.rows[cantFilasCriticas + 1].insertCell(3);
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[3].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[3].innerHTML = idioma_2;
			
		tablaReporteCriticas.rows[cantFilasCriticas + 1].insertCell(4);
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[4].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[4].innerHTML = idioma_3;
		
		tablaReporteCriticas.rows[cantFilasCriticas + 1].insertCell(5);
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[5].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[5].innerHTML = "&nbsp;";
		
		tablaReporteCriticas.rows[cantFilasCriticas + 1].insertCell(6);
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[6].className = "adsense_busqueda_test_resultado_subtitulo";
		tablaReporteCriticas.rows[cantFilasCriticas + 1].cells[6].innerHTML = "&nbsp;";
		
	etIframe.src = paisPorElaborar["dominio_base"] + paginaTest + "?pais_reporte=" + paisReporte;
}

function quitarAlertaAdsenseBusqueda(imagen) {
	var totalFilas, tabla, filaActual, idiomaImg, filaCorrecta = false;
	
	imagen.lang = "xxx";
	tabla = document.getElementById("adsense_busqueda_test_resultado_criticas");
	totalFilas = tabla.rows.length;
	for (filaActual = 0; filaActual < totalFilas; filaActual++) {
		try {
			idiomaImg = tabla.rows[filaActual].cells[6].childNodes[0].lang;
		}
		catch(ex) {
			idiomaImg = "";
		}
		if (idiomaImg != "" && idiomaImg != undefined) {
			filaCorrecta = filaActual;
			break;
		}
	}
	
	if (filaCorrecta !== false) {
		tabla.deleteRow(filaCorrecta);
	}
}

function centrarVentana(ancho, alto) {
	var retorno = new Array();
	
	retorno["izquierda"] = Math.ceil((screen.width - ancho) / 2);
	retorno["arriba"] = Math.ceil((screen.height - alto) / 2);
	retorno["ancho"] = ancho;
	retorno["alto"] = alto;
	
	return retorno;
}

function corregirAdsenseBusqueda(vinculo) {
	var parametros = new Array();
	parametros["ancho"] = 500;
	parametros["alto"] = 700;
	parametros = centrarVentana(parametros["ancho"], parametros["alto"]);
	
	var url = vinculo.rel + "/backoffice/adsense-busqueda-correccion/";
	var totalFilas, tabla, filaActual, idiomaA, filaCorrecta = false;
	
	vinculo.lang = "xxx";
	tabla = document.getElementById("adsense_busqueda_test_resultado_criticas");
	totalFilas = tabla.rows.length;
	
	for (filaActual = 0; filaActual < totalFilas; filaActual++) {
		try {
			idiomaA = tabla.rows[filaActual].cells[5].childNodes[0].lang;
		}
		catch(ex) {
			idiomaA = "";
		}
		
		if (idiomaA != "" && idiomaA != undefined) {
			filaCorrecta = filaActual;
			tabla.rows[filaActual].style.backgroundColor = "yellow";
			break;
		}
	}
	
	url += texto_trim(tabla.rows[filaActual].id.substr(1, tabla.rows[filaActual].id.indexOf("-") - 1)) + "/" + texto_trim(tabla.rows[filaActual].id.substr(tabla.rows[filaActual].id.indexOf("-") + 1));
	vinculo.lang = "";
	
	ventanaCorreccion = window.open(url, "", "");
}

function obtenerTotalAdsenseCorreccion() {
	var x, etDiv, cantidadAdsense;
	
	for (x = 1; x <= 3; x++) {
		etDiv = "";
		while (true) {
			etDiv = document.getElementById("adsense_" + x).innerHTML;
			if (etDiv != "") break;
		}
		
		cantidadAdsense = 0;
		while (true) {
			posicion = etDiv.toLowerCase().indexOf('<span class="ad_url">');
			if (posicion === -1) posicion = etDiv.toLowerCase().indexOf('<span class=ad_url>');
			if (posicion === -1) break;
			cantidadAdsense++;
			etDiv = etDiv.substr(posicion + 5);
		};
		
		document.getElementById("td_total_adsense_" + x).innerHTML = cantidadAdsense;
	}
}

function texto_trim(texto) {
	var retorno = texto;
	var longitud = retorno.length;
	var x, y;
	
	if (longitud == 0) return "";
	
	for (x = 0; x < longitud; x++) {
		if (retorno.charAt(x) != " ") break;
	}
	
	if (x >= longitud) return "";
	
	for (y = longitud - 1; y >= 0; y--) {
		if (retorno.charAt(y) != " ") break;
	}
	
	return retorno.substr(x, y - x + 1);
}

function google_ad_request_done(google_ads) {
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	try {
		switch (zona_afc) {
			/*case "linkunit_sup":
				var aleat = Math.floor(Math.random() * 2);
				if (aleat == 0) {
					google_ad_request_done_linkunit_sup(google_ads);
				}
				else {
					google_ad_request_done_linkunit_sup_mismo_color(google_ads);
				}
				return;*/
			case "vi_ab_0":
				google_ad_request_done_linkunit_sup_0(google_ads);
				return;
			case "vi_ab_1":
				google_ad_request_done_linkunit_sup(google_ads);
				return;
			case "vi_ab_2":
				google_ad_request_done_linkunit_sup_mismo_color(google_ads);
				return;
			case "vi_ab_3":
				google_ad_request_done_linkunit_sup_celeste(google_ads);
				return;
			case "vi_ab_4":
				google_ad_request_done_linkunit_sup_celeste_arial(google_ads);
				return;
			case "vi_ab_5":
			case "vi_ab_6":
			case "vi_ab_7":
			case "vi_ab_8":
				google_ad_request_done_derecha(google_ads);
				return;
			case "linkunit_inf":
				//google_ad_request_done_linkunit_inf(google_ads);
				return;
		}
	}
	catch (ex) {}
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/ 
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<a target="_blank" href=\"' + 
			google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<a target="_blank" href=\"' + 
			google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br> <a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<a target="_blank" href=\"' + 
			google_info.feedback_url + '\" style="position: relative; top: 4px; word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a><br>' + 
			google_ads[0].snippet;
	}
	else {
		if (google_ads.length == 1) {
			/*
				* Partners should adjust text sizes
				* so ads occupy the majority of ad space.
			*/
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
			google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000">' +
			google_ads[0].line2 + '&nbsp;' +
			google_ads[0].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"><span>' + 
			google_ads[0].visible_url + '</span></a></p>';
			s += '</div>';
		}
		else if (google_ads.length > 1) {
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			/*
				* For text ads, append each ad to the string.
			*/
			for (i = 0; i < google_ads.length; ++i) {
				s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
					google_ads[i].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
					google_ads[i].line1 + '</b><br></span></a> <span style="color:#000000">' +
					google_ads[i].line2 + " " + 
					google_ads[i].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
					google_ads[i].visible_url + '\';return true"><span>' + 
					google_ads[i].visible_url + '</span></a></p>';
			}
			s += '</div>';
		}
    }
	
    document.write(s);
    return;
}

function google_ad_request_done_linkunit_sup_0(google_ads) {
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/ 
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br> <a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="position: relative; top: 4px; word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a><br>' + 
			google_ads[0].snippet;
	}
	else {
		if (google_ads.length == 1) {
			/*
				* Partners should adjust text sizes
				* so ads occupy the majority of ad space.
			*/
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
			google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000">' +
			google_ads[0].line2 + '&nbsp;' +
			google_ads[0].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"><span>' + 
			google_ads[0].visible_url + '</span></a></p>';
			s += '</div>';
		}
		else if (google_ads.length > 1) {
			/* Zona de customización */
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			/*
				* For text ads, append each ad to the string.
			*/
			for (i = 0; i < google_ads.length; ++i) {
				s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"> <span style="text-decoration: underline; color: #0066CC; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #0066CC; font-size: 11pt; font-family: Verdana;">' + 
					google_ads[i].line1 + '</b></span></a> <a target="_blank" style="color: #0066CC;text-decoration:none" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"><span style="font-family: Verdana;">' + 
					google_ads[i].visible_url + '</span><br><span style="color:#000000; font-family: Verdana;">' + 
					google_ads[i].line2 + " " + 
					google_ads[i].line3 + '</span></p>';
			}
			s += '</div>';
		}
    }
	
    document.write(s);
    return;
}

function google_ad_request_done_linkunit_sup(google_ads) {
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	
	if (zona_afc == "vi_ab_5") {
		google_ad_request_done_linkunit_sup_5(google_ads);
		return;
	}
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/ 
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br> <a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="position: relative; top: 4px; word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a><br>' + 
			google_ads[0].snippet;
	}
	else {
		if (google_ads.length == 1) {
			/*
				* Partners should adjust text sizes
				* so ads occupy the majority of ad space.
			*/
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
			google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000">' +
			google_ads[0].line2 + '&nbsp;' +
			google_ads[0].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"><span>' + 
			google_ads[0].visible_url + '</span></a></p>';
			s += '</div>';
		}
		else if (google_ads.length > 1) {
			/* Zona de customización */
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			/*
				* For text ads, append each ad to the string.
			*/
			for (i = 0; i < google_ads.length; ++i) {
				s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
					google_ads[i].line1 + '</b></span></a> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"><span>' + 
					google_ads[i].visible_url + '</span><br><span style="color:#000000">' + 
					google_ads[i].line2 + " " + 
					google_ads[i].line3 + '</span></p>';
			}
			s += '</div>';
		}
    }
	
    document.write(s);
    return;
}

function google_ad_request_done_linkunit_sup_5(google_ads) {
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/ 
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br> <a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="position: relative; top: 4px; word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a><br>' + 
			google_ads[0].snippet;
	}
	else {
		if (google_ads.length == 1) {
			/*
				* Partners should adjust text sizes
				* so ads occupy the majority of ad space.
			*/
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
			google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000">' +
			google_ads[0].line2 + '&nbsp;' +
			google_ads[0].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"><span>' + 
			google_ads[0].visible_url + '</span></a></p>';
			s += '</div>';
		}
		else if (google_ads.length > 1) {
			/* Zona de customización */
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			/*
				* For text ads, append each ad to the string.
			*/
			for (i = 0; i < google_ads.length; ++i) {
				s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
					google_ads[i].line1 + '</b></span></a> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"><span>' + 
					google_ads[i].visible_url + '</span><br><span style="color:#000000">' + 
					google_ads[i].line2 + " " + 
					google_ads[i].line3 + '</span></p>';
			}
			s += '</div>';
		}
    }
	
    document.write(s);
    return;
}

function google_ad_request_done_linkunit_sup_mismo_color(google_ads) {
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/ 
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br> <a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="position: relative; top: 4px; word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a><br>' + 
			google_ads[0].snippet;
	}
	else {
		if (google_ads.length == 1) {
			/*
				* Partners should adjust text sizes
				* so ads occupy the majority of ad space.
			*/
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
			google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000">' +
			google_ads[0].line2 + '&nbsp;' +
			google_ads[0].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"><span>' + 
			google_ads[0].visible_url + '</span></a></p>';
			s += '</div>';
		}
		else if (google_ads.length > 1) {
			/* Zona de customización */
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			/*
				* For text ads, append each ad to the string.
			*/
			for (i = 0; i < google_ads.length; ++i) {
				s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
					google_ads[i].line1 + '</b></span></a> <a target="_blank" style="color:#000000;text-decoration:none" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"><span>' + 
					google_ads[i].visible_url + '</span><br><span style="color:#000000">' + 
					google_ads[i].line2 + " " + 
					google_ads[i].line3 + '</span></p>';
			}
			s += '</div>';
		}
    }
	
    document.write(s);
    return;
}

function google_ad_request_done_linkunit_sup_celeste(google_ads) {
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	
	if (zona_afc == "vi_ab_7") {
		google_ad_request_done_linkunit_sup_celeste_7(google_ads);
		return;
	}
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/ 
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br> <a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="position: relative; top: 4px; word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a><br>' + 
			google_ads[0].snippet;
	}
	else {
		if (google_ads.length == 1) {
			/*
				* Partners should adjust text sizes
				* so ads occupy the majority of ad space.
			*/
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
			google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000">' +
			google_ads[0].line2 + '&nbsp;' +
			google_ads[0].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"><span>' + 
			google_ads[0].visible_url + '</span></a></p>';
			s += '</div>';
		}
		else if (google_ads.length > 1) {
			/* Zona de customización */
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			/*
				* For text ads, append each ad to the string.
			*/
			for (i = 0; i < google_ads.length; ++i) {
				s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #6B97BA; font-size: 25pt; font-family: Trebuchet MS;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"> <span style="text-decoration: underline; color: #6B97BA; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #6B97BA; font-size: 12pt; font-family: Trebuchet MS;">' + 
					google_ads[i].line1 + '</b></span></a> <a target="_blank" style="color: #999999;text-decoration:none" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"><span>' + 
					google_ads[i].visible_url + '</span><br><span style="color:#000000">' + 
					google_ads[i].line2 + " " + 
					google_ads[i].line3 + '</span></p>';
			}
			s += '</div>';
		}
    }
	
    document.write(s);
    return;
}

function google_ad_request_done_linkunit_sup_celeste_7(google_ads) {
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/ 
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br> <a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="position: relative; top: 4px; word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a><br>' + 
			google_ads[0].snippet;
	}
	else {
		if (google_ads.length == 1) {
			/*
				* Partners should adjust text sizes
				* so ads occupy the majority of ad space.
			*/
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
			google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000">' +
			google_ads[0].line2 + '&nbsp;' +
			google_ads[0].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"><span>' + 
			google_ads[0].visible_url + '</span></a></p>';
			s += '</div>';
		}
		else if (google_ads.length > 1) {
			/* Zona de customización */
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			/*
				* For text ads, append each ad to the string.
			*/
			for (i = 0; i < google_ads.length; ++i) {
				s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #6B97BA; font-size: 25pt; font-family: Trebuchet MS;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"> <span style="text-decoration: underline; color: #6B97BA; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #6B97BA; font-size: 12pt; font-family: Trebuchet MS;">' + 
					google_ads[i].line1 + '</b></span></a> <a target="_blank" style="color: #999999;text-decoration:none" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"><span>' + 
					google_ads[i].visible_url + '</span><br><span style="color:#000000">' + 
					google_ads[i].line2 + " " + 
					google_ads[i].line3 + '</span></p>';
			}
			s += '</div>';
		}
    }
	
    document.write(s);
    return;
}

function google_ad_request_done_linkunit_sup_celeste_arial(google_ads) {
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/ 
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br> <a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<a target="_blank" href=\"' + google_info.feedback_url + '\" style="position: relative; top: 4px; word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a><br>' + 
			google_ads[0].snippet;
	}
	else {
		if (google_ads.length == 1) {
			/*
				* Partners should adjust text sizes
				* so ads occupy the majority of ad space.
			*/
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
			google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000">' +
			google_ads[0].line2 + '&nbsp;' +
			google_ads[0].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"><span>' + 
			google_ads[0].visible_url + '</span></a></p>';
			s += '</div>';
		}
		else if (google_ads.length > 1) {
			/* Zona de customización */
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Arial; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			/*
				* For text ads, append each ad to the string.
			*/
			for (i = 0; i < google_ads.length; ++i) {
				s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #6B97BA; font-size: 25pt; font-family: Arial;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"> <span style="text-decoration: underline; color: #6B97BA; font-size: 15pt; font-family: Arial;"> <b style="color: #6B97BA; font-size: 12pt; font-family: Arial;">' + 
					google_ads[i].line1 + '</b></span></a> <a target="_blank" style="color: #999999;text-decoration:none;font-family: Arial;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
					google_ads[i].visible_url + '\';return true"><span style="font-family: Arial;">' + 
					google_ads[i].visible_url + '</span><br><span style="color:#000000; font-family: Arial;">' + 
					google_ads[i].line2 + " " + 
					google_ads[i].line3 + '</span></p>';
			}
			s += '</div>';
		}
    }
	
    document.write(s);
    return;
}

function google_ad_request_done_derecha(google_ads) {
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/
	
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<p style="margin-top: 0px; margin-left: 3px; margin-bottom: 13px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<p style="margin-top: 0px; margin-left: 3px; margin-bottom: 13px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p><a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<p style="margin-top: 0px; margin-left: 3px; margin-bottom: 13px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>' + 
			google_ads[0].snippet;
	}
	else {
		// A/B Test:
		switch (zona_afc) {
			case "vi_ab_5":
				google_ad_request_done_linkunit_sup(google_ads);
				return;
			case "vi_ab_6":
				google_ad_request_done_linkunit_sup_mismo_color(google_ads);
				return;
			case "vi_ab_7":
				google_ad_request_done_linkunit_sup_celeste(google_ads);
				return;
			case "vi_ab_8":
				google_ad_request_done_linkunit_sup_celeste_arial(google_ads);
				return;
		}
    }
	
    document.write(s);
    return;
}

function google_ad_request_done_linkunit_inf(google_ads) {
	//alert("Inferior");
	/*
		* This function is required and is used to display
		* the ads that are returned from the JavaScript
		* request. You should modify the document.write
		* commands so that the HTML they write out fits
		* with your desired ad layout.
	*/
	
	var s = '';
	var i;
	
	/*
		* Verify that there are actually ads to display.
	*/ 
	if (google_ads.length == 0) {
		return;
	}
	
	/*
		* If an image or flash ad is returned, display that ad.
		* Otherwise, build a string containing all of the ads and
		* then use a document.write() command to print that string.
	*/ 
	
	if (google_ads[0].type == "flash") {
		s += '<a target="_blank" href=\"' + 
			google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>' + 
			'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' + 
			google_ad.image_url + '">' + 
			'<PARAM NAME="quality" VALUE="high">' + 
			'<PARAM NAME="AllowScriptAccess" VALUE="never">' + 
			'<EMBED src="' + 
			google_ad.image_url + '" WIDTH="' + 
			google_ad.image_width + '" HEIGHT="' + 
			google_ad.image_height + 
			'" TYPE="application/x-shockwave-flash"' + 
			' AllowScriptAccess="never" ' + 
			' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	}
	else if (google_ads[0].type == "image") {
		s += '<a target="_blank" href=\"' + 
			google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br> <a href="' + 
			google_ads[0].url + '" target="_top" title="go to ' + 
			google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' + 
			google_ads[0].visible_url + '\';return true"><img border="0" src="' + 
			google_ads[0].image_url + '"width="' + 
			google_ads[0].image_width + '"height="' + 
			google_ads[0].image_height + '"></a>';
	}
	else if (google_ads[0].type == "html") {
		s += '<a target="_blank" href=\"' + 
			google_info.feedback_url + '\" style="position: relative; top: 4px; word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a><br>' + 
			google_ads[0].snippet;
	}
	else {
		if (google_ads.length == 1) {
			/*
				* Partners should adjust text sizes
				* so ads occupy the majority of ad space.
			*/
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
			google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000">' +
			google_ads[0].line2 + '&nbsp;' +
			google_ads[0].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
			google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
			google_ads[0].visible_url + '\';return true"><span>' + 
			google_ads[0].visible_url + '</span></a></p>';
			s += '</div>';
		}
		else if (google_ads.length > 1) {
			s += '<p style="margin-top: 4px; margin-left: 3px;"><a target="_blank" href=\"' + google_info.feedback_url + '\" style="word-spacing: -2px; color: #666666; text-decoration: none; font-weight: bold; font-family: Trebuchet MS; font-size: 10pt;">Ads by Google</a></p>';
			s += '<div>';
			/*
				* For text ads, append each ad to the string.
			*/
			for (i = 0; i < google_ads.length; ++i) {
				s += '<p style="margin-top: 7px; margin-left: 2px;"><a target="_blank" style="text-decoration: none; color: #000080; font-size: 15pt; font-family: Trebuchet MS;" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
					google_ads[i].visible_url + '\';return true"> <span style="text-decoration: underline; color: #000080; font-size: 15pt; font-family: Trebuchet MS;"> <b style="color: #000080; font-size: 12pt; font-family: Trebuchet MS;">' + 
					google_ads[i].line1 + '</b><br></span></a> <span style="color:#000000">' +
					google_ads[i].line2 + " " + 
					google_ads[i].line3 + '</span> <a target="_blank" style="color:#999999;text-decoration:none" href="' + 
					google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'go to ' +
					google_ads[i].visible_url + '\';return true"><span>' + 
					google_ads[i].visible_url + '</span></p>';
			}
			s += '</div>';
		}
    }
	
    document.write(s);
    return;
}

function cerrarLoginFacebook() {
	var xml = ajaxPeticionar("peticion=cerrar_login_facebook");
}

function nuevosEnlacesUsuario(usarFacebookConnect, logeadoEnFacebook, zona) {
	var xml = ajaxPeticionar("peticion=nuevos_enlaces_usuario&usar_facebook_connect=" + usarFacebookConnect + "&logeado_en_facebook=" + logeadoEnFacebook + "&zona=" + zona);
	return xml.childNodes[0].childNodes[0].nodeValue;
}

function esLoginDeFacebook() {
	var xml = ajaxPeticionar("peticion=es_login_de_facebook");
	return xml.childNodes[0].nodeValue;
}

function operarFieldsets() {
	var lista = document.getElementById("posting_categoria");
	var fieldsetSeleccionado = lista.options[lista.selectedIndex].lang;
	var divs = document.getElementsByTagName("div");
	var cantDivs = divs.length;
	var x;
	
	for (x = 0; x < cantDivs; x++) {
		if (divs[x].lang.indexOf("@" + fieldsetSeleccionado + "@") >= 0) {
			divs[x].style.display = "inline";
		}
		else if (divs[x].lang.indexOf("@") == 0) {
			divs[x].style.display = "none";
		}
	}
	
	document.getElementById("posting_fieldset").value = fieldsetSeleccionado;
	
	if (fieldsetSeleccionado >= 1) {
		var listaSubcategorias = document.getElementById("posting_subcategoria");
		var cantOpciones = listaSubcategorias.options.length;
		var catElegida = lista.options[lista.selectedIndex].value;
		
		//Vacía la lista:
		for (x = 1; x < cantOpciones; x++) {
			listaSubcategorias.remove(1);
		}
		
		listaSubcategorias.options[0].lang = fieldsetSeleccionado;
		
		//Llena la lista:
		var cantSubcategorias = categorias[catElegida].length;
		var opcion;
		for (x = 0; x < cantSubcategorias; x++) {
			opcion = document.createElement('option');
			opcion.value = categorias[catElegida][x]["codigo"];
			/*if (opcion.value == codigoLocalidadSeleccionada) {
				indiceSeleccionado = x;
			}*/
			opcion.text = categorias[catElegida][x]["nombre"];
			opcion.lang = categorias[catElegida][x]["fieldset"];
			try {
				listaSubcategorias.add(opcion, null);
			}
			catch(ex) {
				listaSubcategorias.add(opcion);
			}
		}
	}
}

function operarFieldsetsSubcategoria() {
	var lista = document.getElementById("posting_subcategoria");
	var fieldsetSeleccionado = lista.options[lista.selectedIndex].lang;
	var divs = document.getElementsByTagName("div");
	var cantDivs = divs.length;
	var x;
	
	if (fieldsetSeleccionado >= 1) {
		document.getElementById("posting_fieldset").value = fieldsetSeleccionado;
	}
	
	for (x = 0; x < cantDivs; x++) {
		if (divs[x].lang.indexOf("@" + fieldsetSeleccionado + "@") >= 0) {
			divs[x].style.display = "inline";
		}
		else if (divs[x].lang.indexOf("@") == 0) {
			divs[x].style.display = "none";
		}
	}
}

function cargarSelectPaisesAutogenerador(rama) {
	var xml = ajaxPeticionar("peticion=lista_paises_rama&rama=" + rama);
	var cantidadPaises;
	
	try {
		cantidadPaises = xml.childNodes.length;
	}
	catch (ex) {
		document.getElementById("autogenerador_paises_nombres").innerHTML = "";
		return;
	}
	
	if (cantidadPaises > 0) {
		var html = "";
		var cctld, nombrePais;
		
		for (var x = 0; x < cantidadPaises; x++) {
			cctld = xml.childNodes[x].childNodes[0].childNodes[0].nodeValue;
			nombrePais = xml.childNodes[x].childNodes[1].childNodes[0].nodeValue;
			
			html += "<p class='autogenerador_checkbox'>";
			html += "<input class='autogenerador_checkbox' type=checkbox id='chk_pais_" + cctld + "' name='chk_pais_" + cctld + "'><label for='chk_pais_" + cctld + "'>" + nombrePais + "</label>";
			html += "</p>";
		}
		
		document.getElementById("autogenerador_paises_nombres").innerHTML = html;
	}
	else {
		document.getElementById("autogenerador_paises_nombres").innerHTML = "";
	}
}

function autogenerar(errorCCTLD, errorCantidad, maximaCantidad, errorMaximaCantidad, mensajeHecho, mensajeCuota) {
	var selectRamas = document.getElementById("select_ramas");
	var rama = selectRamas.options[selectRamas.selectedIndex].value;
	var checkboxes = document.getElementsByTagName("input");
	var checkboxCCTLDs = "";
	var CCTLD;
	
	for (var x = 0; x < checkboxes.length; x++) {
		if (checkboxes[x].id.indexOf("chk_pais_") === 0 && checkboxes[x].checked) {
			CCTLD = checkboxes[x].id.substr(9);
			if (checkboxCCTLDs != "") checkboxCCTLDs += "-";
			checkboxCCTLDs += CCTLD;
		}
	}
	
	if (checkboxCCTLDs == "") {
		alert(errorCCTLD);
		return;
	}
	
	var cantidad = document.getElementById("cantidad").value * 1;
	if (isNaN(cantidad) || cantidad == Infinity || cantidad < 0 || cantidad != Math.floor(cantidad)) {
		cantidad = 0;
	}
	
	if (cantidad == 0) {
		alert(errorCantidad);
		return;
	}
	else if (cantidad > maximaCantidad) {
		alert(errorMaximaCantidad);
		return;
	}
	
	document.getElementById("subm").disabled = true;
	document.getElementById("cargando").style.visibility = "visible";
	
	var peticion = ajaxConectar();
	peticion.open("POST", archivoAjaxPhp, true);
	peticion.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	peticion.send("peticion=autogeneracion&rama=" + rama + "&paises=" + checkboxCCTLDs + "&cantidad=" + cantidad);
	peticion.onreadystatechange = function() {
		if (peticion.readyState == 4 && peticion.status == 200) {
			document.getElementById("cargando").style.visibility = "hidden";
			if (peticion.responseXML.documentElement.childNodes[0].nodeValue == 0) {
				alert(mensajeCuota);
			}
			else {
				alert(mensajeHecho);
			}
			document.getElementById("subm").disabled = false;
		}
	};
}

function puntosSuspensivosMoviles(cantidad, idElemento) {
	var elemento = document.getElementById(idElemento);
	var cantidadActual = elemento.lang;
	var textoPorMostrar = elemento.innerHTML.substr(0, elemento.innerHTML.length - cantidadActual);
	cantidadActual++;
	if (cantidadActual > cantidad) cantidadActual = 0;
	elemento.lang = cantidadActual;
	for (var x = 1; x <= cantidadActual; x++) {
		textoPorMostrar += ".";
	}
	elemento.innerHTML = textoPorMostrar;
}

function cargarSelectPaisesAutogeneradorIdiomas(idioma, preseleccionados) {
	var xml = ajaxPeticionar("peticion=lista_paises_autogenerador_idiomas&idioma=" + idioma);
	var paises = xml.childNodes[0].nodeValue.split(",");
	var html = "";
	var x, paises2 = new Array();
	var cantPaises = paises.length, conteo = 0;
	var preseleccion = "", preseleccion2, cantPrevios, tildado;
	
	if (preseleccionados != "") {
		preseleccion = preseleccionados.split(",");
		preseleccion2 = new Array();
		cantPrevios = preseleccion.length;
		for (x = 0; x < cantPrevios; x++) {
			preseleccion2[preseleccion[x]] = true;
		}
		preseleccion = preseleccion2;
	}
	
	for (x = 0; x < cantPaises; x++) {
		paises2[nombresPaises[paises[x]]["posicion"]] = paises[x];
	}
	paises = new Array();
	for (x = 0; x < paises2.length; x++) {
		if (paises2[x] != undefined) {
			paises[conteo] = paises2[x];
			conteo++;
		}
	}
	
	for (x = 0; x < paises.length; x++) {
		if (preseleccionados == "") {
			tildado = "";
		}
		else {
			try {
				tildado = preseleccion[paises[x]];
				if (tildado != true) tildado = "";
			}
			catch (ex) {
				tildado = "";
			}
			if (tildado != "") tildado = "checked";
		}
		html += "<p class='autogenerador_checkbox'>";
		html += "<input class='autogenerador_checkbox' type=checkbox id='chk_pais_" + paises[x] + "' name='chk_pais_" + paises[x] + "'" + " " + tildado + "><label for='chk_pais_" + paises[x] + "'>" + nombresPaises[paises[x]]["nombre"] + "</label>";
		html += "</p>";
	}
	
	document.getElementById("autogenerador_paises_nombres").innerHTML = html;
}

function envioFormularioCreacionRama() {
	document.getElementById("errores").style.display = "none";
	document.getElementById("cargando").style.visibility = "visible";
	document.getElementById("formulario_creacion").submit();
}

function espera(tiempo) {
	var xml = ajaxPeticionar("peticion=espera&tiempo=" + tiempo);
}

function operarFormularioContacto(evento) {
	if (evento.keyCode == 13) {
		document.getElementById("envio_del_mensaje").click();
		return false;
	}
	else {
		return true;
	}
}

function revisionCargaRama(clave, archRamas, archImags) {
	var xml = ajaxPeticionar("peticion=revisioncargarama&clave=" + clave + "&archramas=" + archRamas + "&archimagenes=" + archImags);
	var resultado;
	
	try {
		resultado = xml.childNodes[0].nodeValue;
	}
	catch (ex) {
		resultado = "";
	}
	
	if (resultado != "") {
		clearInterval(cronometroCarga);
		if (resultado != "1") {
			var resultadoComando = resultado.split("@@@");
			var paisErroneo;
			var yerro;
			
			switch (resultadoComando[0]) {
				case "ERR_CATEGORIA_INEXISTENTE":
				case "ERR_IDIOMA_INEXISTENTE_PAIS":
				case "ERR_RAMA_EXISTENTE":
					paisErroneo = paisesDatos[resultadoComando[1]];
					yerro = mensajesErrores[resultadoComando[0]].replace("[[[pais]]]", paisErroneo);
					break;
				case "ERR_RAMAS_LINEA_SIN_NIVEL":
				case "ERR_RAMAS_NIVEL_INVALIDO":
				case "ERR_RAMAS_TERMINO_VACIO":
					yerro = mensajesErrores[resultadoComando[0]].replace("[[[linea]]]", resultadoComando[1]);
					break;
				case "ERR_RAMAS_NIVEL_FALTANTE":
					yerro = mensajesErrores[resultadoComando[0]].replace("[[[nivel]]]", resultadoComando[1]);
					break;
				default:
					yerro = mensajesErrores[resultadoComando[0]];
			}
			
			document.getElementById("cargando").style.visibility = "hidden";
			document.getElementById("cargando").style.display = "none";
			var capa = document.getElementById("errores");
			capa.innerHTML = "<p>" + yerro + "</p>";
			capa.style.display = "inline";
		}
		else {
			//Todo Ok:
			var ofrecer = document.getElementById("ofrece_ejecucion");
			document.getElementById("cargando").style.visibility = "hidden";
			document.getElementById("cargando").style.display = "none";
			document.getElementById("a_ofr").href = nombreRamaEnCurso;
			ofrecer.style.display = "inline";
			document.getElementById("nombre").value = "";
		}
		document.getElementById("subm").disabled = false;
	}
}
