
function addArrayElement(elem) {
  this[this.length]=elem;
};

document.reposition = reposition;
document.reposition.list=[];
document.reposition.list.add=addArrayElement;

function init() {};
function reposition() {};

document.init = init;
document.init.list=[];
document.init.list.add=addArrayElement;

window.onresize=document.reposition;
window.onload=document.init;

// TABLE BASED LEFT MENUS

  var agt=navigator.userAgent.toLowerCase();
  var is_gecko = (agt.indexOf('gecko') != -1);

	function repositionLeftMenu() {
		var hook = getAbsPos(document.getElementById('menuhook'));
		var leftmenu = document.getElementById('leftmenu');

		leftmenu.style.top = hook.y; 
	};
  
  function tiMenu() {
    this.tiMenuMakeItem = tiMenuMakeItem;
    this.tiMenuFinish = tiMenuFinish;
    this.clev = 0;
    this.fld = 0;
    this.index = new Array();
    document.write('<table border="0" id="leftmenu">');

		document.init.list.add(repositionLeftMenu);
		document.reposition.list.add(repositionLeftMenu);
  };
  
  function tiMenuSetFolder(id,open) {
    var fld = document.getElementById('fld'+id);
    if (open) {
      if (is_gecko) 
        fld.style.display='table-row-group';
      else
        fld.style.display='block';
      document.images['tg'+id].src = 'pics/icnopen1.gif';
      document.images['tg'+id].alt = '-';
    } else {
      fld.style.display='none';
      document.images['tg'+id].src = 'pics/icnclosed1.gif';
      document.images['tg'+id].alt = '+';
    };
  };
  
  function tiMenuCloseSiblings(id) {
    var prt = document.getElementById('fld'+id).parentNode, fldName;
    
    for (var i=0; i<prt.childNodes.length; i++) {
      if (prt.childNodes[i].tagName=='TBODY') {
        fldName = prt.childNodes[i].id;
        if (fldName.substr(0,3)=='fld') {
          tiMenuSetFolder(parseInt(fldName.substring(3)),0);
        };
      };
    };
  };
  
  function tiMenuToggle(id) {
    var fld = document.getElementById('fld'+id);
    if (fld.style.display=='none') {
      tiMenuCloseSiblings(id);
      tiMenuSetFolder(id,1);
    } else {
      tiMenuSetFolder(id,0);
    };
  };
  
  function tiMenuFinish() {
    for (i=0; i<this.clev; i++) document.write('<\/TABLE><\/TD><\/TR><\/TBODY>\r\n');
    document.write('<\/TABLE>')
  };
  
 function tiMenuMakeItem(level,folder,txt,href,open,hl,t) {
    var i;
    
    if (level >= this.index.length) this.index[this.index.length] = 0;

    this.index[level]++;
    this.fld++;
    
    if (level<this.clev) {
      for (i=level; i<this.clev; i++) document.write('<\/TABLE><\/TD><\/TR><\/TBODY>\r\n');
    };
    
    if (folder) {
      document.write('<TR>')
      if (level>0) {
				document.write('<TD width="11"><a href="javascript:tiMenuToggle(' + this.fld + ')">');
				document.write('<img name="tg' + this.fld + '" src="pics/icn' + ((open) ? 'open' : 'closed') + '1.gif" border="0" width="9" height="9" alt="' + ((open) ? '-' : '+') + '"><\/a><\/TD>');
			};
      document.write('<TD width="100%" class=menu_folder>');
    } else {
      document.write('<TR><TD></TD><TD>');
    };
    document.write('<a href="' + href + t + '">' + txt + '<\/a>');
    document.write('<\/TD><\/TR>');
    if (folder) {
      document.write('<TBODY id="fld' + this.fld + '"' + ((!open) ? ' style="display:none"' : '') + '><TR>');
      
      if (level>0) {
        document.write('<TD width="11"><img src="pics/blank.gif" border="0" width="11" height="9"><\/TD>');
      } else {
      };
      document.write('<TD width="100%"><TABLE width="100%" border="0">');
    };
    this.clev=level;
  };

