var TkFragmentSiteMap = Class.create();
TkFragmentSiteMap.prototype = {
  initialize: function(assetPath, options) {
    this.assetPath = assetPath;
    this.node = g_navNode_Root;
    this.options = {
      className: 'tkFragmentSiteMap',
      overview: false
    }
    Object.extend(this.options, options || {});
  },

  write: function() {
    document.write('<table class="' + this.options.className + '" cellspacing="0"><tbody>');
    this.writeNode(this.node);
    document.write('</tbody></table>');
  },

  writeNode: function(node) {
    var level = node.m_level;
    if (level == 1 || level == 2 || level == 3 || level == 4) {
      var html = '<tr><td class="level' + (level) + '"><div>';
      if (level > 3) {
        html += '<img class="bullet" src="' + this.assetPath + '/image/bullet/blue.gif" alt="-" />';
      } else if (level > 1) {
        html += '<img class="bullet" src="' + this.assetPath + '/image/bullet/blue.gif" alt="-" />';
        // html += '<img class="arrow" src="' + this.assetPath + '/image/arrow/blue.gif" alt="-" />';
      }
      if (level == 1) {
        html += '<img class="box" src="' + this.assetPath + '/image/box/blue.gif" alt="-" />';
      }
      if (!this.options.overview && level == 1 && 0 < node.m_subNodes.length) {
        html += node.m_label;
      } else {
        html += '<a href="' + node.m_href + '">' + node.m_label + '</a>';
      }
      html += '</div></td></tr>';
      document.write(html);
    }
    for (var i = 0; i < node.m_subNodes.length; i++) {
      this.writeNode(node.m_subNodes[i], node.m_id);
      if (level < 1) {
        document.write('<tr><td>&nbsp;</td></tr>');
      }
    }
  }
}
