jQuery( document ).ready( function ($) {
    // for jquery file tree
    $('#fileTree').fileTree(
        {
            root  : './',
            script: './jqueryFileTree.cgi',
            multiFolder: true
        },
        function(file) {
            // callback is colorbox
            if (file.match(/\.(png|jpe?g|gif)$/i)) {
                $.fn.colorbox({ href: file, maxWidth: "80%", maxHeight: "80%" });
            }
            else if (file.match(/\.(zip|lzh)$/i)) {
                alert("Not Available.");
            }
            else {
                $.fn.colorbox({ iframe: true, href: 'sourcereader.cgi?file=' + file, width: "80%", height: "80%" });
            }
        }
    );

    // for auto code highlight
    $('pre code').addClass('prettyprint');
    if (window.prettyPrint)
    {
        prettyPrint();
    }

    // for menu
    $("#menu ul.list-item-list").css({ display:"none" });
    var effect_speed = 'fast';
    $("#menu ul.list li.list-item").hover( function () {
        $(this).children("ul.list-item-list").slideDown(effect_speed);
    }, function () {
        $(this).children("ul.list-item-list").slideUp(effect_speed);
    });

    // for div.header fixed
    var box = $('div.header').css({'position':'absolute','top':0,'left':0,'background-color':'#255e7f'});
    $(window).scroll( function () {
        box.css('top', $(document).scrollTop());
    });
});

