$(document).ready(function(){
    // REMOVE ROLLOVER ON IMAGES {{{
    $("a img").mouseover(function(){
        $(this).parent().css("outline", "none");
    });
    // }}}

    // ROLLOVER TRACÉS {{{
    $("img.thumbs").each(function(){
        path = $(this).attr("src").split("/th")[0];
        filename = $(this).attr("title").split(":", 1)[0];
        $(this).removeAttr("width");
        $(this).removeAttr("height");
        $(this).attr("id", filename);
        $(this).after("<img id='" + filename + "-traces.png' class='traces' src='" + path + "/" + filename + "-traces.png'/>");
        $(this).hide();
    });
    $("table.thumbtable td, div.thumblist a").hover(function(){
            target = $("img.traces", $(this));
            $(target).hide();
            $(target).prev().show();
        }, function(){
            $(target).show();
            $(target).prev().hide();
    });
    // }}}
    
    // EDIT HELP POSITIONING + COLLAPSING SUBSECTIONS {{{
        $("div.edit-help").css({"position": "absolute", "top": "100px", "left": "620px", "width": "300px"});
        $("div.edit-help div.collapsed").hide();
        $("div.edit-help h3").toggle(
            function(){
                $(this).next().show();
            },function(){
                $(this).next().hide();
        });
    // }}}
    
    // CALCULATE HEIGHT OF "LA PINCE" {{{ 
        //$("iframe#pince").css("height", $("body").css("height"));
        //$(window).scroll(function(){
            ////console.log("bla");
            //$("iframe#pince").css("right", "0");
        //});
    // }}}
    // HIDES "LA PINCE" {{{
        //$("div.page").mouseover(function(){
            //$(this).css("z-index", "1000");
        //});
        //$("div.page").mouseover(function(){
            //$(this).css("background-color", "white");
            //$(this).css("border-right", "1px solid DarkSlateGrey");
            //$(this).css("padding-right", "1em");
            //$(this).css("z-index", "1000");
        //});
        //$("div.page").hover(function(){
            //$(this).css("background-color", "white");
            //$(this).css("border-right", "1px solid DarkSlateGrey");
            //$(this).css("padding-right", "1em");
            //$(this).css("z-index", "1000");
        //}, function(){
            //$(this).css("background", "none");
            //$(this).css("border-right", "none");
        //});
        //$("iframe#pince").hover(function(){
            //$(this).css("z-index", "1000");
        //}, function(){
            //$(this).css("z-index", "-1");
        //});

    // }}}
    if ($(".audio").length != 0) {
        flowplayer(".audio", "http://balsamine.be/pub/skins/balsamine/js/flowplayer/flowplayer-3.2.7.swf", { 
            clip: {
                autoPlay: false,
                scaling: "fit",
                autoBuffering: true,
            },
            canvas: {
                backgroundColor: "#FFFFFF",
                backgroundGradient: "none",
            },
            plugins: {
                audio: {url: "http://balsamine.be/pub/skins/balsamine/js/flowplayer/flowplayer.audio-3.2.2.swf",},
                controls: {
                    fullscreen: false,
                    time: true,
                    play: true,
                    volume: true,
                    autoHide: false,
                    height: 18,
                    backgroundColor: "#FFFFFF",
                    backgroundGradient: "none",
                    buttonColor: "#000000",
                    buttonOverColor: "#000000",
                    timeFontSize: 9,
                },
            }
        });
    }
    
    if ($(".video").length != 0) {
        flowplayer(".video", "http://balsamine.be/pub/skins/balsamine/js/flowplayer/flowplayer-3.2.7.swf", { 
            clip: {
                autoPlay: false,
                autoBuffering: true,
                scaling: "fit",
            },
            canvas: {
                backgroundColor: "#FFFFFF",
                backgroundGradient: "none",
            },
            plugins: {
                controls: {
                    fullscreen: true,
                    time: true,
                    play: true,
                    volume: true,
                    autoHide: true,
                    height: 18,
                    backgroundColor: "#FFFFFF",
                    backgroundGradient: "none",
                    buttonColor: "#000000",
                    buttonOverColor: "#000000",
                    timeFontSize: 9,
                },
            }
        });
    }
    // AGENDA: COLLAPSING MONTHS
    $("div.month tr:first-child").click(function(){
        $(this).parent().parent().parent().toggleClass("past");
    });
});

