$(document).ready(function (e) {
    var ultimoheadlink;

    $(".headerflotante").hide();
    $(".menubody li:odd").addClass("odd");

    //$(".headerflotante").hide();
    $(".menubody").hide();

    $(".bloqueheader").click(function (e) {
        //Oculta el resto
        if (ultimoheadlink != this) {
            $(".bloqueheader").removeClass("bloqueheaderclick");
            $(".headerflotante").hide("slow");
        }
        //Muestra el actual
        $(this).toggleClass("bloqueheaderclick");
        $(this).children(".headerflotante").toggle("slow");

        ultimoheadlink = this;
    });

    $(".menufooter").click(function (e) {
        $(this).siblings(".menubody").toggle("slow");
        $(this).toggleClass("menufooterclick").toggleClass("menufooter");
    });


    //Imagenes emergentes
    $(".comedorimg").click(function (e) {

        var src = $(this).attr("src");
        var cadsrc = src.split("/");
        cadsrc = jQuery.grep(cadsrc, function (a) { return a != "miniaturas"; });
        cadsrc = cadsrc.join("/")

        $("#foto").children("img").attr('src', cadsrc);
        $("#foto").css({
            position: 'absolute',
            left: (($(window).width() - 640) / 2),
            top: (($(window).height() - 480) / 2)
        }).show("slow");

    });

    $("#foto").click(function (e) {
        $(this).hide("slow");
    });


    //Jornadas en la cabecera
    $('.jornada').hide();
    $('.jornada:first').show();
    setInterval(function () {
        $('.jornada:visible').fadeOut(1000, function () {
            if ($(this).next('.jornada').size()) {
                $(this).next().fadeIn(1000);
            }
            else {
                $('.jornada').eq(0).fadeIn(1000);
            }
        });
    }, 10000);


});
