<!--
	/******** GOOGLE  ********/
	function cs() {window.status=''};
	function ss(urlVisible) {window.status=urlVisible;return true;};	
	function google_ad_request_done(google_ads) {
		var i;
		var publi ='';
		accip = "off";
		if(google_ads.length > 0) {
			publi+='<div class="adds">';
			publi+='<div class="estilo_tit">Enlaces <strong>Patrocinados</strong></div>';
			publi+='<table class="addscontent" cellpadding="0" cellspacing="0">';
			for(i = 0; i < google_ads.length; ++i) {
				publi+='<tr>';
				publi+='<td class="estilo_txt">';
				publi+='<a href=\''+ google_ads[i].url + '\' target="_blank" onMouseOver="return ss(\'' + google_ads[i].visible_url + '\')" onMouseOut="cs()">';

				publi+='<span class="estilo_lnk">';
				publi+=google_ads[i].line1;
				publi+='</span>';
				publi+='<span class="estilo_descripcion">';
				publi+=google_ads[i].line2 + '&nbsp;';
				publi+=google_ads[i].line3 + '&nbsp;';
				publi+='</span>';
				publi+='<span class="estilo_url">';
				publi+=google_ads[i].visible_url;
				publi+='</span></a></td></tr>';
			}
			publi+='</table></div>';
			if(contNoxtrum = window.document.getElementById("publi1_noxtrum"))
				contNoxtrum.innerHTML = publi;
		}
	}
	/******** GOOGLE  ********/
	/*TIENDA*/
	function tienda(modulo,maximo){
		for (i = 1; i < maximo+1; i++) {
			bloque = "modulotienda" + i;
			//alert('oculto ' + bloque);
			document.getElementById(bloque).style.display = 'none';
		}

		presentar = "modulotienda" + modulo;
		//alert('presento ' + presentar );
		document.getElementById(presentar).style.display = 'block';
	}
	
	function abrirTienda(url) {
		afiliado = codigo_tienda != '' ? '_SolicitudRegistro_WAR_LTD_Portlets_codAfiliado=' + codigo_tienda : '';
		window.open(url + afiliado,'tienda');
	}
	
	/*---*/
	
	/************ INICIO AJAX **********/
	
	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 sndReq(url,fcn,param) {
		var http = createRequestObject();
		var funcion = "vacio";
		var parametros = "";
		if(typeof(fcn) != "undefined")
			funcion = fcn;
		if(typeof(param) != "undefined")
			parametros = param;
	
		http.open('get', url);
        http.onreadystatechange = function handleResponse() {
			if((http.readyState == 4) && (http.status == 200)) {
				var response = unescape(http.responseText.replace(/\+/g,  " "));
				eval(funcion + "(response,'" + parametros + "')");
			}
		}
		http.send(null);
	}

	function vacio(valores) {
		return;
	}
	
	function evalParam(param) {
		salida = '';
		paramArray = param.split("&");
		for(i=0;i<paramArray.length;i++) {
			datos = paramArray[i].split('=');
			if(datos.length == 2)
				salida = salida + datos[0] + " = '" + datos[1] + "';";
		}
		return salida;
	}

	/********* FIN AJAX ***************/
	
	/************ COOKIES ***********/
	
	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));
	}
	
	/************ FIN COOKIES ***********/
	
	function visualizacapasarticulo(capa,enlace){
		document.getElementById('envialanoticia').style.display = 'none';
		document.getElementById('enviar').style.color ='';
		document.getElementById('rectificalanoticia').style.display = 'none';
		document.getElementById('rectifica').style.color ='';
		document.getElementById(capa).style.display = 'block';
		document.getElementById(enlace).style.color ='#990000';
	
	}

	function ocultacapasarticulo(capa,enlace){
		document.getElementById(capa).style.display = 'none';
		document.getElementById(enlace).style.color ='';
	}
	
	function MM_openBrWindow(theURL,winName,features) {
		window.name='principal';
		window.open(theURL,winName,features);
	}

	function checkemail(email) {
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(email)) {
			return true
		}
		else{
			return false;
		}
	}
	
	function enviarNoticia(){
		var max_longitud = 120;
		var formulario =  window.document.envio_noticia;
		
		var nombre = formulario.nombre.value;
		var email_remitente = formulario.email_remitente.value;
		var para = formulario.para.value;
		var email_destinatario = formulario.email_destinatario.value;
		var comentario = formulario.comentario.value;
		
		if (!nombre || !email_remitente || !para || !email_destinatario)  {
			alert('No ha rellenado todos los campos');
			return;	
		}
		
		if (!checkemail(email_remitente)) {
			alert('El email del remitente no es correcto');
			formulario.email_remitente.focus();
			return;	
		}
		
		if (!checkemail(email_destinatario)) {
			alert('El email del destinatario no es correcto');
			formulario.email_destinatario.focus();
			return;	
		}
		
		var http = createRequestObject();
		var qs = "nombre=" + nombre + "&email_remitente=" + email_remitente + "&para=" + para;
		qs += "&email_destinatario=" + email_destinatario + "&comentario=" + comentario;
		qs += "&url=" + window.document.location.href;
		http.open("get", "/backend/enviar_noticia.php?" + qs +"&r=" + Math.random());
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					if (http.responseText.indexOf('OK') > -1) {
						var url_mostrar = (window.document.location.href.length > max_longitud) ? window.document.location.href.substr(0, max_longitud) + "..." : window.document.location.href;
						elHTML = "<form action=><div class=envianoticia><div class=envianoticiaOK><p>Su correo ha sido enviado correctamente.</p><p>Página enviada:</p><p class=url><a href='" + window.document.location.href + "' title='" + window.document.location.href + "'>" + url_mostrar + "</a></p></div><div class=clear></div></div><div class='envianoticia-botones boton'><a href=javascript:cerrarEnviarNoticia();>Cerrar</a></div></form>";
					}
					else {
						elHTML = "<form action=><div class=envianoticia><div class=envianoticiaOK><p>Ha ocurrido un ERROR al enviar la página, por favor intentelo más tarde.</p></div><div class=clear></div></div><div class='envianoticia-botones boton'><a href=javascript:cerrarEnviarNoticia();>Cerrar</a></div></form>";
					
					}
					formulario.reset();		
					window.document.getElementById('contenidoenvianoticia').innerHTML = elHTML;
				}
				else {
					alert("Ha habido un problema al enviar la noticia, por favor, intentelo más tarde.");
				}
				
			}	
		};
		http.send(null);	
	}
	
	function cerrarEnviarNoticia() {
		var contenido;
		
		window.document.getElementById('envialanoticia').style.display = 'none';
		
		contenido = '<form name="envio_noticia">';
		contenido += '	<fieldset>';
		contenido += '		<div class="envianoticia">';
		contenido += '			<p>Rellena los siguientes campos para enviar esta información a otras personas.</p>';
		contenido += '			<div class="envianoticiaI">';
		contenido += '				<table width="99%" border="0" cellspacing="0" cellpadding="0">';
		contenido += '					<tr>';
		contenido += '						<th>Nombre</th>';
		contenido += '						<td><input name="nombre" type="text" value="" /></td>';
		contenido += '						<th>Email remitente</th>';
		contenido += '						<td><input name="email_remitente" type="text" value="" /></td>';
		contenido += '					</tr>';
		contenido += '					<tr>';
		contenido += '						<th>Para</th>';
		contenido += '						<td><input name="para" type="text" value="" /></td>';
		contenido += '						<th>Email destinatario </th>';
		contenido += '						<td><input name="email_destinatario" type="text" value="" /></td>';
		contenido += '					</tr>';
		contenido += '				</table>';
		contenido += '			</div>';
		contenido += '			<div class="envianoticiaD">';
		contenido += '				<textarea name="comentario" cols="5" rows="5"></textarea>';
		contenido += '			</div>';
		contenido += '			<div class="clear"></div>';
		contenido += '		</div>';
		contenido += '		<div class="envianoticia-botones boton"><a href="#" onclick="window.document.envio_noticia.reset()">Borrar</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:enviarNoticia();">Enviar</a></div>';
		contenido += '	</fieldset>';
		contenido += '</form>	';
		
		window.document.getElementById('contenidoenvianoticia').innerHTML = contenido;
	}
	
	
	function rectificarNoticia(){
		
		var max_longitud = 120;
		
		var formulario =  window.document.rectificar_noticia;
		
		var nombre = formulario.nombre.value;
		var email = formulario.email.value;
		var comentario = formulario.comentario.value;
		
		if (!nombre || !email || !comentario)  {
			alert('No ha rellenado todos los campos');
			return;	
		}
		
		if (!checkemail(email)) {
			alert('El email no es correcto');
			formulario.email_remitente.focus();
			return;	
		}
		
		var http = createRequestObject();
		var qs = "nombre=" + nombre + "&email=" + email + "&comentario=" + comentario;
		qs += "&url=" + window.document.location.href;
		http.open("get", "/backend/rectificar_noticia.php?" + qs +"&r=" + Math.random());
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					if (http.responseText.indexOf('OK') > -1) {
						var url_mostrar = (window.document.location.href.length > max_longitud) ? window.document.location.href.substr(0, max_longitud) + "..." : window.document.location.href;
						elHTML = "<form action=><div class=envianoticia><div class=envianoticiaOK><p>Su rectificación ha sido enviada correctamente.</p><p>Págian enviada:</p><p class=url><a href='" + window.document.location.href + "' title='" + window.document.location.href + "'>" + url_mostrar + "</a></p></div><div class=clear></div></div><div class='envianoticia-botones boton'><a href=javascript:cerrarRectificarNoticia();>Cerrar</a></div></form>";
					}
					else {
						elHTML = "<form action=><div class=envianoticia><div class=envianoticiaOK><p>Ha ocurrido un ERROR al enviar la rectificación, por favor intentelo más tarde.</p></div><div class=clear></div></div><div class='envianoticia-botones boton'><a href=javascript:cerrarRectificarNoticia();>Cerrar</a></div></form>";
					
					}
					
					formulario.reset();			
				
					window.document.getElementById('contenidorectificanoticia').innerHTML = elHTML;
	
						
				}
			}	
		};
		http.send(null);	
	}
	
	function cerrarRectificarNoticia() {
		var contenido;
		
		window.document.getElementById('rectificalanoticia').style.display = 'none';
		
		contenido = '<form name="rectificar_noticia">';
                contenido += '      <fieldset>';
                contenido += '      <div class="rectificanoticia">';
                contenido += '        <p>Rellene todos los campos con sus datos.</p>';
                contenido += '        <div class="rectificanoticiaI">';
                contenido += '          <table width="99%" border="0" cellspacing="0" cellpadding="0">';
                contenido += '            <tr>';
                contenido += '              <th width="12%">Nombre<span class="obligatorio">*</span></th>';
                contenido += '              <td width="38%"><input name="nombre" type="text" value="" /></td>';
                contenido += '              <th width="9%">Email<span class="obligatorio">*</span></th>';
                contenido += '              <td width="41%"><input name="email" type="text" value="" /></td>';
                contenido += '            </tr>';
                contenido += '            <!--tr>';
                contenido += '              <th colspan="4">URL de la noticia<span class="obligatorio">*';
                contenido += '                <input name="text2" class="url" type="text" value="http://www.elcorreodigital.com/vizcaya/20070319/politicasdas das das das das das das ... " />';
		contenido += '		</span></th>';
                contenido += '            </tr-->';
                contenido += '          </table>';
		contenido += '				  </div>';
                contenido += '        <div class="rectificanoticiaD">';
                contenido += '          <textarea cols="5" rows="5" name="comentario"></textarea>';
                contenido += '        </div>';
                contenido += '        <div class="clear"></div>';
                contenido += '      </div>';
                contenido += '      <div class="envianoticia-botones boton"><span class="obligatorio" style="float:left;">* campo obligatorio</span><a href="#" onclick="window.document.rectificar_noticia.reset()">Borrar</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:rectificarNoticia();">Enviar</a></div>';
                contenido += '      </fieldset>';
                contenido += '    </form>	';
		
		window.document.getElementById('contenidorectificanoticia').innerHTML = contenido;
	}
	
	function votarticulo(id,puntos) {
		
		var http = createRequestObject();
		http.open("get", "/herramientas/votar.php?puntos=" + puntos + "&id=" + id + "&r=" + Math.random());
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					gracias = "<div class=label>Gracias por votar</div>";
					document.getElementById('contenidoestrellas').innerHTML = gracias;
					getEstrellas(id);
				}
			}	
		};
		http.send(null);		
	}
	
	function votarticulo_titulo(id,puntos,titulo, url) {
		
		var http = createRequestObject();
		http.open("get", "/herramientas/votar.php?puntos=" + puntos + "&id=" + id + "&r=" + Math.random() + '&titulo=' + titulo + '&url=' + url);
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					gracias = "<div class=label>Gracias por votar</div>";
					document.getElementById('contenidoestrellas').innerHTML = gracias;
					getEstrellas(id);
				}
			}	
		};
		http.send(null);		
	}
	
	function getEstrellas(id) {
		var http = createRequestObject();
		http.open("get", "/herramientas/estrellas.php?id=" + id +"&r=" + Math.random());
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					var estrellas = http.responseText;
					if (estrellas.indexOf("##")) {
						campos = estrellas.split("##");
						estrellas = campos[0];
						if (campos[1]==1){
							var votos="1 Voto";
						}else {
							var votos=campos[1] + " Votos";
						}
							window.document.getElementById('numero-votos').innerHTML = votos;
					}
					if (estrellas.indexOf(".")) {
						campos = estrellas.split(".");
						estrellas = campos[0];	
						var media = (campos[1] > 0) ? 1 : 0;
					}
					var contenido = '';
					for (i = 0; i < estrellas; i++) {
						contenido += '<img src="/img/star_on.gif" alt="' + i +' votos" />';
					}
					if (media == 1) {
						contenido += '<img src="/img/star_on_md.gif" alt="' + estrellas +' votos" />';
						estrellas++;
					}
					for (i = estrellas; i < 5; i++) {
						contenido += '<img src="/img/star_off.gif" alt="' + i +' votos" />';	
					}
					window.document.getElementById('resultados-votos').innerHTML = contenido;
				}
			}	
		};
		http.send(null);
	}
	
	/***************************** Comentarios **********************************/
	
	function getNComentarios(id) {
		var http = createRequestObject();
		http.open("get", "/herramientas/NComentarios.php?id=" + id +"&r=" + Math.random());
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					var ncomentarios = http.responseText;
					if (ncomentarios==1){
						ncomentarios = ncomentarios + " Opinion";
					}else {
						ncomentarios = ncomentarios + " Opiniones";
					}
					window.document.getElementById('resultados-ncomentarios').innerHTML = ncomentarios;
				}
			}	
		};
		http.send(null);
	}
	
	function getComentarios(id, by) {
		if (id) {
			var http = createRequestObject();
			http.open("get", "/backend/getComentarios.php?id=" + id + "&by=" + by + "&r=" + Math.random());
			http.onreadystatechange = function () {
				
				if(http.readyState == 4){
					if (http.responseXML) {
						if (http.responseXML.getElementsByTagName('comments')) {
							if (http.responseXML.getElementsByTagName('comment').length > 0) {
								muestraComentarios(http.responseXML, 1);
								window.document.getElementById('lomasreciente').className = (by == 'date') ? 'activo' : '';
								window.document.getElementById('lomasvalorado').className = (by == 'votes') ? 'activo' : '';
							}
						}
						
					}
				}	
			};
			http.send(null);
			
		}
	}
	function getComentariosCajeros(id, by) {
		if (id) {
			var http = createRequestObject();
			http.open("get", "/backend/getComentarios.php?id=" + id + "&by=" + by + "&id_tipo_externo=2&r=" + Math.random());
			http.onreadystatechange = function () {

				if(http.readyState == 4){
					if (http.responseXML) {
						if (http.responseXML.getElementsByTagName('comments')) {
							muestraComentarios(http.responseXML, 1);
							window.document.getElementById('lomasreciente').className = (by == 'date') ? 'activo' : '';
							window.document.getElementById('lomasvalorado').className = (by == 'votes') ? 'activo' : '';
						}
						
					}
				}	
			};
			http.send(null);
			
		}
	}
	
	function muestraComentarios(response, pagina) {
		var contenido;
		var html;
		var fecha_load = new Date();
		var browser = navigator.appName;
		var positive_votes;
		var negative_votes;
		var max_comentarios = 5;
		
		var limite = response.getElementsByTagName('comment').length;
		html = '<div class="numopiniones"><span>' + response.getElementsByTagName('total_comments')[0].firstChild.data + ' OPINIONES</span></div>';
		
		var limite_b = ((((pagina - 1) * max_comentarios) + max_comentarios) > limite) ? limite : (((pagina - 1) * max_comentarios) + max_comentarios);
		var inicio = (pagina - 1) * max_comentarios;
		var paginas = Math.ceil(limite / max_comentarios);
		
		var pagina_ver = (pagina < 10) ? '0' + pagina : pagina;
		var paginas_ver = (paginas < 10) ? '0' + paginas : paginas;
		
		for (var i = inicio; i < limite_b; i++) {
			
			var id = response.getElementsByTagName('id')[i].firstChild.data;
			var fecha = response.getElementsByTagName('date')[i].firstChild.data;
			var hora = fecha.substr(8,2) + ':' + fecha.substr(10,2)
			var nombre = response.getElementsByTagName('name')[i].firstChild ? response.getElementsByTagName('name')[i].firstChild.data : '';
			if (browser == 'Microsoft Internet Explorer'){
				var texto = response.getElementsByTagName('content')[i].firstChild.data;
			}
			else {
				var texto = response.getElementsByTagName('content')[i].childNodes[1].data;
			}
			
			positive_votes = response.getElementsByTagName('positive_votes')[i].firstChild.data;
			negative_votes = response.getElementsByTagName('negative_votes')[i].firstChild.data;
			fecha = fecha.substr(6,2) + "/" + fecha.substr(4,2) + "/" + fecha.substr(0,4);
			contenido = '	<div class="opinion">';
			contenido += '<div class="fecha">' + fecha + ' | <span class="hora">' + hora + '</span></div>';
	   		contenido += '<h3>' + unescape(nombre) + '</h3>';
			contenido += '<div class="texto">' + unescape(texto) + '</div>';
			contenido += '<div class="detalles-opinion">';
			contenido += '<div class="favorcontra" id="favorcontra-' + id + '"><a href="javascript:votarComentario(' + id+ ', 1);" class="afavor">A';
			contenido += '    favor (' + positive_votes + ')</a><a href="javascript:votarComentario(' + id + ', 2);" class="encontra">En';
			contenido += '    contra (' + negative_votes + ')</a></div>';
			contenido += '<div class="inadecuado" id="inadecuadoboton"><a href="javascript:mostrarDenunciar(' + id + ');" class="boton" title="Comentario inadecuado"><img src="/img/ico_inadecuado.gif" alt="Comentario inadecuado" />Comentario';
			contenido += '    inadecuado</a></div>';
			contenido += '<div class="clear"></div>';
			contenido += '</div>';
			contenido += '<div class="formdenunciar" id="formdenunciar-' + id + '" style="display:none;">';
			contenido += '<form name="formulario_' + id + '" action="/backend/denunciarComentario.php" method="post">';
			contenido += '<input type="hidden" name="load_time" value="' + fecha_load.getTime() + '">';
			contenido += '<input type="hidden" name="submit_time" value="0">';
			contenido += '<input type="hidden" name="id" value="' + id + '">';
			contenido += '<input type="hidden" name="anchor" value="comentarios">';
			contenido += '<p>Por favor seleciona el motivo por el que crees que este comentario';
			contenido += '  es inadecuado </p>';
			contenido += '<textarea name="denuncia">Escriba aquí el motivo de la denuncia.</textarea>';
			contenido += '<a href="javascript:denunciarComentario(' + id + ');" class="boton">denunciar comentario</a>';
			contenido += '</label>';
			contenido += '<div class="clear"></div>';
			contenido += '</div>';
			contenido += '<div class="clear"></div>';
			contenido += '</form>';
			contenido += '</div>';

			html += contenido;
		}
		
		if (limite > max_comentarios) {
			html += '<div class="botones-listado"><a id="anterior" href="javascript:nada()" class="boton anterior">&lt;&lt;';
                  	html += 'Anterior</a>&nbsp;&nbsp;<span><strong>' + pagina_ver + '</strong>/' + paginas_ver + '</span>&nbsp;&nbsp;<a id="siguiente" href="javascript:nada()" class="boton siguiente">Siguiente';
                  	html += '&gt;&gt; </a></div>';	
		}		
		
		window.document.getElementById('listado-comentarios').innerHTML = html;
		
		
		if (limite > max_comentarios) {
			
			window.document.getElementById('anterior').onclick = function () {
				if (pagina != 1) {
					muestraComentarios(response, (pagina - 1));	
				}	
				else {
					muestraComentarios(response, pagina);
				}
							
			}
			
			window.document.getElementById('siguiente').onclick = function () {
				if (pagina != paginas) {
					muestraComentarios(response, (pagina + 1));	
				}
				else {
					muestraComentarios(response, pagina);
				}
								
			}
		}
		
	}

	function nada() {
		return;	
	}

	
	function desconectar() {
		window.location = '/backend/desconectar.php?url=' + window.location.href;
	}
	
	function conectar() {
		var direccion;
		
		if (window.document.location.href.indexOf('?') > 0) {
			var campos = window.document.location.href.split('?');
			direccion = campos[0];
		}
		else {
			direccion = window.document.location.href;
		}
		
		if (direccion.indexOf('#') > 0) {
			var campos = direccion.split('#');
			direccion = campos[0];
		}
		
		var qs = 'url=' + direccion;
		qs += '&email=' + window.document.logueo.email.value;
		qs += '&contrasena=' + window.document.logueo.contrasena.value;
		window.location = '/backend/conectar.php?' + qs;	
	}
	
	function enviaComentario() {
	  var fecha_submit = new Date();
	  
	  /*
	  if (!getCookie('registrado_hi')) {
	  	alert('Para poder comentar hace falta estar registrado');
	  	muestraLogueo();
	  	return;	
	  }
	  */
	  if (window.document.formulario.author_name.value == '') {
	  	alert('Por favor, introduce tu nombre');
	  	window.document.formulario.author_name.focus();
	  	return;	
	  }
	  
	  if (window.document.formulario.author_email.value == '') {
	  	alert('Por favor, introduce tu email');
	  	window.document.formulario.author_email.focus();
	  	return;	
	  }
	  
	  if (window.document.formulario.message.value == '') {
	  	alert('Por favor, introduce tu opinión');
	  	window.document.formulario.message.focus();
	  	return;	
	  }
	  
	  if (!window.document.formulario.acepto.checked) {
	  	alert('Tienes que aceptar las condiciones de uso');
	  	return;	
	  }
	  
	  var registrado = '';
	  
	  window.document.formulario.message.value = window.document.formulario.message.value;
	  window.document.formulario.author_name.value = window.document.formulario.author_name.value + registrado;
	  
	  window.document.formulario.submit_time.value = fecha_submit.getTime();
	  window.document.formulario.submit();
	  alert('Gracias por escribir un comentario');
	}
	
	function votarComentario(id, tipo) {
		if (id) {
			var http = createRequestObject();
			http.open("get", "/backend/votarComentario.php?id=" + id + "&tipo=" + tipo + "&r=" + Math.random());
			http.onreadystatechange = function () {
				if(http.readyState == 4){
					if (http.responseText) {
						var response = http.responseText;
						if (response.indexOf('ok')) {
							if (tipo == 1) {
								window.document.getElementById('favorcontra-' + id).innerHTML = '<span class="afavor">A favor</span> <span class="mensaje">| Gracias por votar</span>';	
							}
							else {
								window.document.getElementById('favorcontra-' + id).innerHTML = '<span class="encontra">En contra</span> <span class="mensaje">| Gracias por votar</span>';
							}
						}
							
					}
				}	
			};
			http.send(null);
		}		
	}
	
	function mostrarDenunciar(id) {
		var display = window.document.getElementById('formdenunciar-' + id).style.display;
		if (display == 'none' && !getCookie('registrado_hi')) {
			alert('Para denunciar un comentario hace falta estar logueado');
			return;	
		}
		window.document.getElementById('formdenunciar-' + id).style.display = (display == 'none') ? 'block' : 'none';
	}
	
	function denunciarComentario(id) {
		var fecha_submit = new Date();
		eval('var formu = window.document.formulario_' + id);
		formu.submit_time.value = fecha_submit.getTime();
		formu.submit();
		 alert('Gracias por denunciar el comentario');
		
	}
	
	function muestraLogueo() {
		window.document.getElementById('artlogeo').style.display = '';	
	}
	
	function borrarTexto() {
		if (window.document.formulario.message.value == 'escribe aquí tu comentario') {
			window.document.formulario.message.value = '';	
		}	
	}
	
	function recordarContrasena() {
		if (window.document.logueo.email.value == '') {
			alert('Por favor, introduce tu email para que te enviemos tu nueva contraseña');
			window.document.logueo.email.focus();
			return;	
		}
		
		var http = createRequestObject();
		http.open("get", "/backend/recordar_contrasena.php?email=" + window.document.logueo.email.value + "&r=" + Math.random());
		http.onreadystatechange = function () {
			if(http.readyState == 4){
				if (http.responseText) {
					var response = http.responseText;
					if (response.indexOf('ok') != -1) {
						alert('Te hemos enviado un email con tu nueva contraseña.');
					}
					else {
						alert('Ha ocurrido un error, por favor, intentalo más tarde.');
					}
				}
			}	
		};
		http.send(null);	
		
		
	}
	/***************************** FIN Comentarios **********************************/
	
	function cambialo(valor) {
		//alert('entro???');
		document.getElementById('pest-lomas-leido').className = '';
		document.getElementById('pest-lomas-comentado').className = '';
		document.getElementById('pest-lomas-votado').className = '';
		pestanna = 'pest-lomas-' + valor;
		document.getElementById(pestanna).className = 'activo';
		bloquepestanna = valor;
		document.getElementById('leido').style.display = 'none';
		document.getElementById('comentado').style.display = 'none';
		document.getElementById('votado').style.display = 'none';
		document.getElementById(bloquepestanna).style.display = 'block';
	}
	
	/***************** INICIO FOTONOTICIA ***********************************/

	var timeOut;
	function rota(id,num) {
		if(noticias = window.document.getElementById('fotonoticia-' + id)) {
			for(inoticia in noticias.childNodes) {
				noticia = noticias.childNodes[inoticia];
				if((typeof(noticia.id) != "undefined") && (noticia.id.indexOf('fotonoticia-' + id) == 0))
					noticia.style.display = "none";
			}
			if(noticia = window.document.getElementById('fotonoticia-' + id + '-' + num))
				noticia.style.display = "";
		}
		if(pestanas = window.document.getElementById('fotonoticia-thumb-' + id)) {
			for(ipestana in pestanas.childNodes) {
				pestana = pestanas.childNodes[ipestana];
				if((typeof(pestana.id) != "undefined") && (pestana.id.indexOf('fotonoticia-thumb-' + id) == 0))
					pestana.className = "thumb";
			}
			if(pestana = window.document.getElementById('fotonoticia-thumb-' + id + '-' + num))
				pestana.className = "thumb activo";
		}
		num++;
		if (num > 3){
			num = 1;
		}
		timeOut = window.setTimeout("rota(" + id + ", " + num +")", 10000);
	}
	
	function fotoNoticia(id,num) {
		window.clearTimeout(timeOut);
		if(noticias = window.document.getElementById('fotonoticia-' + id)) {
			for(inoticia in noticias.childNodes) {
				noticia = noticias.childNodes[inoticia];
				if((typeof(noticia.id) != "undefined") && (noticia.id.indexOf('fotonoticia-' + id) == 0))
					noticia.style.display = "none";
			}
			if(noticia = window.document.getElementById('fotonoticia-' + id + '-' + num))
				noticia.style.display = "";
		}
		if(pestanas = window.document.getElementById('fotonoticia-thumb-' + id)) {
			for(ipestana in pestanas.childNodes) {
				pestana = pestanas.childNodes[ipestana];
				if((typeof(pestana.id) != "undefined") && (pestana.id.indexOf('fotonoticia-thumb-' + id) == 0))
					pestana.className = "thumb";
			}
			if(pestana = window.document.getElementById('fotonoticia-thumb-' + id + '-' + num))
				pestana.className = "thumb activo";
		}
	}
	function fotoPestana(id,accion) {
		window.clearTimeout(timeOut);
		if(pestanas = window.document.getElementById('fotonoticia-thumb-' + id)) {
			var inicio = 0;
			var fin = 3;
			var total = 0;
			for(ipestana in pestanas.childNodes) {
				pestana = pestanas.childNodes[ipestana];
				if((typeof(pestana.id) != "undefined") && (pestana.id.indexOf('fotonoticia-thumb-' + id) == 0)) {
					datosPestana = pestana.id.split('-');
					numPestana = parseInt(datosPestana[datosPestana.length - 1]);
					if((inicio == 0) && (pestana.style.display == "")) inicio = numPestana;
					if((numPestana > 3) && (pestana.style.display == "")) fin = numPestana;
					pestana.style.display = 'none';
					total += 1;
				}
			}
			if((fin < total) && (accion == "+")) {
				inicio = inicio + 1;
				fin = fin + 1;
			}
			if((inicio > 1) && (accion == "-")) {
				inicio = inicio - 1;
				fin = fin - 1;
			}
			if(flecha = window.document.getElementById('fotonoticia-thumb-izq-' + id))
				flecha.style.display = inicio == 1 ? 'none' : '';
			if(flecha = window.document.getElementById('fotonoticia-thumb-der-' + id))
				flecha.style.display = fin == total ? 'none' : '';
			for(i=inicio;i<=fin;i++) {
				if(pestana = window.document.getElementById('fotonoticia-thumb-' + id + '-' + i))
					pestana.style.display = "";
			}
		}
	}
	/***************** FIN FOTONOTICIA ***********************************/

	/***************** INICIO VOTOS y COMENTARIOS ***********************************/
	var arrVotCom = new Array();
	function getVotCom() {
		
		// Temporalmente por caidas
		//return;

		reqVotCom = arrVotCom.join("-");
		sndReq('/backend/getVotCom.php?ids=' + reqVotCom,'printVotCom','')
	}
	function printVotCom(respuesta,param) {
		if(respuesta != "") {
			arrNot = respuesta.split("##");
			for(indNot in arrNot) {
				datNot = arrNot[indNot].split("%%");
				if(datNot.length == 3) {
					if(elemento = document.getElementById("votos-" + datNot[0]))
						elemento.innerHTML = datNot[1];
					if(elemento = document.getElementById("comentarios-" + datNot[0]))
						elemento.innerHTML = datNot[2];
				}
			}
		}
	}
	/*****FOTO NOTICIA VERTICALES *********/
var arrFotosVerticales = new Array();

function pintafotovertical(n,num) {
var total = arrFotosVerticales.length - 2;
var anterior = n-1;
var siguiente = n+1;
var limite_for = ((arrFotosVerticales.length -1) < 3) ? (arrFotosVerticales.length -1) : 3;
//alert(arrFotosVerticales.length);
//alert('total'+total+'anterior'+anterior+'siguiente'+siguiente);
var f_slides = '';
if(n != 1)
	f_slides += '<a href="JavaScript:pintafotoverticalnorota(' + anterior + ')" class="MMVstop">Anterior</a>';
else
	f_slides += '<a href="JavaScript:pintafotoverticalnorota(' + n + ')" class="MMVstop">Anterior</a>';
f_slides += '<div class="MMV_slides">';
for(i = n,pos=1;pos <= limite_for;i++,pos++){
	datos = arrFotosVerticales[i].split('##');
	var clasefotoactiva = i == num ? 'class="activo"' : '';
	f_slides += '<span id="MMVfoto' + pos +'" ' + clasefotoactiva + '><a href="JavaScript:pintafotograndenorota(' + i +')" title=""><img src="' + datos[0] +'" alt="" /></a><span class="MMVico"></span></span>';
}	

if(siguiente < total)
	f_slides += '<a href="JavaScript:pintafotoverticalnorota(' + siguiente + ')" class="MMVsbottom">siguiente</a>';
f_slides += '</div>';

window.document.getElementById('MMVfotosslides').innerHTML = f_slides;
}	

function pintafotogrande(num){
	datos = arrFotosVerticales[num].split('##');
	window.document.getElementById('MMV_photo').innerHTML = '<a href=' + datos[3] + '><img src="'+ datos[2] + '" /></a>';

	if(noticias = window.document.getElementById('fotonoticiaV-3')) {
			for(inoticia in noticias.childNodes) {
				noticia = noticias.childNodes[inoticia];
				
				if((typeof(noticia.id) != "undefined") && (noticia.id.indexOf('fotonoticiaV-3-') == 0))
					noticia.style.display = "none";
			}
			if(noticia = window.document.getElementById('fotonoticiaV-3-' + num ))
				noticia.style.display = "";
	}
	pintafotovertical(1,num);
}
var timeOut;
function rotavertical(num) {
	pintafotogrande(num);
	num++;
	if(num>3)
		num=1;
	timeOut = window.setTimeout("rotavertical("+ num +")", 10000);
}
function pintafotoverticalnorota(num) {
	clearTimeout(timeOut);
	pintafotovertical(num);
}
function pintafotograndenorota(num) {
	clearTimeout(timeOut);
	pintafotogrande(num);
}
	/***************** FIN VOTOS y COMENTARIOS ***********************************/
//-->


function cambio_grafico(num) {
	eval('frm = window.document.varios_graficos_' + num + ';');
	numero = -1;
	for (i = 1; i <= frm.variables.value; i++){
		eval ('marcado = frm.chk_grafico_' + i + '.checked;');
		if (marcado){
			numero = numero + Math.pow(2,(i - 1));
		}
	}
	if (numero == -1){
		return;
	}
	eval('grafico = frm.grafico_' + num + '_' + numero + '.value;');
	document.getElementById('graficos_valor_' + num).innerHTML = '<img src="' + grafico +'"/>';;

}
