//<![CDATA[

/**
 * 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 marcarSeccionActiva(color)
{
	var url = ("." + document.URL.substring(document.URL.lastIndexOf("/")));
	//quitamos la cadena "query"
	var pos = url.indexOf("?");
	if (pos != -1) { url = url.substring(0, pos); }
	
	if (url == "./") { url = "./index.php"; }
	if (url == "./producto.php") { url = "./productos.php"; }
	var enlace = $("//a[@href='" + url + "']");
	
	enlace.css("color", color);
}

/**
 * Activa los pop-ups de los enlaces con class="externo", 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;
	$(".externo").click(function(e) // Activamos el popup al hacer clic.  
	{
		window.open(this.href, "popup", "width=" + ancho + ",height=" + alto + ",left=" + x + ",top=" + y + ",resizable=yes");
		return false;
	});
}

function activarRollover()
{
	$(".rollover").hover(
		function()
		{
			var nombre = $(this).attr("src").substr($(this).attr("src").lastIndexOf("/") + 1);
			$(this).attr("src", $(this).attr("src").replace(nombre, "_" + nombre));
		},
		function ()
		{
			var nombre = $(this).attr("src").substr($(this).attr("src").lastIndexOf("/") + 1);
			$(this).attr("src", $(this).attr("src").replace("_",  ""));
		}
	);
}

$(document).ready(function (e)
{
	marcarSeccionActiva("#666");
	activarRollover();
});

//]]>
