//
// ハイヤーご利用ボタン動作管理クラス
//
function Husenavi(hname) {

    var _hspeed = 8;       // 表示切り替え速度
    var _hmaxopacity = 55; // 最大透過

    this.hname = hname;

    this.init = function() {

        var i = 0;

        while (1) {

            var hnavi = document.getElementById(hname + i);

            if (hnavi == null) {
                break;
            }

            this.setEvent(hnavi);

            i++;
        }
    }

    this.setEvent = function(hnavi) {

        // マウスオーバーイベント
        hnavi.onmouseover = function() {

            if (this.opacity == null) {
                this.opacity = 100;
            }

            clearTimeout(this.timerId);

            var obj = this;
            this.timerId = setInterval(
                function(){
                    obj.opacity -= _hspeed;

                    if (obj.opacity < _hmaxopacity) {
                        obj.opacity = _hmaxopacity;
                        clearTimeout(obj.timerId);
                    }

                    obj.style.opacity = obj.opacity / 100;
                    obj.style.MozOpacity = obj.opacity / 100;
                    obj.style.filter = 'alpha(opacity=' + obj.opacity + ')';
                }, 10);
        }

        // マウスアウトイベント
        hnavi.onmouseout = function() {

            if (this.opacity == null) {
                this.opacity = _hmaxopacity;
            }

            clearTimeout(this.timerId);

            var obj = this;
            this.timerId = setInterval(
                function(){
                    obj.opacity += _hspeed;

                    if (100 < obj.opacity) {
                        obj.opacity = 100;
                        clearTimeout(obj.timerId);
                    }

                    obj.style.opacity = obj.opacity / 100;
                    obj.style.MozOpacity = obj.opacity / 100;
                    obj.style.filter = 'alpha(opacity=' + obj.opacity + ')';
                }, 10);
        }
    }
}


