//<![CDATA[

/**
 * Realiza un efecto al pasar el ratón sobre las imágenes marcadas con la clase
 * "rollover".
 */
function rollover ()
{
	var ruta;
	var directorio;
	var imagen;
	$(".rollover").hover(		
		function(e)
		{
			ruta = $(this).attr("src");
			directorio = ruta.substr(0, ruta.lastIndexOf("/"));
			imagen = "_" + ruta.substr(ruta.lastIndexOf("/") + 1);
			$(this).attr("src", directorio + "/" + imagen);
		},
		function(e)
		{
			ruta = $(this).attr("src");
			directorio = ruta.substr(0, ruta.lastIndexOf("/"));
			imagen = ruta.substr(ruta.lastIndexOf("/") + 1).replace("_", "");
			$(this).attr("src", directorio + "/" + imagen);
		}
	);
}

/**
 * Marca con CSS la sección del menú que sea la activa en ese momento.
 * @param color string El color en que se marcará el enlace
 */
function markActiveSection(color)
{
	var url = (document.URL.substring(document.URL.lastIndexOf("/")));
	var pos = url.indexOf("?");
	if (pos != -1) { url = url.substring(0, pos); }
	
	var enlace = $("a[href*='" + url + "']");
	enlace.css("background-color", color);
	enlace.css("border-color", "#000");
}

/**
 * Activa los pop-ups de los enlaces con class="external", y centra el pop-up en la pantalla. 
 * Hace uso de la biblioteca jQuery. 
 * @param {int} ancho
 * @param {int} alto
 */
function activarPopups(ancho, alto)
{
	var x = (screen.width - ancho) / 2;
	var y = ((screen.height - alto) / 2) - 30;
	$("[rel=external]").click(function(e) // Activamos el popup al hacer clic.  
	{
		window.open(this.href, "popup", "width=" + ancho + ",height=" + alto + ",left=" + x + ",top=" + y + ",resizable=yes,scrollbars=yes");
		return false;
	});
}

$(document).ready(
	function(e)
	{
		rollover ();
		activarPopups(800,800);
	}
);

//]]>
