var meses = new Array();
meses["es"] = new Array("Enero","Febrero","Marzo","Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
meses["en"] = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
meses["po"] = new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro");


function swapImage(obj, strAdd){
    var parts = $(obj).attr("src").split('.');
    var id = $(obj).attr("id");
    var fparts = parts[parts.length-2].split('/');
    fparts[fparts.length-1] = id+strAdd;
    $(obj).attr("src", fparts.join('/')+"."+parts[parts.length-1]);
}


////////////////////////////////////////////////////////////////
// Navegacion y Menu
function setUpMenu(){
  $('.menu li').each(function (){
    $(this).mouseover(function (){
        $(this).addClass("hover");
    });
    $(this).mouseout(function (){
        $(this).removeClass("hover")
    });
  });
  $('.menu li a.mainItem').each(function (){
    $(this).mouseover(function (){
		$(this).addClass("hover");
        // swapImage($("img",this), "_over");
    });
    $(this).mouseout(function (){
		$(this).removeClass("hover")
        // swapImage($("img",this), "");
    });
  });
}

function getDateNow(){
	var fecha = new Date();
	var dia = fecha.getDate();
	var mes = fecha.getMonth();
	var anio = fecha.getFullYear();
	 if (typeof idioma == "undefined")  return;
	switch (idioma){
		case "en":
			if ((dia == 1) || (dia != 11) && (dia % 10 == 1)) 		// Correction for 11th and 1st/21st/31st
				strDay = "st";
			else if ((dia == 2) || (dia != 12) && (dia % 10 == 2)) 	// Correction for 12th and 2nd/22nd/32nd
				strDay = "nd";
			else if ((dia == 3) || (dia != 13) && (dia % 10 == 3)) 	// Correction for 13th and 3rd/23rd/33rd
				strDay = "rd";
			else
				strDay = "th";
			return meses[idioma][mes]+" "+dia+strDay+", "+anio; 
			break;
		case "es":
			return dia+" de " + meses[idioma][mes] + " de " + anio;
			break;
		case "po":
			return meses[idioma][mes] + " " + dia + ", " + anio;
			break;
	}
}


////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
$(document).ready(setUpMenu);

/* Tooltips para glosario (necesita: jquery.tooltip.js)*/
$(document).ready(function (){
	$("#dateheader").html( getDateNow() );
	$("cite.glosario").tooltip({
       delay: 200,
       track: true,
       showBody: ":",
       fade: 250,
       top: -20
    })
	$(".hoverTools").mouseover(function (){
		$("#tools", this).show();
	});
	$(".hoverTools").mouseout(function (){
		$("#tools", this).hide();
	});
	
	
	/* Recuperar resolucion de pantalla */
	function writescreen(){
		var today = new Date();
		var the_date = new Date("December 31, 2023");
		var the_cookie_date = the_date.toGMTString();
		var the_cookie = "resolution="+screen.width +"-"+ screen.height;
		var the_cookie = the_cookie + ";expires=" + the_cookie_date + ";path=/";
		document.cookie=the_cookie
	} 	
	writescreen();
	
	
});


////////////////////////////////////////////////////////////////


