MJL.event.add(window, "load", function(event) {
    //MJL.enable.flash("flash");
    MJL.enable.window("blank");
    MJL.enable.window("pdf");
    //MJL.enable.tab("tabs");
    //MJL.enable.styleSwitcher("styleSwitcher");
    MJL.enable.heightEqualizer("list-index-01", {groupBy : 2});
    MJL.enable.heightEqualizer("list-index-01", {
        groupBy : 2,
        collect : function(parent) {
            return MJL.getElementsByClassName(parent, "title");
        }
    });
    MJL.enable.heightEqualizer("col2", {groupBy : 2});
    MJL.enable.heightEqualizer("col2index", {
        groupBy : 2,
        collect : function(parent) {
            return MJL.getElementsByClassName(parent, "body");
        }
    });
    MJL.enable.rollover("roll", {disable : "unroll"});
    
    //
    // 画像とテキスト (based on jQuery)
    //
    // 画像とテキストの並列処理を行う関数を返す高階関数
    function getImgParallelStyler(side) {
        // side は既定値しか認めない
        if ("left" != side && "right" != side) {
            throw Error("invalid side type: '"+side+"'");
        }
        // 実行関数
        return function() {
            var obj = $(this);
            var imgBlock = $("div.image:first-child", obj);
            var imgWidth = $("p.image img", imgBlock).width(); // 画像幅
            imgBlock.css("width", imgWidth+"px"); // 画像幅を強制
            // 別カラムの margin を調整
            $("div.column", obj).css("margin-"+side,
                                     imgBlock[0].offsetWidth+"px");
        };
    }
    // 実行
    $(".image-parallel.image-L").each(getImgParallelStyler("left"));
    $(".image-parallel.image-R").each(getImgParallelStyler("right"));
    
}, false);

// MJL と無関係なコードはこの先に記述

$(function() {
    
    var $gnav = $("#globalNavi");
    var $main = $("#main");
    var $localNav = $("#localNavi");
    
    // Global Navigation Control
    function globalNaviCheck() {
        var bodyclass = $("body").attr("class");
        $("li", $gnav).each(function(){
            var listid = $(this).attr("id").replace("gn-", "");
            if (bodyclass == listid) {
                $(this).addClass("unroll");
                $("img", this).each(function(){
                    this.src = this.src.replace( /(\.[a-z]{3})$/, "_o$1");
                });
            }
        });
    }
    $("#globalNavi").each(function(){
        globalNaviCheck();
    });
    
    
    // Local navigation control
    $('li:first-child', $localNav).addClass("firstChild");
    $('li:last-child', $localNav).addClass("lastChild");
    
    //なかソン非表示
    var _pagePath = location.pathname.replace(/(.*)\/(.*)/,'$1').split("/")[2];
    /*if(_pagePath == 'schedule'){
        $('li:last-child', $localNav).hide()}
        $('body.top .list-link-01 li').each(function(){
        var _link_text = $('a',this).html();
        if(_link_text == 'なかよしソングフェスティバル'){$(this).hide();}
    });*/
    
    // pathname と ローカルナビゲーション内の href 属性値にある index.html という箇所をすべて削除
    function activePageCheck() {
        var path = window.location.pathname.replace("index.html", "");
        $("a", $localNav).each(function(){
            var _href = $(this).attr("href").replace("index.html", "").replace(/http:\/\/[^/]*?\//, "/");
            if (path == _href) {
            	$(this).addClass("active");
            }
        });
    }
    
    $("#localNavi").each(function(){
        activePageCheck();
        $("a.active", this).parents("li").addClass("selected");
    });
    
    
    
    // Stripe Table
    $(".tbl-striped tbody tr:nth-child(odd)").addClass("odd");
    $(".tbl-striped tbody tr:nth-child(even)").addClass("even");
    
    
    // List Numbering
    $(".list-ordered-01").each(function() {
        $("> li", this).each(function(i) {
            $(this).addClass("nb"+(i+1));
        });
    });
    
    // Heading Elements with Concert Tag
    $("div.hdg-l3-01-container p.tag").siblings("h3").addClass("with-tag");
    
    // JOC Top Page Index Module
    $("#joc.top #index > li, #joc.top div.column").hover(
        function(){
            $(this).addClass('over');
        },
        function(){
            $(this).removeClass('over');
        }
    );
});
