	/*
	 * JavaScript Pretty Date
	 * Copyright (c) 2008 Óscar Serrano (jquery.com)
	 * Licensed under the MIT license.
	 */
	//Dada fecha  con hora devuelve solo la fecha
	function fechaSolo(time){
			var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," "));
			return date.getDate()+"/"+(date.getMonth()+1)+"/"+date.getFullYear();;
		}
	// Takes an ISO time and returns a string representing how
	// long ago the date represents.
	function prettyDate(time){
		var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
			diff = (((new Date()).getTime() - date.getTime()) / 1000),
			day_diff = Math.floor(diff / 86400);
				
		if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
		{
			var dia=date.getDate()+"/"+(date.getMonth()+1)+"/"+date.getFullYear();
			return dia;
		}
				
		return day_diff == 0 && (
				diff < 60 && "ahora mismo" ||
				diff < 120 && "hace 1 minuto" ||
				diff < 3600 && " hace "+Math.floor( diff / 60 ) + " minutos" ||
					diff < 7200 && "hace 1 hora" ||
				diff < 86400 && " hace "+ Math.floor( diff / 3600 ) + " horas") ||
			day_diff == 1 && "Ayer" ||
			day_diff < 7 && " hace "+ day_diff + " días" ||
			day_diff < 31 && " hace "+ Math.ceil( day_diff / 7 ) + " semanas";
	}
	
	// If jQuery is included in the page, adds a jQuery plugin to handle it as well
	if ( typeof jQuery != "undefined" )
		jQuery.fn.prettyDate = function(){
			return this.each(function(){
				var date = prettyDate(this.title);
				if ( date )
					jQuery(this).text( date );
			});
		};
		
	//devuelve el contenido del pie de pagina
	function piePagina()
	{
		var now = new Date();
		return "El Manco de La Pesquera (c) 2005-"+now.getFullYear() +" . Actualizado "+ prettyDate(document.lastModified);
	}

	//funcion comun a todas las paginas
	function inicializa()
	{
		 //rellenamos pie
		 $("div#footer").html("<p>"+piePagina()+"</p>");
		 //añadimos marcador de inicio
		 $("#header").append("<a name='inicio'></a>");
		 
		 //publicacion de fechas de los post
			$.each($(".fecha"),
					 function(){
						 	var fec=$(this).html();
							$("div#links").append("<li><a href='#"+fec+"'>"+fechaSolo($(this).html())+"<br/>"+$(this).prev().html().substring(0,30)+"...</a></li>");
							$(this).html("Publicado "+ prettyDate($(this).html()));
							$(this).append(" | <a href='#inicio'> Inicio</a>");
							$(this).prev().append("<a name='"+fec+"'></a>");
						 }
					 );
		//cargamos menu
		$("div#menu").load("menu.html");
		 //igualamos altura
		 var longitud=0;
		 if ($("div#column2").height() > $("div#column1").height()) {
            longitud=$("div#column2").height();
			$("div#column1").height($("div#column2").height())
        }else{
            longitud=$("div#column1").height();
        }
		longitud=longitud+200;		 
		 $("div#column1").height(longitud)
		 $("div#column2").height(longitud)
		
		$(".wiki").each(function() {
			var text = $(this).text();
			$(this).replaceWith($('<a href="http://es.wikipedia.org/w/index.php?search=' + escape(text) + '" target="_blank"></a>').text(text));
	  	});

		


	}
	

		
