//menu

//browser sniffer
var browserName=navigator.appName; 
var isNav = (navigator.appName.indexOf("Netscape")>=0);
var IE = document.all?true:false

//globals
var tableWidth = 0;
var currentMenuShowingID;
var nextMenuSelectedID;
var currentFlyoutMenuShowingID;
var cancelHideSubMenu = true; //cancel sub menu hide if mouseover sub
var cancelHideFlyoutMenu = true;
var subMenuShowing = false;
var flyoutMenuShowing = false;
var currentRowMousedOver = null;
var previousRowMousedOver = null;
var mousedOffTable = false;
var timeoutInterval = 1000;
var menuActive;
var mainActivatedFontColor;
var mainActivatedBGColor;
var mainDeactivatedLinkNonActiveFontColor;
var mainDeactivatedLinkActiveFontColor;
var subTableWidth;
var subTableOffsetX;
var subTableOffsetY;
var mainBGColor;
var arrSubTableWidth = new Array();

//************************************************************************************************************
var linkArray0 = new Array("traffic.aspx", "listview.aspx?typeID=1", "https://www.dot.ny.gov/portal/page/portal/transportation-partners/nys-transportation-federation/travel-info-ny/winter-travel-advisory");
var linkArray1 = new Array("transit.aspx", "listview.aspx?typeID=2");
var linkArray2 = new Array("#", "tripplanner/default.aspx");

//var linkArray3 = new Array("ridesharesub.aspx?catID=0", 
//                           "ridesharesub.aspx?catID=1", 
//                           "ridesharesub.aspx?catID=2", 
//                           "ridesharesub.aspx?catID=3", 
//                           "ridesharesub.aspx?catID=4", 
//                           "ridesharesub.aspx?catID=5");
var linkArray3 = new Array("commuters.aspx", 
                           "employers.aspx");
                           
//var linkArray4 = new Array("travellinkssub.aspx?catID=6", 
//                           "travellinkssub.aspx?catID=7", 
//                           "travellinkssub.aspx?catID=8", 
//                           "travellinkssub.aspx?catID=9", 
//                           "travellinkssub.aspx?catID=10", 
//                           "travellinkssub.aspx?catID=11", 
//                           "travellinkssub.aspx?catID=12", 
//                           "travellinkssub.aspx?catID=13", 
//                           "travellinkssub.aspx?catID=14", 
//                           "travellinkssub.aspx?catID=15");
var linkArray4 = new Array("travellinks.aspx#airports", 
                           "automobile.aspx", 
                           "travellinks.aspx#bicycling", 
                           "travellinks.aspx#clean", 
                           "mobile.aspx", 
                           "travellinks.aspx#tourism", 
                           "travellinks.aspx#emergency", 
                           "commercialvehicles.aspx", 
                           "intermodal.aspx", 
                           "travellinks.aspx#ports", 
                           "travellinks.aspx#public", 
                           "travellinks.aspx#transportation",
                           "developer.aspx");

var flyArray0 = new Array("eventList.aspx?type=inc&amp;listType=active&amp;mode=traffic", 
                          "eventList.aspx?type=const&amp;listType=active&amp;mode=traffic", 
                          "eventList.aspx?type=specevt&amp;listType=active&amp;mode=traffic", 
                          "eventList.aspx?type=const&amp;listType=future&amp;mode=traffic", 
                          "eventList.aspx?type=specevt&amp;listType=future&amp;mode=traffic", 
                          "eventList.aspx?type=all&amp;listType=active&amp;mode=traffic")
                          
var flyArray1 = new Array("eventList.aspx?type=inc&amp;listType=active&amp;mode=transit", 
                          "eventList.aspx?type=const&amp;listType=active&amp;mode=transit",
                          "eventList.aspx?type=specevt&amp;listType=active&amp;mode=transit",
                          "eventList.aspx?type=const&amp;listType=future&amp;mode=transit",
                          "eventList.aspx?type=specevt&amp;listType=future&amp;mode=transit",
                          "eventList.aspx?type=all&amp;listType=active&amp;mode=transit")

var mainMenuArray = new Array("traffic.aspx", "transit.aspx", "tripplanner/default.aspx", "rideshare.aspx", "travellinks.aspx");

var flyOutArray0 = new Array("", "", "", "0");
var flyOutArray1 = new Array("", "", "1");

var flyItemCount = 6;   

var linkSel = "";
//*************************************************************************************************************


//set up parameters in case XML load fails
mainActivatedFontColor = "#006699";
mainActivatedBGColor = "#FFFFFF";
mainDeactivatedLinkNonActiveFontColor = "#FFFFFF";
mainDeactivatedLinkActiveFontColor = "#FFFFFF";
subMenuActivatedFontColor = "#006699";
subMenuDeactivatedFontColor = "#4192BB";
mainBGColor = "#006699";
subTableWidth = 174;

subTableOffsetX = -1;   //distance of sub table from the right of the main table
subTableOffsetY = 20;   //distance of sub table from the top of the main table row

// **************************** Keyboard Menu functions ***************************************************************
var token;

function onUnloaded(menuID, sender, keyEventArgs)
{            
    onDetach(sender, function(keyEventArgs) {      
    
     });
}

function onLoaded(j, s, menuID, itemCount, sender, keyEventArgs)
{         
    //var s = 0; 
    //var j = 0;
    var linkID = 0;    
    var id = '';
    var id2 = '';
    var flyID = "";
    var sender1;
    var sender2; 
    var senderFly;     
    var flag = 0;       
    var eofDown = 0;  
    var eofDownSub = 0; 
    var arrowR = 0;        
    var first = false;

    if (itemCount != 0) {
    
        var rgbActiveColor = "rgb(0, 102, 153)";


        activateMainMenu('Row' + menuID);

        onEvent(sender, function(keyEventArgs) {

            if (keyEventArgs.keyCode == 9)     // TAB key
            {
                j = 0;  // for main menu
                s = 0;  // for sub menu               
            }

            if (keyEventArgs.keyCode == 40)    // arrow DOWN
            {
                var menuDown;
                var menuSenderDown;
                var mainDown = false;


                if (menuID == 0 || menuID == 1) {
                    for (i = 0; i < itemCount; i++) {
                        menuDown = 'td' + menuID + 'Row' + i;
                        menuSenderDown = document.getElementById(menuDown);

                        if (menuSenderDown.style.color == subMenuActivatedFontColor) {
                            if (first == true)
                                mainDown = true;
                        }
                    }
                    first = true;
                }

                if (flag != 1 && mainDown == true && j <= itemCount - 1)
                    j = j + 1;


                if (arrowR == 0) {
                    if (menuID == 0 && j == 3) {
                        showFlyoutMenu(menuID, j, flyOutArray0[3])
                        clearFlyMenu();
                    }
                    else if (menuID == 1 && j == 2) {
                        showFlyoutMenu(menuID, j, flyOutArray1[2])
                        clearFlyMenu();
                    }
                    else {
                        clearFlyMenu();
                        cancelHideFlyoutMenu = false;
                        hideFlyoutMenu();
                    }
                }

                var menuFlyDown;
                var menuFlySenderDown;
                var FlyDown = false;

                if (menuID == 0 || menuID == 1) {
                    if (flyoutMenuShowing == true) {
                        for (i = 0; i < flyItemCount; i++) {
                            menuFlyDown = 'flyOut' + menuID + 'Item' + i;
                            menuFlySenderDown = document.getElementById(menuFlyDown);

                            if (menuFlySenderDown.style.color.search("rgb") != -1) {
                                if (menuFlySenderDown.style.color == rgbActiveColor)
                                    FlyDown = true;
                            }

                            if (menuFlySenderDown.style.color == subMenuActivatedFontColor)
                                FlyDown = true;

                        }
                    }
                }

                if (flag != 1 && FlyDown == true && s <= flyItemCount - 1)
                    s = s + 1;

                if (FlyDown == false) {
                    for (i = 0; i < itemCount; i++) {

                        id2 = 'td' + menuID + 'Row' + i;

                        sender2 = document.getElementById(id2);

                        if (sender2 != null)
                            menuTDOut(sender2);
                    }
                }
                else {
                    for (i = 0; i < flyItemCount; i++) {

                        id2 = 'flyOut' + menuID + 'Item' + i;

                        sender2 = document.getElementById(id2);

                        if (sender2 != null)
                            menuTDOut(sender2);
                    }
                }


                if (FlyDown == false)
                    id = 'td' + menuID + 'Row' + j;
                else
                    id = 'flyOut' + menuID + 'Item' + s;


                sender1 = document.getElementById(id);

                if (sender1 != null)
                    highlightMenuTD(sender1);


                if (FlyDown == false)
                    linkID = j;
                else
                    linkID = s;


                if (FlyDown == false) {
                    if (j < itemCount - 1) {
                        j = j + 1;
                        eofDown = 0;
                    }
                    else
                        eofDown = 1;
                }
                else {
                    if (s < flyItemCount - 1) {
                        s = s + 1;
                        eofDownSub = 0;
                    }
                    else
                        eofDownSub = 1;
                }


                flag = 1;
            }

            if (keyEventArgs.keyCode == 39)    // arrow RIGHT
            {
                if (menuID == 0 && j == 3 || menuID == 1 && j == 2) {
                    if (flyoutMenuShowing == true) {
                        flag = 0;
                        eofDown = 0;
                        eofDownSub = 0;
                        linkID = 0;

                        arrowR = 1;

                        clearFlyMenu();

                        flyID = 'flyOut' + menuID + 'Item0';
                        senderFly = document.getElementById(flyID);

                        highlightMenuTD(senderFly);
                    }
                }
            }

            if (keyEventArgs.keyCode == 38)    // arrow UP
            {
                var menuFly;
                var menuSender;
                var flyUp = false;

                if (menuID == 0 || menuID == 1) {
                    for (i = 0; i < flyItemCount; i++) {
                        menuFly = 'flyOut' + menuID + 'Item' + i;
                        menuSender = document.getElementById(menuFly);

                        if (menuSender.style.color.search("rgb") != -1) {
                            if (menuSender.style.color == rgbActiveColor)
                                flyUp = true;
                        }

                        if (menuSender.style.color == subMenuActivatedFontColor)
                            flyUp = true;
                    }
                }

                //document.getElementById("TextBox10").value = j;  

                if (flyUp == false) {
                    if (flag != 2 && j > 0 && eofDown == 0)
                        j = j - 1;

                    if (j > 0)
                        j = j - 1;
                }
                else {
                    if (flag != 2 && s > 0 && eofDownSub == 0)
                        s = s - 1;

                    if (s > 0)
                        s = s - 1;
                }

                if (flyUp == false) {
                    if (menuID == 0 && j == 3) {
                        showFlyoutMenu(menuID, j, flyOutArray0[3])
                    }
                    else if (menuID == 1 && j == 2) {
                        showFlyoutMenu(menuID, j, flyOutArray1[2])
                    }
                    else {
                        cancelHideFlyoutMenu = false;
                        hideFlyoutMenu();
                    }
                }

                if (flyUp == false) {
                    for (i = 0; i < itemCount; i++) {
                        id2 = 'td' + menuID + 'Row' + i;

                        sender2 = document.getElementById(id2);

                        if (sender2 != null)
                            menuTDOut(sender2);
                    }
                }
                else {
                    for (i = 0; i < flyItemCount; i++) {
                        id2 = 'flyOut' + menuID + 'Item' + i;

                        sender2 = document.getElementById(id2);

                        if (sender2 != null)
                            menuTDOut(sender2);
                    }
                }

                if (flyUp == false)
                    id = 'td' + menuID + 'Row' + j;
                else
                    id = 'flyOut' + menuID + 'Item' + s;


                sender1 = document.getElementById(id);

                if (sender1 != null)
                    highlightMenuTD(sender1);

                if (flyUp == false)
                    linkID = j;
                else
                    linkID = s;


                flag = 2;
            }
            else if (keyEventArgs.keyCode == 13) // ENTER key
            {
                if (browserName.search("Explorer") == -1) {
                    focus();

                    forFireFox(flag, arrowR, menuID, linkID);

                }
                else {
                    focus();
                    //setTimeout(function() { sender1.focus();} , 100);              

                    if (flag == 0 && arrowR == 0)
                        location.href = mainMenuArray[menuID];
                    else {
                        if (arrowR == 0) {
                            switch (menuID) {
                                case "0": location.href = linkArray0[linkID]; break;
                                case "1": location.href = linkArray1[linkID]; break;
                                case "2": location.href = linkArray2[linkID]; break;
                                case "3": location.href = linkArray3[linkID]; break;
                                case "4": location.href = linkArray4[linkID]; break;
                                //default: result = 'unknown'; 
                            }
                        }
                        else {
                            switch (menuID) {
                                case "0": location.href = flyArray0[linkID]; break;
                                case "1": location.href = flyArray1[linkID]; break;
                            }
                        }
                    }
                    location.target = '_parent';
                }
            }
            else {
                //onDetach(sender, 'onKeyDown', function(keyEventArgs) {})
            }

        });
    }
}  

function dispPageInFireFox(link, parent)
{
    //alert(linkSel);
    if (linkSel == "")
    {
        location.href = link;  
        location.target = parent;
    }
}

function forFireFox(flag, arrowR, menuID, linkID)
{
                                
if (flag == 0 && arrowR == 0)
    {
        location.href = mainMenuArray[menuID];
        linkSel = mainMenuArray[menuID];
    }
else
{   
    //linkSel = "";
    
    if (arrowR == 0)
    {      
        switch (menuID) {
        case "0": location.href = linkArray0[linkID]; linkSel = linkArray0[linkID]; break;
        case "1": location.href = linkArray1[linkID]; linkSel = linkArray1[linkID]; break;
        case "2": location.href = linkArray2[linkID]; linkSel = linkArray2[linkID]; break;
        case "3": location.href = linkArray3[linkID]; linkSel = linkArray3[linkID]; break;
        case "4": location.href = linkArray4[linkID]; linkSel = linkArray4[linkID]; break;        
        }     
    }
    else{                
        switch (menuID) {
        case "0": location.href = flyArray0[linkID]; linkSel = flyArray0[linkID]; break;
        case "1": location.href = flyArray1[linkID]; linkSel = flyArray1[linkID]; break;                
        }   
    }  
}

location.target = '_parent';  
}

function clearMenu(menuID, itemCount)
{    
    var id;
    var sender;
    if (itemCount != 0) {
    
        for (var i = 0; i < itemCount; i++) {
            id = 'td' + menuID + 'Row' + i;
            sender = document.getElementById(id);
            menuTDOut(sender);
        }    
    
    }
    
             
}

function clearFlyMenu()
{   
    var id;
    var sender;
    
    for (var i = 0; i < 2; i++)
    {
        for (var j = 0; j < flyItemCount; j++)
        {
          id = 'flyOut' + i + 'Item' + j;
          sender = document.getElementById(id);
          menuTDOut(sender);
        }     
    }         
}

function onEvent(sender, fn)
{
    sender=document.getElementById(sender);
    // Set the root Canvas object to a KeyDown event-handler function.
    //token = document.addEventListener("onkeydown", fn);
    if (sender.attachEvent)   
        token = sender.attachEvent("onkeydown", fn);      
    else       
        token = sender.addEventListener("keydown", fn, false);        
         
}

function onDetach(sender, fn)
{
    sender=document.getElementById(sender);
    // Set the root Canvas object to a KeyDown event-handler function.   
    if (sender.attachEvent)   
        token = sender.detachEvent("onkeydown", fn);  
    else
        token = sender.removeEventListener("keydown", fn, false);
               
}

//function RGBtoHEX(rgb)
//{
//    var char = "0123456789ABCDEF";
//    
//    return String(char.charAt(Math.floor(rgb/16))) + String(char.charAt(rgb - (Math.floor(rgb/16)*16)));
//    
//}

//function pausecomp(millis) 
//{
//var date = new Date();
//var curDate = null;

//do { curDate = new Date(); } 
//while(curDate-date < millis);
//} 
// **************************************************************************************************************


function loadMenuProperties(){ 

    //customization
    var i = 0;
            
    try {
        initializeXmlHttp();
    
        //using async set to false - now code is synchronous 
        xmlhttp.open("GET", "./menu/menu.xml", true);
    
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4){
                var xmlDoc = xmlhttp.responseXML;
                
                if (xmlDoc != null)
                {
                    var elem = xmlDoc.getElementsByTagName("MenuAttributes");
    			
			        if (elem.length > 0) {
				        mainActivatedFontColor = xmlDoc.getElementsByTagName("mainActivatedFontColor")[0].firstChild.nodeValue;
                        mainDeactivatedLinkNonActiveFontColor = xmlDoc.getElementsByTagName("mainDeactivatedLinkNonActiveFontColor")[0].firstChild.nodeValue;
                        mainActivatedBGColor = xmlDoc.getElementsByTagName("mainActivatedBGColor")[0].firstChild.nodeValue;
                        mainActivatedFontColor = xmlDoc.getElementsByTagName("mainActivatedFontColor")[0].firstChild.nodeValue;
                        subTableWidth = parseInt(xmlDoc.getElementsByTagName("subTableWidth")[0].firstChild.nodeValue);
                        subTableOffsetX = parseInt(xmlDoc.getElementsByTagName("subTableOffsetX")[0].firstChild.nodeValue);
                        subTableOffsetY = parseInt(xmlDoc.getElementsByTagName("subTableOffsetY")[0].firstChild.nodeValue);
                        subMenuActivatedFontColor = xmlDoc.getElementsByTagName("subMenuActivatedFontColor")[0].firstChild.nodeValue;
                        subMenuDeactivatedFontColor = xmlDoc.getElementsByTagName("subMenuDeactivatedFontColor")[0].firstChild.nodeValue;
                        mainBGColor = xmlDoc.getElementsByTagName("mainBGColor")[0].firstChild.nodeValue;
                    }
                    
                    elem = null;
                    
                    //read in the width of each menu defined in the menu.xml doc.
                    elem = xmlDoc.getElementsByTagName("MainMenuItem");
                    
                    for (i = 0; i < elem.length; i++){
                        arrSubTableWidth[i] = elem.item(i).getAttribute("width");
                    }
                }
            }//end if xmlhttp.readystate = 4
        }
        
        xmlhttp.send(null);
    }
    catch (e){}
}

function showSubMenu(iRowID, iMainMenuID) {

    var mainMenuLink;

    // Do not show the submenu for the 'MY511NY' link
    if (iMainMenuID != 5) {

        //no subMenu available
        if (parseInt(iRowID) == -1) {
            if ((currentMenuShowingID != null) && (currentMenuShowingID != iMainMenuID)) {
                cancelHideSubMenu = false;
                hideSubMenu('newRowActivated');
            }
            currentMenuShowingID = iMainMenuID;

            var hideDivFrame = new getObj("hideDivFrame");
            hideDivFrame.obj.style.display = "none";
            return false;
        }

        var subMenuSelected = new getObj("subMenu" + iRowID);
        var mainMenuRow = new getObj("Row" + iRowID);
        mainMenuLink = new getObj("Row" + iRowID + "Link");
        var subTableSelected = new getObj("subTable" + iRowID);

        cancelHideSubMenu = true;

        //position submenu that's been selected
        positionSubMenu(subMenuSelected, iRowID);

        //close existing menu if one is opened
        if ((currentMenuShowingID != null) && (currentMenuShowingID != iRowID)) {
            cancelHideSubMenu = false;
            hideSubMenu('newRowActivated');
        }
        //display the sub menu
        subTableSelected.obj.style.width = subTableWidth + "px";

        //subTableSelected.obj.style.width = parseInt(arrSubTableWidth[iRowID]) + 2 + "px";
        subMenuSelected.obj.style.display = "block";

        //let js know a submenu is currently displayed
        subMenuShowing = true;

        //slowly fade in the menu        
        //fadeSubMenu(0, iRowID);

        var hideDivFrame = new getObj("hideDivFrame");
        hideDivFrame.obj.style.width = subTableWidth;
        //hideDivFrame.obj.style.width = arrSubTableWidth[iRowID];
        hideDivFrame.obj.style.left = subMenuSelected.style.left;
        hideDivFrame.obj.style.top = subMenuSelected.style.top;

        //if height exists, use the height of the submenu. otherwise, hardcode to a size that should cover all boxes.
        if (parseInt(subMenuSelected.obj.clientHeight) > 0) {
            hideDivFrame.obj.style.height = subMenuSelected.obj.clientHeight + "px";
        }
        else {
            hideDivFrame.obj.style.height = "130px";
        }

        hideDivFrame.obj.style.display = "block";

        currentMenuShowingID = iRowID;
    }
	
}


function showFlyoutMenu(iSubMenuID, iRowID, iFlyoutID) {
    
    //close existing menu if one is opened
	if ((currentFlyoutMenuShowingID != null) && (iFlyoutID != currentFlyoutMenuShowingID)) {
		cancelHideFlyoutMenu = false;
		hideFlyoutMenu();
	}
	  
	if (iFlyoutID == "") {
	    return false;
	}  
	
    var flyoutMenuSelected = new getObj("flyoutMenu"+iFlyoutID);
	var subMenuRow = new getObj("subMenu"+iSubMenuID+"Row"+iRowID);
    var flyoutTableSelected = new getObj("flyoutTable" + iFlyoutID);
     
    cancelHideFlyoutMenu = true;
    cancelHideSubMenu = true;

	//position submenu that's been selected
	positionFlyoutMenu(flyoutMenuSelected, iRowID, iSubMenuID, iFlyoutID);
	 
	flyoutMenuSelected.obj.style.width = subTableWidth + "px";
	flyoutTableSelected.obj.style.width = subTableWidth + "px";
	flyoutMenuSelected.obj.style.display = "block";
	
	//let js know a submenu is currently displayed
	flyoutMenuShowing = true;
	
	var hideFlyoutDivFrame = new getObj("hideFlyoutDivFrame");
	//hideDivFrame.obj.style.width = subTableWidth;
	hideFlyoutDivFrame.obj.style.width = subTableWidth + "px";
	hideFlyoutDivFrame.obj.style.left = flyoutMenuSelected.style.left;
	hideFlyoutDivFrame.obj.style.top = flyoutMenuSelected.style.top;
	
	//if height exists, use the height of the submenu. otherwise, hardcode to a size that should cover all boxes.
	if (parseInt(flyoutMenuSelected.obj.clientHeight) > 0) {
	    hideFlyoutDivFrame.obj.style.height = flyoutMenuSelected.obj.clientHeight + "px";
	}
	else {
	    hideFlyoutDivFrame.obj.style.height = "130px";
	}
	
	hideFlyoutDivFrame.obj.style.display = "block";
	currentFlyoutMenuShowingID = iFlyoutID;
	
}

function callHideSubMenu() {
	//if sub menu is showing, wait 3 seconds to hide menu
	//otherwise deactivate row properties and sidebar properties
	//right away
	//this is done so that when user mouses off of table, we deactivate
	//the sidebar properties. Otherwise, if a submenu is showing, we wait
	//a few seconds to deactivate
	
	if (subMenuShowing) {
	    setTimeout('hideSubMenu()',timeoutInterval);
	}
	else {
	    hideSubMenu();
	}	
}

function hideSubMenu(deactivateType) {
    
    if (flyoutMenuShowing) {
	    hideFlyoutMenu();
	}
	
    if (currentMenuShowingID != undefined) {
        
        var mainMenuLink = new getObj("Row" + currentMenuShowingID + "Link");
		var mainMenuRow = new getObj("Row"+currentMenuShowingID);
		
		if (!cancelHideSubMenu) {
		    
		    //added 5/20/08 to handle IE div bug
	        var hideDivFrame = new getObj("hideDivFrame");
	        hideDivFrame.obj.style.display = "none";
	        
		    if (document.getElementById('subMenu'+currentMenuShowingID)) {
		        var subMenuToHide = new getObj('subMenu'+currentMenuShowingID);
		        subMenuToHide.obj.style.display = "none";
		    }
			
			//change color of sidebar back to normal on mouseoff
			//need to know if user moused off table or if user selected
			//another row.
			cancelHideSubMenu = true;
			subMenuShowing = false;
			
			//subArrow.style.visibility = "visible";
	        mainMenuLink.obj.style.textDecoration = "none";
	        
	        mainMenuRow.obj.bgColor = mainBGColor;
	        
	        //need to reset hyperlinks accordingly - customized above
	        if (currentMenuShowingID != menuActive) {
	            mainMenuLink.obj.style.color = mainDeactivatedLinkNonActiveFontColor;
	        }
	        else {
	            mainMenuLink.obj.style.color = mainDeactivatedLinkActiveFontColor;
	        }
		}
	}
}

function hideFlyoutMenu() {
   
    if (currentFlyoutMenuShowingID != undefined) {
        //var mainMenuLink = new getObj("Row" + currentMenuShowingID + "Link");
		//var flyoutMenuRow = new getObj("Row"+currentFlyoutMenuShowingID);
		if (!cancelHideFlyoutMenu) {
		    if (document.getElementById('flyoutMenu'+currentFlyoutMenuShowingID)) {
		        var flyoutMenuToHide = new getObj('flyoutMenu'+currentFlyoutMenuShowingID);
		        flyoutMenuToHide.obj.style.display = "none";
		    }
			
			//change color of sidebar back to normal on mouseoff
			//need to know if user moused off table or if user selected
			//another row.
			cancelHideFlyoutMenu = true;
			flyoutMenuShowing = false;
			
			//subArrow.style.visibility = "visible";
	        //mainMenuLink.obj.style.textDecoration = "none";
	        
	        //added 5/20/08 to handle IE div bug
	        var hideFlyoutDivFrame = new getObj("hideFlyoutDivFrame");
	        hideFlyoutDivFrame.obj.style.display = "none";
	        
	        //mainMenuRow.obj.bgColor = mainBGColor;
	        
	        //need to reset hyperlinks accordingly - customized above
	        //if (currentMenuShowingID != menuActive) {
	        //    mainMenuLink.obj.style.color = mainDeactivatedLinkNonActiveFontColor;
	        //}
	        //else {
	        //    mainMenuLink.obj.style.color = mainDeactivatedLinkActiveFontColor;
	        //}
		}
	}
}

function positionSubMenu(subMenuSelected, iRowID) {
	//main table object
	
	var mainTable = new getObj("mainTable");
	//var mainTableDiv = new getObj("mainTableDiv");
	//alert("mainTableDiv: " + mainTableDiv);
	var subMenuDiv = new getObj("subMenu"+iRowID);
	var mainMenuRow = new getObj("Row"+iRowID);
	
	
	var curTop = 0;
	
	//get properties of main table
	tableWidth = mainTable.obj.style.width;
	tableWidth = parseInt(tableWidth.replace("px", ""));
	
	//find x and y position of main table
	var xPos = findPosX(new getObj("containerTable"+iRowID));
	var yPos = findPosY(new getObj("mainTable"));
	
	//set visibility
	//position sub menu
	subMenuSelected.style.left = xPos + subTableOffsetX + "px";
	subMenuSelected.style.top = yPos + subTableOffsetY +  "px";
	
}

function positionFlyoutMenu(flyoutMenuSelected, iRowID, iSubMenuID, iFlyoutID) {
	//main table object
	
	var flyoutTable = new getObj("flyoutTable"+iFlyoutID);
	
	//var mainTableDiv = new getObj("mainTableDiv");
	//alert("mainTableDiv: " + mainTableDiv);
	var subMenuDiv = new getObj("subMenu"+iSubMenuID);
	var flyoutMenuDiv = new getObj("flyoutMenu"+iFlyoutID);
	//var flyoutMenuRow = new getObj("Row"+iRowID);

	var curTop = 0;
	
	//get properties of main table
	//var subMenuWidth = subMenuDiv.obj.style.width;
	//subMenuWidth = parseInt(subMenuWidth.replace("px", ""));
	
	//find x and y position of sub menu table
	var xPos = findPosX(new getObj("subTable"+iSubMenuID));
	var yPos = findPosY(new getObj("subMenu"+iSubMenuID+"Row"+iRowID));
	
	//set visibility
	//position sub menu
	flyoutMenuDiv.style.left = (xPos - 1 + subTableWidth) + "px";
	flyoutMenuDiv.style.top = (yPos - 1) + "px";
}

function findPosX(divElement) {
//find x position of menu - calculate position from left of screen
	var curLeft = 0;
	
	if (divElement.obj.offsetParent) {
		while (divElement.obj.offsetParent) {
			curLeft += divElement.obj.offsetLeft;
			divElement.obj = divElement.obj.offsetParent;
		}
	}
	else if (divElement.obj.x) {
		curLeft += divElement.obj.x;
	}
	
	return curLeft;
}

function findPosY(divElement) {
//find y position of menu - calculate position from top of screen
	var curTop = 0;
		
	if (divElement.obj.offsetParent) {
		while (divElement.obj.offsetParent) {
			curTop += divElement.obj.offsetTop;
			divElement.obj = divElement.obj.offsetParent;
		}
	}
	else if (divElement.y){
		curTop += divElement.obj.y;
	}
	
	return curTop;
}

function activateMainMenu(iMainMenuID) {
	//activate row properties
	//previous to last current moused over
	previousRowMousedOver = currentRowMousedOver; 
	
	var mainMenuItemSelected = new getObj(iMainMenuID);
	var mainMenuLink = new getObj(iMainMenuID + "Link");
	//var subArrow = new getObj(iMainMenuID + "_arr");
	
	//subArrow.style.visibility = "hidden";
	mainMenuItemSelected.obj.style.cursor = "pointer";
	//mainMenuLink.obj.style.textDecoration = "underline";
	mainMenuLink.obj.style.color = mainActivatedFontColor;
    mainMenuItemSelected.obj.bgColor = mainActivatedBGColor;
	currentRowMousedOver = iMainMenuID;
	
	//change color of previous sidebar if previous has been selected - deactivate
	if (previousRowMousedOver != null) {
		if (currentRowMousedOver != previousRowMousedOver) {
		    deactivateMainMenu(previousRowMousedOver);
		}
	}
}

function deactivateMainMenu(iMainMenuID) {
	//put menu item back to normal state
	//var currentMenuShowingIDRow = "Row" + currentMenuShowingID;
	//alert("currentMenuShowingIDRow: " + currentMenuShowingIDRow);
	var mainMenuItemSelected = new getObj(iMainMenuID);
	var mainMenuLink = new getObj(iMainMenuID + "Link");
  	
  	mainMenuLink.style.color = mainDeactivatedLinkNonActiveFontColor; 	
  	mainMenuLink.obj.style.textDecoration = "none";
	mainMenuItemSelected.obj.bgColor = mainBGColor;
}

function highlightMenuTD(menuItem) {
    menuItem.style.cursor = "pointer";
    //menuItem.className = "menuTDOn";
    menuItem.style.color = subMenuActivatedFontColor;
}

function menuTDOut(menuItem) {
    //menuItem.className = "menuTDOff";
    menuItem.style.color = subMenuDeactivatedFontColor;
}

function fadeSubMenu(inc, iRowID){
    //get div that needs to be faded in and out
    if (subMenuShowing) {
        var hideDivFrame = new getObj("hideDivFrame");
        
        if (inc == 0) {
            hideDivFrame.obj.style.display = "none";
        }
        
        var fadeIn = new getObj("subMenu"+iRowID);;
	
        //for browsers other than IE, use 0-1 for opacity. otherwise 0-100 for IE.
        var incFrac = inc/30;
        var subInc = 1-incFrac;
    
        var incMult = inc*5
    
        //fade in the image
        fadeIn.obj.style.filter = "alpha(opacity=" + incMult + ")";
        fadeIn.obj.style.mozOpacity = incFrac;
        fadeIn.obj.style.opacity = incFrac;
        
        inc++;
    
        //repeat until image is completely faded in or out
        if (inc < 100) {
            setTimeout("fadeSubMenu(" + inc + "," + iRowID + ")",1);
        }
        else if (inc >= 100) {
            //need to solve this issue - this is for the IE hack
            //hideDivFrame.obj.style.filter = "alpha(opacity=" + 100 + ")";
            //hideDivFrame.obj.style.mozOpacity = 1;
            //hideDivFrame.obj.style.opacity = 1;
            //hideDivFrame.obj.style.display = "block";
        }
    }
}
