function loadMJL(event) {
    MJL.enable.heightEqualizer("equalize");
    MJL.enable.flash("flash");
	MJL.enable.styleSwitcher("styleSwitcher");
    MJL.enable.rollover("roll", {disable:"unroll"});

    if (!spCheck()) {
        MJL.enable.heightEqualizer("list-col2",{
            groupBy:2,
            collect:function(parent) {
                return parent.getElementsByTagName("li");
            }
        });
    }
    MJL.enable.heightEqualizer("list-col3",{
        groupBy:3,
        collect:function(parent) {
            return parent.getElementsByTagName("li");
        }
    });
    MJL.enable.heightEqualizer("list-col4",{
        groupBy:4,
        collect:function(parent) {
            return parent.getElementsByTagName("li");
        }
    });
    MJL.enable.heightEqualizer("list-col5",{
        groupBy:5,
        collect:function(parent) {
            return parent.getElementsByTagName("li");
        }
    });
    MJL.enable.heightEqualizer("lay-col2-01",{
        groupBy:2,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "box-01");
        }
    });
    MJL.enable.heightEqualizer("lay-col3-01",{
        groupBy:3,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "box-01");
        }
    });
    MJL.enable.heightEqualizer("nav-index-01",{
        groupBy:2,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "col");
        }
    });
    MJL.enable.heightEqualizer("nav-index-03",{
        groupBy:3,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "col");
        }
    });
    MJL.enable.heightEqualizer("nav-index-04",{
        groupBy:2,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "col");
        }
    });
    MJL.enable.heightEqualizer("nav-index-05",{
        groupBy:3,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "col");
        }
    });
    MJL.enable.heightEqualizer("nav-index-09",{
        groupBy:2,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "col-inner");
        }
    });
    MJL.enable.heightEqualizer("nav-index-10",{
        groupBy:3,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "col-inner");
        }
    });
    MJL.enable.heightEqualizer("nav-index-11",{
        groupBy:2,
        collect:function(parent) {
            return parent.getElementsByTagName("li");
        }
    });
    MJL.enable.heightEqualizer("nav-index-12",{
        groupBy:2,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "col-inner");
        }
    });
    MJL.enable.heightEqualizer("nav-button-03",{
        groupBy:3,
        collect:function(parent) {
            return parent.getElementsByTagName("li");
        }
    });
    MJL.enable.heightEqualizer("nav-toc-01",{
        collect:function(parent) {
            return parent.getElementsByTagName("a");
        }
    });
    MJL.enable.heightEqualizer("list-staff-01",{
        groupBy:5,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "staff");
        }
    });
    if (!spCheck()) {
        MJL.enable.heightEqualizer("nav-footer-equalize",{
            groupBy:4,
            collect:function(parent) {
                return parent.getElementsByTagName("li");
            }
        });
    }
    MJL.enable.heightEqualizer("nav-content-08",{
        groupBy:2,
        collect:function(parent) {
            return MJL.getElementsByClassName(parent, "block");
        }
    });


    MJL.enable.window("popup_01", {width: 640, height: 600});
    MJL.enable.window("popup_02", {width: 1010, height: 692, menubar: "no", toolbar: "no", location: "no"});
    MJL.enable.window("popup_03", {width: 1014, height: 700, menubar: "no", toolbar: "no", location: "no"});
    MJL.enable.window("popup_04", {width: 1024, height: 600, menubar: "no", toolbar: "no", location: "no"});
    MJL.enable.window("popup_05", {width: 1000, height: 685, menubar: "no", toolbar: "no", location: "no"});
    MJL.enable.window("popup_06", {width: 1000, height: 670, menubar: "no", toolbar: "no", location: "no"});
    MJL.enable.window("popup_07", {width: 900, height: 700});
	MJL.enable.window("popup_08", {width: 1024, height: 768, menubar: "no", toolbar: "no", location: "no"});
	MJL.enable.window("popup_09", {width: 1000, height: 780, menubar: "no", toolbar: "no", location: "no"});

    // ------------------------------------------------------------------------
    // 画像とテキスト
    // ------------------------------------------------------------------------
    // 画像とテキストの並列処理を行う関数を返す高階関数
    function getImgParallelStyler(side) {
        return function() {
            var obj = $(this);
            var imgBlock = $('div.pict:first-child', obj);
            var imgWidth = $('img', imgBlock).width(); // 画像幅
            imgBlock.css('width', imgWidth+'px'); // 画像幅を強制
            // 別カラムの margin を調整
            $('div.text', obj).css('margin-'+side, imgBlock[0].offsetWidth+'px');
        };
    }
    // 実行
    $('.lay-pict-02.left-pict').each(getImgParallelStyler('left'));
    $('.lay-pict-02.right-pict').each(getImgParallelStyler('right'));
}
//YougoLinkAPIがロードされていないときだけ実行
if ( typeof(YougoLinkApi) == 'undefined' ) {
    MJL.event.add(window, "load", loadMJL, false);
}


// ----------------------------------------------------------------------------
// jQuery
// ----------------------------------------------------------------------------
 
$(function(){

    
    
    // ------------------------------------------------------------------------
    // jQuery quickSearch plugin
    // ------------------------------------------------------------------------
    $('div.form-easysearch-01-inner > form').quickSearch();
    
    
    // ------------------------------------------------------------------------
    // jQuery rssParser plugin
    // ------------------------------------------------------------------------
    // RSSの読み込みは「重要なお知らせ」から読み込むようにします。
    // サイトトップ
    $('div.home_topics_imp').rssParser({ files:['/topics/important.xml'], limit: 5, type:"important" });
    $('div.home_topics').rssParser({ files:['/topics/topics.xml'], limit: 5 });
    // 知る・楽しむ
    $('div.enjoy_topics_imp').rssParser({ files:['/topics/enjoyimportant.xml'], limit: 5, type:"important" });
    $('div.enjoy_topics').rssParser({ files:['/topics/enjoytopics.xml'], limit: 5 });
    // 個人のご契約者様
    $('div.keiyaku_topics_imp').rssParser({ files:['/topics/keiyakuimportant.xml'], limit: 5, type:"important" });
    $('div.keiyaku_topics').rssParser({ files:['/topics/keiyakutopics.xml'], limit: 5});
    // 日本生命について
    $('div.kaisha_topics_imp').rssParser({ files:['/topics/kaishaimportant.xml'], limit: 5, type:"important" });
    $('div.kaisha_topics').rssParser({ files:['/topics/kaishatopics.xml'], limit: 5 });
    // 法人のお客様
    $('div.hojin_topics_imp').rssParser({ files:['/topics/hojinimportant.xml'], limit: 5, type:"important" });
    $('div.hojin_topics').rssParser({ files:['/topics/hojintopics.xml'], limit: 5 });
    // 保険をご検討中のお客様 
    $('div.kojin_topics_imp').rssParser({ files:['/topics/kojinimportant.xml'], limit: 5, type:"important" });
    $('div.kojin_topics').rssParser({ files:['/topics/kojintopics.xml'], limit: 5 });
    // ニュースRSS
    $('div.news_topics').rssParser({ files:['/news/news.xml'], limit: 5, type:"news" });
    // 野球部ニュースRSS
    $('div.baseball_news_topics').rssParser({ files:['/enjoy/sports/baseball/news/baseballtopics.xml'], limit: 5, type:"news" });
});


// ----------------------------------------------------------------------------
// jQuery quickSearch plugin
// 保険をご検討中のお客様　保険簡単サーチ
// ----------------------------------------------------------------------------
(function ($) {
    $.fn.quickSearch = function (options) {
        return this.each(function (i) {
            $(this).prepend('<p class="btn-disp"><img src="/kojin/images/btn_open.gif" alt="開く" width="53" height="15" /></p>'); // トグルボタン要素の作成と配置
            var toggleBtn = $("p.btn-disp > img", this).css("cursor", "pointer"); // トグルボタン
            var searchBtn = $("input:image", this); // 検索ボタン
            var flg = false; // フラグ用
            var target = []; // toggle対象要素群
            // target[]にtoggle対象要素群の収集
            target.push($("p.btn-submit", this)[0]);
            $("dt,dd,", this).each(function (i) {
                (i == 0 | i == 1) ? void(0) : target.push(this);
            });
            $(target).hide();// 初期状態でtoggle対象要素は隠しておく
            
            // CSS
            $(this).parent().parent().css({position: "relative", minHeight:"175px"});
            if(!$.support.objectAll) {
                $(this).parent().parent().css({height:"175px"});
            }
            $(this).parent().css({position:"absolute"});

            // イベント
            toggleBtn.click(function (e) { toggle(this, e) });
            $("input:radio", this).click(function (e) { toggle(this, e) });
            
            // 実行関数
            function toggle(elem, e) {
                var preLoad = new Object();
                var img = toggleBtn[0];
                var imgName = img.src.substr(0, img.src.lastIndexOf("_"));
                var openImgSrc = imgName + "_open.gif";
                var closeImgSrc = imgName + "_close.gif";
                preLoad[img] = new Image();
                preLoad[img].src = closeImgSrc;
                if (flg == false) {
                    $(target).slideDown("slow", function () {
                        img.src = closeImgSrc;
                        img.setAttribute("alt", "閉じる");
                        flg = true;
                    });
                } else if (flg == true && elem.nodeName != "INPUT") {
                    $(target).slideUp("fast", function () {
                        img.src = openImgSrc;
                        img.setAttribute("alt", "開く");
                        flg = false;
                    });
                }
                else {
                    return
                }
            };
            
        });
    };
})(jQuery);



// ----------------------------------------------------------------------------
// jQuery rssParser plugin
// RSS解析
// 
// Attributes:
// -@options: オプションのハッシュ
//  -files: RSSファイルへのパス files:['hoge.xml','fuga.rdf']
//  -limit: HTMLに表示する件数
// ----------------------------------------------------------------------------

(function($){
    var name_space = 'rssParser';
    $.fn[name_space] = function(options){
        var settings = $.extend({
            files : false,
            limit: 10,
            merge: null,
            type: false
        }, options);
        
        return this.each(function(i){
            var elm = $(this);
            var newArr = [];
            var rss_index = 0;
            var rss_files = settings.files;
            var merge_files = settings.merge;
            elm.empty();
            
            // RSSデータの取得（通常）
            function load_rss(){
                var file = rss_files[rss_index];
                $.ajax({
                    type: "GET",
                    url: file,
                    cache: false,
                    success: function(data, status){
                        buildNewData(data);
                        if(rss_index == (rss_files.length-1)){
                            showHtml(newArr);
                        }
                        else{
                            rss_index++;
                            load_rss();
                        }
                    }
                });
            }
            load_rss();
            
            // XML解析
            // 引数でわたされたdata(ajaxで取得したデータ)を解析して必要なデータを配列（newArr）に格納する
            function buildNewData(data){
                // RSS バージョンの取得
                var rssVersion;
                $(data).children().each(function(){
                    var elmName = $(this)[0].tagName;
                    switch(elmName){
                        case "rss":
                            rssVersion = this.getAttribute("version");
                            break;
                        case "rdf:RDF":
                            this.getAttribute("xmlns").search(/(1\.0)/);
                            rssVersion = RegExp.$1;
                            break;
                        case "feed":
                            this.getAttribute("xmlns").search(/(Atom)/);
                            rssVersion = RegExp.$1;
                            break;
                        default:
                            rssVersion = "2.0";
                            break;
                    }
                });
                // item要素の中身を解析してnewArrに格納
                if( $("item", data).length == 0 ) {
                    showHtml("error");
                }
                $("item", data).each( function(i){
                    var title = $("title", this).text();
                    var link = $("link", this).text();
                    var description = $("description", this).text();
                    var category = $("category", this).text();
                    var summary = $("summary", this).text();
                    var date;
                    $(this).children().each(function(){
                        var elmName = $(this)[0].tagName.toUpperCase();
                        if(elmName == "PUBDATE" || elmName == "DC:DATE" || elmName == "UPDATED"){
                            date = getPuDate($(this).text(), rssVersion);
                        }
                    });
                    switch(rssVersion){
                        case "2.0":
                            newArr.push({'version':"2.0", 'title':title, 'link':link, 'date':date, 'category':category, 'description':description });
                            break;
                        case "1.0":
                            newArr.push({'version':"1.0", 'title':title, 'link':link, 'date':date, 'description':description});
                            break;
                        case "Atom":
                            newArr.push({'version':"atom", 'title':title, 'link':link, 'date':date, 'summary':summary});
                            break;
                        default:
                            newArr.push({'version':"2.0", 'title':title, 'link':link, 'date':date, 'category':category, 'description':description });
                            break;
                    }
                });
            }
            
            // RSSの日時のフォーマットを「yyyy年mm月dd日」の形に変換してテキストで返す
            function getPuDate(date, version){
                if(date.match("Err")){ return false };
                var month;
                var day;
                var months = [ ["Jan", "01"],["Feb", "02"],["Mar", "03"],["Apr", "04"],["May", "05"],["Jun", "06"],["Jul", "07"],["Aug", "08"],["Sep", "09"],["Oct", "10"],["Nov", "11"],["Dec", "12"] ];
                var days = [ ["Sun", "日曜"],["Mon", "月曜"],["Tue", "火曜"],["Wed", "水曜"],["Thu", "木曜"],["Fri", "金曜"],["Sat", "土曜"] ];
                if(version == "2.0"){
                    date.match(/(\w{3})\,\s(\d{2})\s(\w{3})\s(\d{4})\s(\d{2}:\d{2}:\d{2})/);
                    for(var j=0; j<months.length; j++){
                        var monthKey = months[j][0];
                        var monthText = months[j][1];
                        if(RegExp.$3 == monthKey){ month = monthText }
                    }
                    return RegExp.$4+'年'+month+'月'+RegExp.$2+'日'+'|'+RegExp.$5;
                }
                else{
                    date.split("-").join("").match(/(\d{4})(\d{2})(\d{2})T(\d{2}:\d{2}:\d{2})/);
                    return RegExp.$1+'年'+RegExp.$2+'月'+RegExp.$3+'日'+'|'+RegExp.$4;
                }
            }
            
            // 通常お知らせの中、重要なお知らせに記載されてないものだけを抽出
            function unique(arry) {
                var uniqueArray = [];
                var imp_arry = [];
                $('.list-news-02 li a').each(function(){
                    imp_arry.push( $(this).text() );
                });
                $(arry).each(function(){
                    var result = true;
                    for ( i=0; i<imp_arry.length; i++) {
                        if( this.title == imp_arry[i] ){
                            result = false;
                        }
                    }
                    if(result == true){
                        uniqueArray.push(this);
                    }
                });
                return uniqueArray;
            }
            
            // HTMLの表示
            function showHtml(arry){
                if(arry.length == 0) {
                    return false;
                }
                else if(arry == "error"){
                    switch (settings.type) {
                        case "important":
                            elm.append("");
                            break;
                        case "news":
                            elm.append("");
                            break;
                        default:
                            elm.append("");
                            break;
                    }
                    
                }
                else{
                    var out_html;
                    if (settings.type == "important") {
                        out_html = '<ul class="list-news-02">';
                        $(arry).each(function(i){
                            if(i == settings.limit){
                                return false
                            }
                            else{
                                if(this.link.match(/\.pdf$/)){
                                    out_html += '<li><a href="'+this.link+'" target="_blank" class="link-pdf-01">'+this.title+'<img src="/shared/images/icn_pdf_01.gif" alt="PDF" class="icn" height="13" width="13" /></a></li>';
                                }
                                else if(!this.link.match(/http:\/\/www\.nissay\.co\.jp|http:\/\/kwrvsw3b/)){
                                    out_html += '<li><a href="'+this.link+'" target="_blank" class="link-window-01">'+this.title+'<img src="/shared/images/icn_window_01.gif" alt="新しいウィンドウ" class="icn" height="10" width="12" /></a></li>';
                                }
                                else{
                                    out_html += '<li><a href="'+this.link+'">'+this.title+'</a></li>';
                                }
                            }
                        });
                        out_html += '</ul><!-- /.list-news-02 -->';
                    }
                    else {
                        var merge_arry = unique(arry);
                        out_html = '<table class="tbl-news-01" border="1" cellspacing="0">';
                        out_html += '<tbody>';
                        $(merge_arry).each(function(i){
                            var date;
                            if(this.date){ date = this.date.split("|")[0]; }
                            if(i == settings.limit){
                                return false
                            }
                            else{
                                out_html += '<tr>';
                                (this.date) ? out_html += '<th>'+date+'</th>' : out_html += '<th></th>';
                                if(this.link.match(/\.pdf$/)){
                                    out_html += '<td><div><a href="'+this.link+'" target="_blank" class="link-pdf-01">'+this.title+'<img src="/shared/images/icn_pdf_01.gif" alt="PDF" class="icn" height="13" width="13" /></a></div></td>';
                                }
                                else if(!this.link.match(/http:\/\/www\.nissay\.co\.jp|http:\/\/kwrvsw3b/)){
                                    out_html += '<td><div><a href="'+this.link+'" target="_blank" class="link-window-01">'+this.title+'<img src="/shared/images/icn_window_01.gif" alt="新しいウィンドウ" class="icn" height="10" width="12" /></a></div></td>';
                                }
                                else{
                                    out_html += '<td><div><a href="'+this.link+'">'+this.title+'</a></div></td>';
                                }
                                out_html += '</tr>';
                            }
                        });
                        out_html += '</tbody>';
                        out_html += '</table><!-- /.tbl-news-01 -->';
                    }
                    elm.append(out_html);
                }
            }
        });
    };
})(jQuery);


// ----------------------------------------------------------------------------
// ログイン
// ----------------------------------------------------------------------------

// ご契約者さま専用サービス
function openKojinLoginPage() {
    window.open("https://www.account-k.nissay.co.jp/pkmenu/salsa_open/auth/customer/CustomerHokenLogin.jsp", "policy",
"top=0, left=0, width=1012, height=672, toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes");
}

// 法人インターネットサービス
function openHojinLoginPage() {
    window.open("https://www.account-h.nissay.co.jp/hnkmenu/salsa_open/auth/extra/Login.jsp", "hojinnet", "top=0, left=0, width=1012, height=672, toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes");
}

// アカウントゲート
function openAccountGate() {
    window.open("https://www.account-g.nissay.co.jp/jkmenu/salsa_open/auth/customer/AccountFrameSet.jsp", "JNBLogin", "top=0, left=0, width=1012, height=672, toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes");
}

// 窓販商品ご契約者さま専用サービス

function openMadohanKojinLoginPage() {

    window.open("https://va-dmn2.nissay.co.jp/vktegaku/internet/KB6S011ZUserLoginO1.jsp", "madohan",

"top=0, left=0, width=1012, height=672, toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes");

}


// ----------------------------------------------------------------------------
// 商品一覧のFlash用
// ----------------------------------------------------------------------------
function popup(url) {
    newWin = window.open(url, "newWindow", "menubar=no, width=1000, height=670, scrollbars=yes, toolbar=0, location=no, directories=no, status=no, resizable=yes");
}


// ----------------------------------------------------------------------------
// スマートフォン判別
// ----------------------------------------------------------------------------
function spCheck() {
    return navigator.userAgent.indexOf('iPhone') >= 0 || navigator.userAgent.indexOf('iPod') >= 0 || navigator.userAgent.indexOf('Android') >= 0 && navigator.userAgent.indexOf('Mobile') >= 0 ? true : false;
}


