//<![CDATA[

/**
 * Activa el efecto rollover para las opciones del menú".
 */
function rolloverMenu()
{
	$("#menu img").each(function(e)
	{
		var imagen = $(this).attr("src");
		var extension = imagen.substring(imagen.lastIndexOf("."));
		var reemplazo = imagen.replace("1" + extension, "2" + extension);
		var fondo = imagen.replace("1" + extension, "3" + extension);
		
		$(this).hover(
			function()
			{
				$(this).attr("src", reemplazo);
				$("#menu").css("background", "url('" + fondo + "') no-repeat bottom left");
			},
			function()
			{
				$(this).attr("src", imagen);
				$("#menu").css("background", "none");
			}
		);
	});
}

/**
 * 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);
		}
	);
}

/**
 * Devuelve el componente del navegador necesario para trabajar con AJAX
 */
function cargarAjax()
{
    var xmlhttp;
    try
	{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e)
	{
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (e)
		{
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
	{
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
}

$(document).ready(function (e)
{
	rollover();
	rolloverMenu();
});

//]]>
