/*
 * TagDisplayクラス
 *
 *--------------------------------------------------------------------- */
var TagDisplay = Class.create();

/*
 * Singleton
 */
TagDisplay.instance = null;

TagDisplay.getInstance = function() {
  var instance = TagDisplay.instance;

  if (instance == null) {
    instance = TagDisplay.instance = new TagDisplay();
  }

  return instance;
}

TagDisplay.prototype = {

  /*
   * Instance properties
   *
   *--------------------------------------------------------------------- */
  tag: null,

  /*
   * Constructor
   *
   *--------------------------------------------------------------------- */
  initialize: function() {
  },

  /**
   * showPlain
   *
   */
  showPlain: function(tag) {

    /*
     * 処理に必要な要素を取得する。
     */
    var plainTagDisplay = $('plain_tag_display');

    /*
     * タグの情報で内容を書き換え, 簡易タグディスプレイを表示する。
     */
    plainTagDisplay.innerHTML = tag.getTagName() + '<br /><br />' + tag.getComment();

    /*
     * 処理対象タグを保持する。
     */
    this.tag = tag;

  },

  /**
   * hidePlain
   *
   */
  hidePlain: function() {
    $('plain_tag_display').style.display = 'none';
  },

  /**
   * locatePlain
   *
   */
  locatePlain: function(x, y) {

    var plainTagDisplay = $('plain_tag_display');
    var offset = Position.cumulativeOffset($('progress'));
    var left = x - offset[0] + 5;
    var top = y - offset[1] - 5 - plainTagDisplay.getHeight();

    plainTagDisplay.setStyle({left: left + 'px', top: top + 'px', display: 'block'});

  },

  /*
   * getTag
   *
   *--------------------------------------------------------------------- */
  getTag: function() {
    return this.tag;
  }

};

