// JavaScript Document

$(document).ready(function(){
    
    $("#moveUp").click(function() {
        var t = $("#scrollable").css('top');
        var h = $("#scrollable").height();
        
        if (parseInt(t) == 0)
            return;
        
        if (parseInt(t) > (parseInt(h) * (-1)))
            $("#moveDown").fadeIn(500);
        
        var nt = parseInt(t) + 100;
        $("#scrollable").animate({top: nt}, 250);
        if (nt == 0)
            $(this).fadeOut(500);
    });
    
    $("#moveDown").click(function() {
        var t = $("#scrollable").css('top');
        var h = $("#scrollable").height();
        
        if (parseInt(t) == 0)
            $("#moveUp").fadeIn(500);
        
        var nt = parseInt(t) - 100;
        $("#scrollable").animate({top: nt}, 250);
        if (((nt - 110) * (-1)) > h)
            $(this).fadeOut(500);
    });
    
    $(".menu:first").show();
    $(".gallery:first").show();
    $(".month:first").show();

    $("#menus_sidebar a").click(function(e) {
        e.preventDefault();
        
        $("#copy").height($("#copy").height());
        
        $.ID = $(this).attr('href');
        $.curID = $("#menus_sidebar a.cur").attr('href');
        $.div = $(this);
        
        $($.curID).fadeOut(250,function() { $($.curID).hide(); });
        $("#menus_sidebar a.cur").animate({color: '#b30202'},250,function() {
            $($.div).css('color','#fff');
            if ($($.ID).hasClass('month')) {
                $($.ID).fadeIn(250);
                $("#menus_sidebar a.cur").css('color','');
                $("#menus_sidebar a.cur").hover(
                    function() { $(this).css('color','#FFF'); },
                    function() { $(this).css('color','#b30202'); }
                );
                $("#menus_sidebar a.cur").removeClass();
                
                $($.div).addClass("cur");
                $($.div).hover(
                    function() { $(this).css('color','#fff'); },
                    function() { $(this).css('color','#fff'); }
                );
            } else {
                $("#copy").animate({height: $($.ID).height()},500,
                    function() {
                        $($.ID).fadeIn(250);
                        $("#menus_sidebar a.cur").css('color','');
                        $("#menus_sidebar a.cur").hover(
                            function() { $(this).css('color','#FFF'); },
                            function() { $(this).css('color','#b30202'); }
                        );
                        $("#menus_sidebar a.cur").removeClass();
                        
                        $($.div).addClass("cur");
                        $($.div).hover(
                            function() { $(this).css('color','#fff'); },
                            function() { $(this).css('color','#fff'); }
                        );
                    }
                );
            }
        });
    });
    
    $(".img_nav a").click(function(e) {
        e.preventDefault();
        
        $.ID = $(this).attr('href');
        $.curID = $(this).parent().parent().parent().find("a.cur").attr('href');
        $.div = $(this);
        
        $($.curID).fadeOut(250,function() { $($.curID).hide(); });
        $(this).parent().parent().parent().find("a.cur").animate({color: '#b30202'},250,function() {
            $($.div).css('color','#fff');
            $($.ID).fadeIn(250);
            $(this).parent().parent().parent().find("a.cur").css('color','#b30202');
            $(this).parent().parent().parent().find("a.cur").hover(
                function() { $(this).css('color','#FFF'); },
                function() { $(this).css('color','#b30202'); }
            );
            $(this).parent().parent().parent().find("a.cur").removeClass();
            
            $($.div).addClass("cur");
            $($.div).hover(
                function() { $(this).css('color','#fff'); },
                function() { $(this).css('color','#fff'); }
            );
        });
    });
     
});

