$(document).ready(function(){

   $("a#nav-atelier").hover(
        function() {
            $("a#nav-atelier span").fadeIn("fast");
        },
        function() {
            $("a#nav-atelier span").fadeOut(0);
        }
   );

  /*$.timer(6500, function (timer) {
  	$("a#nav-atelier span").fadeOut("slow");
  	timer.stop();
  });*/




    $("span#visited-switcher").click(
        function() {
            if ( $.cookie("showVisited")=="false") {
                $("div.project").addClass("hv");
                $.cookie('showVisited', 'true', { expires: 365, path: '/' });
                $(this).text("skrýt navštívené");
                $(this).attr("title", "Skrýt náhledy mnou již navštívených projektů");
            } else {
                $("div.project").removeClass("hv");
                $.cookie('showVisited', 'false', { expires: 365, path: '/' });
                $(this).text("zobrazit navštívené");
                $(this).attr("title", "Zobrazit náhledy mnou navštívených projektů");
            }

        }
    );

    $("div#detail-name").click(
        function() {
            $("div#detail-project-info").toggle();
            $("div#detail-group-info").toggle();
        //            $("div#detail-name").append('&#8230;');
        }
        );


    $(".hoverable").hover(
        function() {
            $(this).addClass("hoverdiv");
        },
        function() {
            $(this).removeClass("hoverdiv");
        }
        );

    $("div#atelier-student-photos img").hover(
        function() {
            var name = $(this).attr('title');
            $('span.chrono-student a[text='+name+']').parents('span').addClass('hoverdiv');
        },
        function() {
            var name = $(this).attr('title');
            $('span.chrono-student a[text='+name+']').parents('span').removeClass('hoverdiv');
        }
        )

    $("div#detail-menu-info").hover(
        function() {
            $("div#detail-menu-info div").css("background-color", "white");
        },
        function() {
            $("div#detail-menu-info div").css("background-color", "transparent");
        }
        );

    $("div.custom-layout img").hover(
        function() {
            $(this).css("z-index", 50);
            var label = $(this).attr("alt");
            $("div#project-workinfo").text(label);
        },
        function() {
            $(this).css("z-index", 1);
            $("div#project-workinfo").text("");
        }
        );

      $("div#detail-works img").hover(
        function() {
            var label = $(this).attr("alt");
            $("div#project-workinfo").text(label);
        },
        function() {
            $("div#project-workinfo").text("");
        }
        );

    /*
    $("a#next-project").hover(  function() {$(this).hide();}, function() {$("div#project-workinfo").text('');}  );
    $("a#previous-project").hover(  function() {$("div#project-workinfo").text('předchozí projekt');}, function() {$("div#project-workinfo").text('');}  );
    $("a#next-author").hover(  function() {$("div#project-workinfo").text('další autorův projekt');}, function() {$("div#project-workinfo").text('');}  );
    $("a#previous-author").hover(  function() {$("div#project-workinfo").text('předchozí autorův projekt');}, function() {$("div#project-workinfo").text('');}  );
*/

    /*
    if ( $.cookie("id-students")!=null ) {
        if ( $.cookie("id-students")=="false" ) {
            $("div.box-students div.content-area").hide()
        }
    } else {
        $.cookie("id-students", "false")
        $("div.box-students div.content-area").hide();
    }
    if ( $.cookie("id-groups")!=null ) {
        if ( $.cookie("id-groups")=="false" ) {
            $("div.box-groups div.content-area").hide();
        }
    } else {
        $.cookie("id-groups", false);
        $("div.box-groups div.content-area").hide();
    }
*/

  

    $("div.project").hover(
        function() {
            var groupID = $(this).attr("gid");
            $("div.project[gid="+groupID+"]").addClass("backbold");
            $("div.project[gid="+groupID+"] span.pn").addClass("visible-text");
        },
        function() {
            var groupID = $(this).attr("gid");
            $("div.project[gid="+groupID+"]").removeClass("backbold");
            $("div.project[gid="+groupID+"] span.pn").removeClass("visible-text");

        }
        );
    /*
    $("div.project").hover(
        function() {
            $('[id^=row_]').size();

            var group = $(this).attr("gID");

            var groupID = $(this).attr("gID");
            $("div.project[gID="+groupID+"]").addClass("backbold");
            $("div.project[gID="+groupID+"] span.pn").addClass("visible-text");
        },
        function() {
            var groupID = $(this).attr("gID");
            $("div.project[gID="+groupID+"]").removeClass("backbold");
            $("div.project[gID="+groupID+"] span.pn").removeClass("visible-text");

        }
    );
*/


    $("div.section-title").click(
        function() {
            //            var id = $(this).attr("id");
            //            var bool = $.cookie(id);
            //            if (bool=="true") bool="false"; else bool="true";
            //            $.cookie(id, bool);
            //            $(this).siblings("d   iv").toggle();
            $(this).siblings("div").toggleClass("invisible");
        }
        );

    $("div.menu-main-item").click(
        function() {
            var id = $(this).attr("id");
            var bool = $.cookie(id);
            if (bool=="true") bool="false"; else bool="true";
            $.cookie(id, bool);
            $("div#"+id+"-content").toggle();
        }
        );



/* calendar */
    $("span.calendar-label").hide();

        $("div#calendar").hover(
            function() {
                $("span.calendar-label").fadeIn("fast");
            },
            function() {
                $("span.calendar-label").fadeOut("fast");
            }
        );
        
//    $("span.calendar-event").animate({ width:"800px" });


});
