        var menuItems = new Array;

        var bCloseMenu = false;
		var bCanClose = true;
		var activeMenuId = -1;
		var newId = -1;
		var oldId = -1;
		var menuCloseTime = 2000; //ms
        
        
        function addMenuItem() {
        
        }
        
        function buildMenu() {
            sOutput = "";
            for (i=0;i<menuRoot.length;i++) {
                sOutput += '<span id="menu' + i + '_0" style="position: absolute; top: ' + menuRoot[i]['top'] + '; left: ' + menuRoot[i]['left'] + '; visibility: hidden;">\n';
                sOutput += '<table width="' + menuRoot[i]['width'] + '" border="0" cellspacing="0" cellpadding="0" align="left" class="submenu">\n';
                for (j=0;j<menuRoot[i]['items'].length;j++) {
                    sOutput += '<tr>\n';
                    sOutput += '	<td id="menu' + i + '_0_' + j + '" width="' + menuRoot[i]['width'] + '" class="submenuOff" onMouseOver="submenuOver(this.id);" onMouseOut="submenuOut(this.id);">\n';
                    sOutput += '		<table width="' + menuRoot[i]['width'] + '" cellspacing="0" cellpadding="0" align="left">\n';
                    sOutput += '		<tr>\n';
                    sOutput += '			<td id="menu' + i + '_0_' + j + '" align="left" onMouseOver="submenuOver(this.id);" onMouseOut="submenuOut(this.id);" onclick="loadPage(\'' + menuRoot[i]['items'][j]['linkPage'] + '\')"><span id="text' + i + '_0_' + j + '" class="submenuTextOff">' + menuRoot[i]['items'][j]['name'] + '</span></td>\n';
                    sOutput += '		</tr>\n';
                    sOutput += '		</table>\n';
                    sOutput += '	</td>\n';
                    sOutput += '</tr>\n';
                }
                sOutput += '</table>\n';
                sOutput += '</span>\n';
            }
          //  alert(sOutput);
            document.write(sOutput);
        }
     
      function hideMenu() {
		    if ((!bCloseMenu) && (bCanClose)) {
                bCloseMenu = true;                            
                setTimeout('hideMenu()', menuCloseTime);
            } else {
                if ((activeMenuId > -1) && (bCanClose)) {
				    //for (j=0;j<menuRoot[activeMenuId].length;j++) {
                        document.getElementById('menu'+activeMenuId+'_0').style.visibility = "hidden";
                    //}  
                    iActiveMenu = -1;
			//alert(oldId);
			if (newId != -1) {
			document.getElementById(newId).className = "menuOff";	
			}
                }                      
                bCloseMenu = false; 
            }
        }

		function menuOver(id) {
            oldId = newId;
			if (eval(document.getElementById(id+'_0'))) {
				document.getElementById(id+'_0').style.left = findPosX(id)+'px';
                document.getElementById(id+'_0').style.top = (findPosY(id)+21)+'px';				
                //alert(document.getElementById(id+'_0').style.left);
                //document.getElementById(id+'_0').style.top = findPosY(id)+'px';                
            }
			document.getElementById(id).className = "menuOn";	
			
			if ((oldId != -1) && (oldId != id)) {
			document.getElementById(oldId).className = "menuOff";	
			}
            if ((activeMenuId != id.substring(4, id.length)) && (activeMenuId > -1))  {
				NextSubmenu('menu'+activeMenuId);
			}  			
			newId = id;
		 	bCanClose=false;
			hideMenu();
		}

		function menuOut(id) {
			bCanClose=true;		
		}

		function loadSubmenu(id) {
			bCanClose=false;
			if ((activeMenuId != id.substring(4, id.length)) && (activeMenuId > -1))  {
				NextSubmenu('menu'+activeMenuId);
			}  			  
			document.getElementById(id+'_0').style.visibility = "visible";
	 	  	activeMenuId = id.substring(4, id.length);
		}
		
		function NextSubmenu(id) {
			document.getElementById(id+'_0').style.visibility = "hidden";
		}

		function unloadSubmenu(id) {
			hideMenu();
		}

		function submenuOver(id) {
			bCanClose=false;
			document.getElementById(id).className = "submenuOn";
            textId = id.substring(4, id.length);
            document.getElementById("text"+textId).className = "submenuTextOn";
			
		}
		
		function submenuOut(id) {
			document.getElementById(id).className = "submenuOff";		
            textId = id.substring(4, id.length);
            document.getElementById("text"+textId).className = "submenuTextOff";
			bCanClose=true;		
		}

//        function findPosX(obj) {
//            var curleft = 0;
//            if (document.getElementById(obj).offsetParent) {
//                while (document.getElementById(obj).offsetParent) {
//                    curleft += document.getElementById(obj).offsetLeft
//                    obj = document.getElementById(obj).offsetParent;
//                }
//            } else if (document.getElementById(obj).x)
//            curleft += document.getElementById(obj).x;
//            return curleft;
//        }
	    function findPosX(objectId) {
			o = document.getElementById(objectId)
			oTop = o.offsetLeft            
			while(o.offsetParent!=null) { 
				oParent = o.offsetParent  
				oTop += oParent.offsetLeft
				o = oParent
			}
			// Return left position
			//document.getElementById("onlineHelp").style.top = oTop+10;
			return oTop
		}	
        
	    function findPosY(objectId) {
			o = document.getElementById(objectId)
			oTop = o.offsetTop            
			while(o.offsetParent!=null) { 
				oParent = o.offsetParent  
				oTop += oParent.offsetTop
				o = oParent
			}
			// Return top position
			//document.getElementById("onlineHelp").style.top = oTop+10;
			return oTop
		}	
        //function findPosY(obj) {
        //    var curtop = 0;
        //    if (document.getElementById(obj).offsetParent) {
        //        while (document.getElementById(obj).offsetParent) {
        //            curtop += document.getElementById(obj).offsetTop
        //            document.getElementById(obj) = document.getElementById(obj).offsetParent;
        //        }
        //    } else if (document.getElementById(obj).y)
        //    curtop += document.getElementById(obj).y;
        //    return curtop;
       // }

		function loadPage(vurl) {
			document.location = vurl;
		}	
