$(document).ready(function(){
	$(window).resize(function(){
		muevemenu();
	});
	$("#menuum div").each(function(){
		this.oldsize = this.offsetLeft;
	});
	
	$("a").each(function(){
		document_base = "http://www.um.es/atica/gat/gat2/";
	
		if (this.href.indexOf(document_base + "#")>= 0){
			this.href = document.location + this.href.substr(this.href.indexOf("#"),this.href.length);
		}
	});
	
	$("a.compartir").each(function(){
		this.href = this.href + document.location;
	});
	
	$("div.flash").each(function(){
		this.style.zIndex = "1";
		this.style.visibility = "visible";
		var so = new SWFObject(this.title, this.id, this.style.width, this.style.height, "8", "#ffffff");
		this.title = "";
	    so.addParam("wmode", "transparent");
		so.addParam("bgcolor", "#FFFFFF");
   		so.write(this.id);
	});
	
	$("#umbar a").click(function(){
		if (typeof(this.state) == "undefined"){
			this.state = true;
		}
		
		if (this.state){
			this.state = !this.state;
			$("#menuum div").each(function(){
				this.style.display = "none";
			});
			$("#menuum").fadeOut("fast").slideUp("slow");
			$("#umbar img").get(0).src = "imgs/umbar.jpg";
		}else{
			this.state = !this.state;
			$("#menuum").slideDown("slow",function(){
				$("#menuum div").each(function(){
					this.style.display = "block";
				});
			}).fadeIn("fast");
			
			$("#umbar img").get(0).src = "imgs/umbaro.jpg";
		}
	});
	
	muevemenu();
	
	$("a.ventana").click(function(){
          var t = this.title || $(this).text() || this.href;
		  if ($(this).is(".grande")){
		  	muestra_ventana(t, this.href, 580, 940);
		  }else if ($(this).is(".mediano")){
		  	muestra_ventana(t, this.href, 560, 770);
		  }else if ($(this).is(".peque")){
		  	muestra_ventana(t, this.href, 310, 360);
		  }else{
		  	muestra_ventana(t, this.href, 470, 600);
		  }
          return false;
    });
	
	if ($("#ruta").html() == "Inicio"){
		$("#ruta").hide();
	}
});

function muestra_ventana(t, url,alto,ancho){
	$.GB_show(url, {
            height: alto,
            width: ancho,
			close_img: "imgs/close.gif",
            animation: true,
            overlay_clickable: true,
            caption: t
       });	
}

function muevemenu(){
	var newleft = $("#web").get(0).offsetLeft;
	$("#menuum div").each(function(){
		this.style.left = (this.oldsize + newleft) + "px";
	});
}

function increaseFont(){
	$("p, li").each(function(){
		if (this.currentStyle)
          styleSize = parseInt(this.currentStyle.fontSize);
        else 
          styleSize = parseInt(window.getComputedStyle(this, null).fontSize);
		  
		this.style.fontSize = (styleSize + 1) + "px";
	});
	
	return false;
}

function decreaseFont(){
	$("p, li").each(function(){
		if (this.currentStyle)
          styleSize = parseInt(this.currentStyle.fontSize);
        else 
          styleSize = parseInt(window.getComputedStyle(this, null).fontSize);
		  
		this.style.fontSize = (styleSize - 1) + "px";
	});
	return false;
}