    function MenuItem(name, link, target) {
        this.name = name;
        this.link = link;
        this.target = target;
        this.childCount = 0;
        this.children = new Array();
    }
    
    var currRoot = '';

    function addMenuItem(parent, child) {
        parent.children[parent.childCount++] = child;
    }

    function createHMenu(root) {
        // position: absolute; left: 0; top: 0;
        document.write('<table style="border-collapse: collapse;" width="100%" border="0" cellpadding="0" cellspacing="0"><tr class="h_menuBarItem">');        
        for ( var i=1; i<root.length; i++ )
        {
            if (root[i].childCount > 0) {
                hideMenu = 'hideVMenu(event,\'menu_' + i + '\',\'rt\');';
                showMenu = 'showVMenu(event,\'menu_' + i + '\',this);';
            } else {
                hideMenu = '';
                showMenu = '';
            }
            tg = '';
            if (root[i].target != null && root[i].target != '') {
            	tg = ' target="' + root[i].target + '" ';
            }
            document.write('<td onmouseout="style.background = \'\';' + hideMenu + '" onmouseover="style.background = \'#FFFFFF\';' + showMenu + '" align="left" class="h_menuBarItem">');            
            if (root[i].link.substr(0, 11) == 'javascript:' ) {            	
            	document.write('<a class="h_menuBarItem" href="javascript:void(0)" style="cursor: pointer;" onclick="' + root[i].link.substr(11) + '">' + root[i].name + '</a>');
            } else if (root[i].link != '') {
                document.write('<a ' + tg + ' class="h_menuBarItem" href="' + root[i].link + '">' + root[i].name + '</a>');
            } else {
                document.write(root[i].name);
            }
            document.write('</td>');
        }
        document.write('<td class="h_menuBarFiller">&nbsp;</td>');
        document.write('</tr></table>');
    }

    function createVMenus(root) {
        for ( var i=1; i<root.length; i++ )
        {
            if (root[i].childCount > 0) {
                document.write('<div id="menu_' + i + '" class="menuBar" style="display: none; z-index: 100;"><table class="menuBar" cellpadding="0" cellspacing="0" onmouseover="holdVMenu(\'menu_' + i + '\');" onmouseout="hideVMenu(event,\'menu_' + i + '\',\'sub\');">');
                for ( var j=0; j<root[i].childCount; j++) {
                    document.write('<tr class="menuBarItem"><td onmouseout="style.background = \'\';" onmouseover="style.background = \'#FFFFFF\';" class="menuBarItem">');
                    document.write('<a class="h_menuBarItem" href="' + root[i].children[j].link + '">' + root[i].children[j].name + '</a></td></tr>');
                }
                document.write('</table></div>');
            }
        }
    }

    function createHVMenus(root) {
      createHMenu(root);
      createVMenus(root);
    }

    function showVMenu(e, menuname, ref) {    	
    	if (window.event) e = window.event; 
    	var srcEl = e.srcElement? e.srcElement : e.target; 
    	    	    	
    	if (srcEl.tagName == 'TD') {
    		currRoot = menuname;    		
    	} 
    	   
        var pos = findPos(ref);
        var m = document.getElementById(menuname);

        var left = (pos[0] + 0)+ 'px';
        var top  = (pos[1] + ref.offsetHeight - 2) + 'px';
        
        m.style.left = left;
        m.style.top  = top;
        m.style.display = '';        
    }

    function hideVMenu(e,menuname, source) {
    	if (window.event) e = window.event; 
    	var srcEl = e.srcElement? e.srcElement : e.target; 
    	
    	if (source == 'sub' && srcEl.tagName == 'div') {
    		setTimeout('hideNow(\'' + menuname + '\')', 200);    		
    	} else if (source = 'rt') {    		    	
    		currRoot = '';
    		setTimeout('hideNow(\'' + menuname + '\')', 200);    		
    	}	
    }
    
    function hideNow(menuname) {
    	if (currRoot != menuname) {    	  
	      document.getElementById(menuname).style.display = 'none';
		  currRoot = '';
    	}
    }

    function holdVMenu(menuname) {
    	currRoot = menuname;
        document.getElementById(menuname).style.display = '';
    }
    

