/*==================================================
画像ロールオーバー
2009/10/21
yamaguchik

img画像で末尾に_ONがついたものとそうでないものを使用する。（例：a.gif、a_ON.gif）
マウスアウト時に_ONのついてない画像(例：a.gif）
マウスオーバー時に_ONの画像を表示させる(例：a_ON.gif）
==================================================*/
(function(){
    function rollover(){
        var targetClassName = "rolloverImg";
        var suffix = "_ON";

        var overReg = new RegExp("^(.+)(\\.[a-z]+)$");
        var outReg = new RegExp("^(.+)" + suffix + "(\\.[a-z]+)$");

        var preload = new Array();
        var images = document.getElementsByTagName("*");

        for (var i = 0, il = images.length; i < il; i++) {
            var classStr = images[i].getAttribute("class") || images[i].className;
            var classNames = classStr.split(/\s+/);
            for(var j = 0, cl = classNames.length; j < cl; j++){
                if(classNames[j] == targetClassName){

                    //preload
                    preload[i] = new Image();
                    preload[i].src = images[i].getAttribute("src").replace(overReg, "$1" + suffix + "$2");

                    //mouseover
                    images[i].onmouseover = function() {
                        this.src = this.getAttribute("src").replace(overReg, "$1" + suffix + "$2");
                    }

                    //mouseout
                    images[i].onmouseout = function() {
                        this.src = this.getAttribute("src").replace(outReg, "$1$2");
                    }
                }
            }
        }
    }

    function addEvent(elem,event,func){
        if(elem.addEventListener) {
            elem.addEventListener(event, func, false);
        }else if(elem.attachEvent) {
            elem.attachEvent("on" + event, func);
        }
    }
    addEvent(window,"load",rollover);
})();


/*==================================================
【【【jQuery】】】
==================================================*/
$(function(){
/*--------------------------------------------------
テキスト可変ボタン マウスオン時に背景変更
--------------------------------------------------*/
    $('.variableBtn a').hover(
        //onmouseover
        function(){
            $(this).css('backgroundPosition','bottom left');
            $(this).find('span').css('backgroundPosition','bottom right');
        },
        //onmouseout
        function(){
            $(this).css('backgroundPosition','top left');
            $(this).find('span').css('backgroundPosition','top right');
        }
    );
/*--------------------------------------------------
ページトップ
--------------------------------------------------*/
    if (! $.browser.safari){
        $('.pageTopbtn').click(function () {
            $(this).blur();
            $('html,body').animate({ scrollTop: 0 }, 'slow');
            return false;
        });
    };


/*--------------------------------------------------
表のゼブラカラー
--------------------------------------------------*/
    if (5 < ($("table.tbl_list tr").size() )) {
        $("tr:even td").css("backgroundColor","#FFFFFF");
        $("tr:odd td").css("backgroundColor","#f0ffff");
    };

/*--------------------------------------------------
閉じるボタン
2010/08/12
hoshi
--------------------------------------------------*/
    $('#window_close').click(function() {
        close();
        return false;
    });

    $('#window_close2').click(function() {
        close();
        return false;
    });
    
/*--------------------------------------------------
マウスオンで行の色を変える（企業用CSSが必要）
--------------------------------------------------*/
    $('table.tbl_crmBgChng tr').mouseover(function() {
        $(this).addClass('crmBgChng');
    });
    $('table.tbl_crmBgChng tr').mouseout(function() {
        $(this).removeClass('crmBgChng');
    });
    
    $('.box_crmBgChng').mouseover(function() {
        $(this).addClass('crmBgChng');
    });
    $('.box_crmBgChng').mouseout(function() {
        $(this).removeClass('crmBgChng');
    });

/*--------------------------------------------------
アコーディオンtr
--------------------------------------------------*/
    $("dl.accordion dd:not(:first)").hide();
    $("dl.accordion dt span").each(function(i) {
        var elementVal = $(this).parent().next("dd");
        $(this).click(function() {
            elementVal.toggle("normal");
        });
    });



});

