//ImgBtnクラス
function ImgBtnInternall(imgElm, action, mode) {
  if (!imgElm)
    return;

  this.imgElm = imgElm;
  this.orgsrc = imgElm.src;
  if (typeof (action) == 'string') {
    if (action.indexOf('over') >= 0) {
      this.imgElm.onmouseover = function() {
        this.imgBtnObj.toggle('over');
      };
      this.imgElm.onmouseout = function() {
        this.imgBtnObj.toggle(this.imgBtnObj.LastMode);
      };
    }
    if (action.indexOf('click') >= 0) {
      this.imgElm.org_onclick = this.imgElm.onclick;
      this.imgElm.onclick = function() {
        this.imgBtnObj.toggle('on');
        if (this.org_onclick)
          this.org_onclick();
      };
    }
  }
  this.toggle(mode);
}

ImgBtnInternall.prototype = {
  attach: function(imgElm, type, mode, is_suspended) {
    if (!imgElm.imgBtnObj)
      imgElm.imgBtnObj = new ImgBtnInternall(imgElm, type, mode);
    imgElm.imgBtnObj.IsSuspended = is_suspended;
    imgElm.imgBtnObj.toggle(mode);
    return imgElm.imgBtnObj;
  }, // End of 'attach' method

  toggle: function(mode) {
    if (this.IsSuspended)
      return;

    this.LastMode = this.imgElm.src.replace(/^.*_(off|over|on).*$/, '$1');
    this.imgElm.src = this.imgElm.src.replace(/_(off|over|on)/, '_' + mode);
  } // End of 'toggle' method
} // End of 'ImageButtonIntelnel' class
  var ImgBtn = new ImgBtnInternall();

  var RollOverImgBtn = {
    attachAtMouseOver: function(btn, mode, is_suspended) {
      if (!mode)
        mode = 'off';
      ImgBtn.attach(btn, 'over', mode, is_suspended).toggle('over');
    } // End of 'attachAtMouseOver' method
} //End of 'RollOverImgBtn' class
