//<![CDATA[

/**
 * Esconde el enlace de tipo 'mailto' para evitar spam
 * @param {string} usuario
 * @param {string} dominio
 */
function nospam(usuario, dominio)
{
	window.location = 'mailto:' + usuario + '@' + dominio;
	return false;
} 

/**
 * 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);
		}
	);
}

/**
 * Realiza un efecto al pasar el ratón sobre los enlaces del pie de página.
 */
function rolloverPie()
{
	var ruta;
	var directorio;
	var imagen;
	$("#pie a").hover(		
		function(e)
		{
			ruta = $(this).css("background-image");
			directorio = ruta.substr(0, ruta.lastIndexOf("/"));
			imagen = "_" + ruta.substr(ruta.lastIndexOf("/") + 1, ruta.indexOf(".png"));	
			$(this).css("background-image", directorio + "/" + imagen);
		},
		function(e)
		{
			ruta = $(this).css("background-image");
			directorio = ruta.substr(0, ruta.lastIndexOf("/"));
			imagen = ruta.substr(ruta.lastIndexOf("/") + 1).replace("_", "");
			$(this).css("background-image", directorio + "/" + imagen);
		}
	);
}

/**
 * Activa los pop-ups de los enlaces con rel="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)
{
	if (ancho > screen.width) { ancho = screen.width;}
	if (alto > screen.height) { alto = screen.height;}
	var x = (screen.width - ancho) / 2;
	var y = ((screen.height - alto) / 2) - 30;
	$("[@rel=external],div.a a,div.b a,div.c a,div.d a,div.e a,div.f a").click(function(e) // Activamos el popup al hacer clic.
	{
		window.open(this.href, "Fotografía", "width=" + ancho + ",height=" + alto + ",left=" + x + ",top=" + y + ",resizable=yes,scrollbars=yes");
		return false;
	});
}

/**
 * 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 ();
		rolloverPie();
		activarPopups(1100,1100);
	}
);

//]]>
