
$(document).ready(function(){
/*
 * -------------------------------------------------------------- Intercambio fotos
*/
	$("#proyectos h4 a").each(function(indice) {
		$(this).click( function() {
			if ( $(this).hasClass("desplegado") || $("div.imagenes").eq(indice).is(":visible") ) return false;
			$("div.imagenes").fadeOut(750).eq(indice).fadeIn(750);
			return false;
		});
	});


/*
 * -------------------------------------------------------------- Desplegables
*/
	$("h4 a, h5 a").click(function(){
	  if ($(this).parent().next().is(".panelPq,.panel")) {
		$(this).toggleClass("desplegado")
		    .parent().next().slideToggle(500);
	    } else {
	    	alert("¡Error en la estructura del DOM!");
	    }
	    return false;
	});
});



/*
 * -------------------------------------------------------------- Lightbox
*/

$(document).ready(function() {
    $("#popUp").find("a").click(abrirPopUp );
});

function abrirPopUp() {
    $("<div id='overlay'></div>").css({
        "display": "none",
        opacity: 0.6,
        height: $(document).height() + "px"
    }).appendTo("body").fadeIn(400, function() { // Al terminar de mostrar la mascara negra
        var scrollBrowser = window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop;
        $("#listadoProyectos")
            .css({ 'top' : scrollBrowser + ($(window).height() / 6) + 'px' })
            .fadeIn(600, function() {
                $("#overlay ,#listadoProyectos a.cerrar").click( function() {
                    $("#listadoProyectos, #overlay").fadeOut(400, function() {
                        $("#overlay").remove();
                    });
                });
            });
            $('#overlay').css({height: $(document).height() + "px"});
    });
    return false;
}


/*
 * -------------------------------------------------------------- png's para IE6
*/

$(document).ready(function() {
	if($.browser.msie && $.browser.version < 7) {
		$('img[src$=.png]').each(function() {
			var _this = $(this);
			var src = _this.attr('src');
			_this.attr('src', 'img/blank.gif');
			this.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src='+ src +', sizingMethod=image)';
		});
	}
});