	function fotoNoticia(id,num,numTotal) {
		var fotosN = document.getElementsByTagName('div');
		var fotoOn = 1;
		var fotoExp = new RegExp(id + "-");
		for(i=0;i<fotosN.length;i++) {
			if(fotosN[i].id.indexOf(id + "-") == 0) {
				fotoOn = parseInt(fotosN[i].id.replace(fotoExp, ""));
				if(fotosN[i].style.display == "") {
					if(num == '+') num = fotoOn + 1;
					if(num == '-') num = fotoOn - 1;
				}
				var nombreDiv=fotosN[i].id.split("-");
				var arrId=id.split("-");
				if (nombreDiv.length == (arrId.length +1))
					fotosN[i].style.display = 'none';
			}
		}
		if(num == 0) num = numTotal;
		if((num > numTotal) || isNaN(num)) num = 1;
		var fotoN;
		if(fotoN = document.getElementById(id + '-' + num)) fotoN.style.display = "";
		var numFoto;
		if(numFoto = document.getElementById(id + '-num')) numFoto.innerHTML = num;		
	}
	
	/** Funcion de los botones de las fotonoticias
		zona -> string = id de la zona
		elemento -> vector = contiene los campos relativos a la fotoNoticia:
			tipo(video/foto), [fotoLink,fotoAlt,fotoPath,] [imgPath,videoPath,publititulo] ,titularHref,titularTarget, titularText
	*/
	function mostrarFotoNoticia(zona,elemento){
		if (zona != null && elemento != null){
			if (elemento["tipo"] == "foto"){
				cargarFotoFN(zona,elemento);
			}else if (elemento["tipo"] == "video"){
				cargarVideoFN(zona,elemento);
			}
		}
	}
	
	function cargarVideoFN(zona,elemento){
		var zonaPadre = document.getElementById(zona);
		var hijos = zonaPadre.getElementsByTagName("div");
		var zonaFoto = null, zonaTitulo = null, i = 0;
		while ((zonaFoto == null || zonaTitulo == null) && i < hijos.length){
			if (zonaFoto == null && hijos[i].className == "photo"){
				zonaFoto = hijos[i];
			}
			if (zonaTitulo == null && hijos[i].className == "ln"){
				zonaTitulo = hijos[i];
			}
			i++;
		}
		
		var divVideo = document.createElement("div");
		var zonaVideo = zona+"_video_container";
		divVideo.setAttribute("id",zonaVideo);
		while (zonaFoto.firstChild != null){
			zonaFoto.removeChild(zonaFoto.firstChild);
		}
		zonaFoto.appendChild(divVideo);
		if (elemento["imgPath"] != null && elemento["videoPath"] != null && elemento["publiTitulo"] != null)
			loadMethodeVideo(zonaVideo, 480, 200, elemento["videoPath"], elemento["imgPath"],true,true,"abc","33,34,31,32",elemento["publiTitulo"] ,"methode");
		
		var titular = document.createElement("h3");
		var linkTitular = document.createElement("a");
		linkTitular.href = elemento["titularHref"];
		linkTitular.title = elemento["titularText"];
		linkTitular.innerHTML = elemento["titularText"];
		titular.appendChild(linkTitular);
		while (zonaTitulo.firstChild != null){
			zonaTitulo.removeChild(zonaTitulo.firstChild);
		}
		zonaTitulo.appendChild(titular);
	}
	
	function cargarFotoFN(zona,elemento){
		// Seleccionamos las zonas donde iran la foto y el titular
		var zonaPadre = document.getElementById(zona);
		var zonaFoto = null, zonaTitulo = null;
		
		// Ahora recorremos los bloques 'div' buscando los de photo y ln deonde incrustaremos la foto y el titular
		var hijos = zonaPadre.getElementsByTagName("div");
		var i = 0;
		while ((zonaFoto == null || zonaTitulo == null) && i < hijos.length){
			if (zonaFoto == null && hijos[i].className == "photo"){
				zonaFoto = hijos[i];
			}
			if (zonaTitulo == null && hijos[i].className == "ln"){
				zonaTitulo = hijos[i];
			}
			i++;
		}
		
		var hayVideo = zonaFoto && zonaFoto.firstChild && zonaFoto.firstChild.id && zonaFoto.firstChild.id.indexOf("video") != -1; 
		// Comprobamos si hay video o si la capa contiene ya una imagen
		if (!hayVideo && zonaFoto.getElementsByTagName("img").length > 0) {
			var enlace = zonaFoto.getElementsByTagName("a")[0];
			if (elemento["fotoLink"] != null && elemento["fotoLink"].length > 0){
				enlace.setAttribute("href",elemento["fotoLink"]);
				if (elemento["fotoTarget"] != null && elemento["fotoTarget"].length > 0)
					enlace.setAttribute("target",elemento["fotoTarget"]);
			}else{
				enlace.setAttribute("href",elemento["titularHref"]);
				if (elemento["titularTarget"] != null && elemento["titularTarget"].length > 0)
					enlace.setAttribute("target",elemento["titularTarget"]);
			}
			var imagen = zonaFoto.getElementsByTagName("img")[0];
			imagen.src = elemento["fotoPath"];
			if (elemento["fotoAlt"] != null && elemento["fotoAlt"].length > 0)
				imagen.alt = elemento["fotoAlt"];
			else
				imagen.alt = elemento["titularText"];
		}else{
			//Sino contiene img, borramos el contenido y añadimos la nueva imagen
			// Creamos los contenedores de la imagen y el titular
			var foto = document.createElement("a");
			if (elemento["fotoLink"] != null && elemento["fotoLink"].length > 0){
				foto.href = elemento["fotoLink"];
			}else{
				foto.href = elemento["titularHref"];
			}
			if (elemento["fotoTarget"] != null && elemento["fotoTarget"].length > 0)
				foto.target = elemento["fotoTarget"];

			var imagen = document.createElement("img");
			imagen.src = elemento["fotoPath"];
			if (elemento["fotoAlt"] != null && elemento["fotoAlt"].length > 0)
				imagen.alt = elemento["fotoAlt"];
			else
				imagen.alt = elemento["titularText"];
			imagen.width = "480";
			foto.appendChild(imagen);
			
			//Limpiamos el contenido de las zonas donde ira la foto y la ponemos
			zonaFoto.innerHTML = "";
			zonaFoto.appendChild(foto);
		}
		
		// Cambiamos el titular
		var titulo = zonaTitulo.getElementsByTagName("a")[0];
		titulo.setAttribute("href",elemento["titularHref"]);
		titulo.setAttribute("title",elemento["titularText"]);
		if (elemento["titularTarget"] != null && elemento["titularTarget"].length > 0)
			titulo.setAttribute("target",elemento["titularTarget"]);
		titulo.innerHTML = elemento["titularText"];
	}
	
	function activarBotonFN(elemento){
		var hijos = elemento.parentNode.parentNode.getElementsByTagName("li");
		for (i = 0; i < hijos.length; i++){
			hijos[i].setAttribute("class","");
			hijos[i].setAttribute("className","");
			hijos[i].getElementsByTagName("div")[0].style.display = "none";
			hijos[i].getElementsByTagName("a")[0].style.display = "block";
		}
		elemento.style.display = "none";
		elemento.parentNode.setAttribute("class","activo");
		elemento.parentNode.setAttribute("className","activo");
		elemento.parentNode.getElementsByTagName("div")[0].style.display = "block";
	}
	
	function activarPaginacion(zona,pos,delaySecs){
		var delay = delaySecs*1000;
		var item,varTimeOut = null, paginar;
		eval ("item = "+zona);
		eval ("paginar = "+zona+"_paginacion");
		if (item != null && item.length > 0){
			if (paginar){
				mostrarFotoNoticia(zona,item[pos]);
				// Activamos el boton de la noticia que se esté mostrando
				var lis = document.getElementById(zona).getElementsByTagName("li");
				if (lis[pos] != null){
					activarBotonFN(lis[pos].getElementsByTagName("a")[0]);
				}
			}
			if (pos < (item.length - 1)){
				pos++;
			}else{
				pos = 0;
			}
			if (paginar){
				varTimeOut = setTimeout("activarPaginacion('"+zona+"',"+pos+","+delaySecs+")", delay);
			}else{
				clearTimeout(varTimeOut);
			}
		}
	}
	
	function desactivarPaginacion(zona){
		eval (zona+"_paginacion = false");
	}
	
	function numeroFotos(id,simbolo,numTotal)
	{	
		var numero=document.getElementById(id).innerHTML;
		if(simbolo == '+') 
		{			
			if( numero < numTotal)
				numero = parseInt(numero) + 1;
			else
				numero= 1;
		}	
		if(simbolo == '-') 
		{		
			if( numero > 1)
				numero = parseInt(numero) - 1;
			else
				numero= numTotal;
		}	
		var numeroFoto;
		if (numeroFoto = document.getElementById(id)) numeroFoto.innerHTML = numero;
	}
	
	function stopPlayer_FNot( id, zona ) {
		var numero = parseInt(document.getElementById(id).innerHTML, 10);
		var str;
		
		if( zona == 'fotonoticiasuperior' )	
			str = fotonoticiasuperior.get( numero );
		if( zona == 'fotonoticia' )	
			str = fotonoticia.get( numero );
		if( zona == 'fotonoticia-rc' ) {
			if (window.fotoNoticiaRCContenidos) {
				if (window.fotoNoticiaRCContenidos[numero]) {
					var idPlayer = window.fotoNoticiaRCContenidos[numero].id;
					document.getElementById(idPlayer).innerHTML = "";
					window.fotoNoticiaRCContenidos[numero].accion();
				}
				return;
			} else {
				str = fotonoticiarc.get( numero );
			}
		}
		
		if( str != null ) {
			var params	= new Array();
			params	= str.split( "##" ); 
		
			fnot.addVariable( 'file', null );
			fnot.write( params[0] );
			fnot.addVariable( 'file', params[1]);
			fnot.addVariable( 'image', params[2]);
			fnot.addVariable( 'height', params[3]);
			fnot.addVariable( 'width', params[4]);
			fnot.addVariable( 'displayheight', params[3]);
			fnot.addVariable( 'displaywidth', params[4]);
			fnot.setAttribute( 'height', params[3] ); 
			fnot.setAttribute( 'width', params[4] );
			fnot.write( params[0] );
		}
	}
	
	// variables para las fotonoticia
		var fotonoticiarc		= null;
		var fotonoticiasuperior = null;
		var fotonoticia			= null;
	//---------
		
	function Map()
	{
		// members
		this.keyArray = new Array(); // Keys
		this.valArray = new Array(); // Values
			
		// methods
		this.put = put;
		this.get = get;
		this.size = size;  
		this.clear = clear;
		this.keySet = keySet;
		this.valSet = valSet;
		this.showMe = showMe;   // returns a string with all keys and values in map.
		this.findIt = findIt;
		this.remove = remove;
	}

	function put( key, val )
	{
		var elementIndex = this.findIt( key );
		
		if( elementIndex == (-1) )
		{
			this.keyArray.push( key );
			this.valArray.push( val );
		}
		else
		{
			this.valArray[ elementIndex ] = val;
		}
	}

	function get( key )
	{
		var result = null;
		var elementIndex = this.findIt( key );

		if( elementIndex != (-1) )
		{   
			result = this.valArray[ elementIndex ];
		}  
		
		return result;
	}

	function remove( key )
	{
		var result = null;
		var elementIndex = this.findIt( key );

		if( elementIndex != (-1) )
		{
			this.keyArray = this.keyArray.removeAt(elementIndex);
			this.valArray = this.valArray.removeAt(elementIndex);
		}  
		
		return ;
	}

	function size()
	{
		return (this.keyArray.length);  
	}

	function clear()
	{
		for( var i = 0; i < this.keyArray.length; i++ )
		{
			this.keyArray.pop(); this.valArray.pop();   
		}
	}

	function keySet()
	{
		return (this.keyArray);
	}

	function valSet()
	{
		    return (this.valArray);   
	}

	function showMe()
	{
		var result = "";
		
		for( var i = 0; i < this.keyArray.length; i++ )
		{
			result += "Key: " + this.keyArray[ i ] + "\tValues: " + this.valArray[ i ] + "\n";
		}
		return result;
	}

	function findIt( key )
	{
		var result = (-1);

		for( var i = 0; i < this.keyArray.length; i++ )
		{
			if( this.keyArray[ i ] == key )
			{
				result = i;
				break;
			}
		}
		return result;
	}

	function removeAt( index )
	{
	  var part1 = this.slice( 0, index);
	  var part2 = this.slice( index+1 );

	  return( part1.concat( part2 ) );
	}
	Array.prototype.removeAt = removeAt;

	
	var docTitle = document.title;
	var arrayTitle = docTitle.split('.');
	docTitle = arrayTitle[0];
	var strGoogle = replaceAll(replaceAll(docTitle,' ','+'),',','');
	var strMyBlog = replaceAll(docTitle,'á','&aacute;');
	strMyBlog = replaceAll(strMyBlog,'ä','&auml;');
	strMyBlog = replaceAll(strMyBlog,'Á','&Aacute;');
	strMyBlog = replaceAll(strMyBlog,'Ä','&auml;');
	strMyBlog = replaceAll(strMyBlog,'é','&eacute;');
	strMyBlog = replaceAll(strMyBlog,'ë','&auml;');
	strMyBlog = replaceAll(strMyBlog,'É','&Eacute;');
	strMyBlog = replaceAll(strMyBlog,'Ë','&auml;');
	strMyBlog = replaceAll(strMyBlog,'í','&iacute;');
	strMyBlog = replaceAll(strMyBlog,'ï','&auml;');
	strMyBlog = replaceAll(strMyBlog,'Í','&Iacute;');
	strMyBlog = replaceAll(strMyBlog,'Ï','&auml;');
	strMyBlog = replaceAll(strMyBlog,'ó','&oacute;');
	strMyBlog = replaceAll(strMyBlog,'ö','&auml;');
	strMyBlog = replaceAll(strMyBlog,'Ó','&Oacute;');
	strMyBlog = replaceAll(strMyBlog,'Ö','&auml;');
	strMyBlog = replaceAll(strMyBlog,'ú','&uacute;');
	strMyBlog = replaceAll(strMyBlog,'ü','&auml;');
	strMyBlog = replaceAll(strMyBlog,'Ú','&Uacute;');
	strMyBlog = replaceAll(strMyBlog,'Ü','&auml;');
	strMyBlog = replaceAll(strMyBlog,'ñ','&ntilde;');
	strMyBlog = replaceAll(strMyBlog,'Ñ','&Ntilde;');
	function replaceAll(input, strFind, strReplace) {
		array = input.split(strFind);
		var output = array[0];
		for (var i=1; i<array.length; i++) {
			output += strReplace + array[i];
		}
		return output;
	}
	function pintaURL(dest, url, titulo) {
 		switch (dest) {
		 	case 'technorati':
		 		var contenido = '<a href="http://www.technorati.com/faves?add=' + url + '"><img src="/imag/ico_compartir3.gif" alt="Añadir a technorati" /></a>';
		 		break;
		 	case 'del.icio.us':
		 		var contenido  = '<a href="http://del.icio.us/post?title=' + titulo + '&url=' + url + '" target="_blank" title="guardar en mis favoritos de Del.icio.us"><img src="/imag/ico_compartir1.gif" alt="guardar en mis favoritos de Del.icio.us" /></a>';
		 		break;
		 	case 'digg':
		 		var contenido = '<a href="http://www.digg.com/submit?url=' + url + '"><img src="/imag/ico_compartir2.gif" alt="Añadir a digg" /></a>';
		 		break;
		 	case 'yahoo':
		 		var contenido = '<a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + url + '&t=' + titulo + '" target="_blank" title="guardar en los favoritos de My Yahoo!"><img src="/imag/ico_compartir4.gif" alt="guardar en los favoritos de My Yahoo!" /></a>';
		 		break;
			case 'meneame':
		 		var contenido = '<a href="http://meneame.net/submit.php?url=' + url + '" target="_blank" title="Enviar a Menéame"><img src="/imag/ico_compartir5.gif" alt="Enviar a Menéame" /></a>';
		 		break;
			case 'reporter':
		 		var contenido = '<a href="http://reporter.es.msn.com/?fn=contribute&Title=' + titulo + '&URL=' + url + '&referrer=ABC" target="_blank" title="Enviar a Reporter MSN"><img src="/imag/reporter.gif" alt="Enviar a Reporter MSN" /></a>';
		 		break;
			case 'wong':
		 		var contenido = '<a href="http://www.mister-wong.es/index.php?action=addurl&bm_url=' + url + '&bm_description=' + titulo + '" target="_blank" title="Enviar a Mister Wong"><img src="/imag/wong.gif" alt="Enviar a Mister Wong" /></a>';
		 		break;
			case 'facebook':	
		 		var contenido = '<a href="http://www.facebook.com/sharer.php?u=' + url + '&t=' + titulo + '" target="_blank" title="Enviar a Facebook"><img src="/imag/facebook.gif" alt="Enviar a Facebook"/></a>';
		 		break;	
			case 'twitter':	
				var contenido = '<a href="http://twitter.com/home?status=Add+This:+' + url + '" target="_blank" title="Enviar a Twitter"><img src="/imag/twitter.gif" alt="Enviar a Twitter"/></a>';
				break;
		}
 		 document.writeln(contenido);
 	}
 	function myBlog(url, titulo) {
 		var codigo = '<a href="' + url + '">' + escape(titulo) + '</a>';
 		var ventana = window.open('/popups/enlaces-sociales.html?codigo=' + codigo, null, 'width=500,height=210');
 	}
	function createRequestObject() {
		var ro;
		var browser = navigator.appName;
		
		if(browser == "Microsoft Internet Explorer"){
			ro = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else{
			ro = new XMLHttpRequest();
		}
		return ro;
	}  
	function setCookie(name, value, expires, path, domain, secure) {
		var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
		document.cookie = curCookie;
	}
	function getCookie(name) {
		var dc = document.cookie;
		var prefix = name + "=";
		var begin = dc.indexOf("; " + prefix);
		if (begin == -1) {
			begin = dc.indexOf(prefix);
		if (begin != 0) return null;
		} else
			begin += 2;
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
			end = dc.length;
		return unescape(dc.substring(begin + prefix.length, end));
	}
