MJL.event.add(window, "load", function(event) {
    // MJL に関係するコードはこの中に記述
    MJL.enable.flash("flash", { version : 9 });
    MJL.enable.styleSwitcher("styleSwitcher");
    MJL.enable.heightEqualizer("equalize");
	MJL.enable.heightEqualizer("box-equalize-01", {
        collect : function(parent) {
            return MJL.convArray(parent.getElementsByTagName("div"));
        }
    });
    MJL.enable.rollover("roll", { active : "active" });
	
    //
    // 画像とテキスト (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+35+"px"); // 画像幅を強制
            // 別カラムの margin を調整
            $("div.column", obj).css("margin-"+side,
                                     imgBlock[0].offsetWidth+"px");
        };
    }
    // 実行
    $(".lyt-image-01").each(getImgParallelStyler("left"));
    $(".lyt-image-02").each(getImgParallelStyler("right"));

}, false);


// MJL と無関係なコードはこの先に記述

$(function(){
	//グローバルナビゲーション現在地表示
    (function(){
        var path = location.pathname,
        dir = path.split("/")[1];
        if(path != "/"){
            $("#nav-global-02 li a").each(function(){
                var anc = $(this).attr("href").split("/"),
                re= new RegExp(dir, "g");
                for(var i=0; i<anc.length; i++){
                    if(anc[i].match(re)){
                        $(this).closest("li").addClass("active");
                    }
                }
            });
        }
    })();

    /*td要素内div要素(.tbl-dsc-01-inner)高さ揃え。
    1つのtd要素内に「.tbl-dsc-01-inner」は1つまで。*/
    if($(".tbl-dsc-01-inner")){
        var chkSize = function(){
            $(".tbl-dsc-01-inner").css("height", "");
            $(".tbl-dsc-01-inner").each(function(){		
                var t = $(this).closest("td"),
                hgt = t.height();
                if(hgt > $(this).height()){
                    $(this).css("height", hgt + "px");
                }
            });
        }
        setInterval(chkSize,500);
    }

	//span内の画像縦中央ぞろえ
    if(".list-images-02, .lyt-cmm-datali-02, .lyt-cmm-datali-01 .images span, .lyt-image-05 .image span, .list-images-04 li p span, .list-images-05 span, .list-images-06 span"){
        $(".list-images-02 li img, .lyt-cmm-datali-02 .images img, .lyt-cmm-datali-01 .images span img, .lyt-image-05 .image span img, .list-images-04 li p span img, .list-images-05 span img, .list-images-06 span img").each(function(){
            var imgHeight = $(this).height(),
            cloHeight = $(this).closest("span").height(),
            marTop = cloHeight - imgHeight;
			
            if(imgHeight < cloHeight){
                $(this).css("margin-top", marTop/2 + "px");
            }
        });
    }

    //イメージマップロールオーバー
    if($(".lyt-map-01")){
        var defSrc = $(".lyt-map-img-01").attr("src");
        $("#map").children("area").each(function(){
            $(this).bind("focusin mouseover",(function(){
                var num = $(this).index() + 1,
                chgSrc = defSrc.replace(".gif", "-0" + num + ".gif");
                $(".lyt-map-img-01").attr("src", chgSrc);
            })).bind("focusout mouseout",(function(){
                    $(".lyt-map-img-01").attr("src", defSrc);
            }));
        });
    }
    
    //プリントボタン
    if($(".doc-print-01")){
        $(".doc-print-01 a").click(function(){
            print();
        });
    }
	
});

// swf内で用いられているコード
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


