/* ============================================================ */
/* GLOBAL VARIABLES (g = variable is global)                    */
/* MB  = MB Button                                              */
/* DDM = Drop Down Menu                                         */
/* ============================================================ */
var gDDMDivId;      // Initialized in the DDMHide Method by setting its value equal to vDDMDivId.
var gDDMInterval;   // Initialized in the DDMHide Method and represents the Interval.

function DDMReveal(pDDMDivId)
{
    var vDDMDivId = document.getElementById(pDDMDivId); // Div that holds the table content of the Drop Down Menu.
		
    // Clear this Interval so the Drop Down Menu doesn't erase.
    window.clearInterval(gDDMInterval);
   
    // Test to see if variable gDDMDivId has been initialized.
    if (gDDMDivId !== undefined)
    {
        // If the Drop Down Menu div does not equal the current one.
        if (gDDMDivId.id != vDDMDivId.id)
        {
            // Erase old Drop Down Menu.
            gDDMDivId.style.display = 'none';
        }
    }
}

/* Method get's called through the setInterval (gDDMInterval).*/
function DDMErase()
{
    // Erase Drop Down Menu.
    gDDMDivId.style.display = 'none';
}

function DDMHide(pDDMDivId)
{
    // Div that holds the table content of the Drop Down Menu.
    var vDDMDivId = document.getElementById(pDDMDivId);
   
    // Initialize gDDMDivId
    gDDMDivId = vDDMDivId;
   
    // Initialize gDDMInterval and start Interval.
    gDDMInterval = window.setInterval("DDMErase()", 0);
}

/* Function used with an onmouseover to show the corresponding menu. */
function DDMShow(pThisCmdBtn, pDDMDivId, pDDMTableId)
{
    var vDDMDiv   = document.getElementById(pDDMDivId);   // Div that holds the table content of the Drop Down Menu.
    var vDDMTable = document.getElementById(pDDMTableId); // Table that holds the content of the Drop Down Menu.
               
    // Reveal the Drop Down Menu
    vDDMDiv.style.display = 'block';
   
    /* Call method to determine when the scrollbar should be displayed
       and to set the appropriate Width for the Drop Down Menu objects. */
    DDMScrollbarAndWidthControls(pThisCmdBtn, vDDMDiv, vDDMTable);
   
    DDMReveal(pDDMDivId);
}

/* Function used with an onclick to show the corresponding menu. */
function DDMToggleVisibility(pThisCmdBtn, pDDMDivId, pDDMTableId)
{
    var vDDMDiv   = document.getElementById(pDDMDivId);   // Div that holds the table content of the Drop Down Menu.
    var vDDMTable = document.getElementById(pDDMTableId); // Table that holds the content of the Drop Down Menu.
               
    // If the Drop Down Menu is visible then make invisible
    if (vDDMDiv.style.display == 'block')
    {
        vDDMDiv.style.display = 'none';
        return;
    }
   
    // Reveal the Drop Down Menu
    vDDMDiv.style.display = 'block';
   
    /* Call method to determine when the scrollbar should be displayed
       and to set the appropriate Width for the Drop Down Menu objects. */
    DDMScrollbarAndWidthControls(pThisCmdBtn, vDDMDiv, vDDMTable);
}


function DDMScrollbarAndWidthControls(pThisCmdBtn, vDDMDiv, vDDMTable)
{
    var vCmdBtnWidth   = pThisCmdBtn.offsetWidth; // Width of the Command Button (- 2, accommodate the side borders).
    var vDDMTableWidth = vDDMTable.offsetWidth;   // Width of Drop Down Menu Table.
    var vDDMDivHeight  = vDDMDiv.offsetHeight;    // Height of the Drop Down Menu Div
   
    var vDDMScrollDeterminerNumber = 411; // Number that determines when to stop the Drop Down Menu Div from growing taller and start scrolling.
    vDDMDiv.style.overflowX = 'hidden';   // Hide the horizontal scrollbar on the Drop Down Menu
   
    // Determine the appropriate Width for the Drop Down Menu objects.
    function DDMObjectsWidth(pDDMTableAndCmdBtnSameWidthPadRightFromScollbarAddOnNumber, pDDMTablePadRightFromScollbarAddOnNumber )
    {
        /* If the width of the Drop Down Menu Table is less than the
           Command Button then set the width of the Drop Down Menu Div
           and the Drop Down Menu Table to the width of the Command Button. */          
        if ((vDDMTableWidth + pDDMTableAndCmdBtnSameWidthPadRightFromScollbarAddOnNumber) < vCmdBtnWidth)
        {
            /* Detect if it is a IE5.5+ browswer, if it is we are going to add a little bit
			   more width to the drop down menu. (gBrowserVersion = browserDetection.js) */
			if (gBrowserVersion >= 5.5)
			{
				vDDMDiv.style.width   = vCmdBtnWidth + 2 + 'px';
            	vDDMTable.style.width = vCmdBtnWidth + 2 + 'px';
			}
			else
			{
				vDDMDiv.style.width   = vCmdBtnWidth + 'px';
            	vDDMTable.style.width = vCmdBtnWidth + 'px';
			}
        }
        /* Else set the width of the Drop Down Menu Div to the width of the
           Drop Down Menu Table (i.e., the width of the table that holds
           the content of the Drop Down Menu. The two parameters are for
           right padding from the Drop Down Menu Div's scrollbar. So if the
           scrollbar is present this padding will keep the text from being covered up. */   
        else
        {
            vDDMDiv.style.width = vDDMTableWidth + pDDMTablePadRightFromScollbarAddOnNumber;
        }
    }
   
    // If the Drop Down Menu Div's height is larger than 311 (vDDMScrollDeterminerNumber), reveal the scrollbar.
    if (vDDMDivHeight >= vDDMScrollDeterminerNumber)
    {
        vDDMDiv.style.height = vDDMScrollDeterminerNumber +'px'; // Set the Drop Down Menu Div's height.
        DDMObjectsWidth(12, 18); // Call Method to set the objects width
		vDDMDiv.style.overflowY = 'auto'; // Show the vertical scrollbar on the Drop Down Menu
    }
    // Else don't set the Drop Down Menu Div's height, no scrollbar needed.
    else
    {
        DDMObjectsWidth(0, 0); // Call Method to set the objects width
    }
}



function MBColorRetainController(pMenuBtn, pLink, pMenuBtnBG, pMenuBtnColor) {
    var vMenuBtn  = document.getElementById(pMenuBtn); // Menu Btn that corresponds with the Drop Down Menu.
	var vMenuLink = document.getElementById(pLink);    // Menu Btn Link that corresponds with the Drop Down Menu.
	
	if (vMenuBtn.className == 'NavbarSecTD') {
		vMenuLink.style.backgroundColor = pMenuBtnBG;
		vMenuLink.style.color = pMenuBtnColor;
	}
}

function MBColorRetain(pMenuBtn, pLink) {
	MBColorRetainController(pMenuBtn, pLink, '#d6d6d6', '#0055ff');
}
function MBColorReglar(pMenuBtn, pLink) {
	MBColorRetainController(pMenuBtn, pLink, '', '');
}



function ChangeCursorType(pThis) {
    pThis.style.cursor='default'; // Set the cursor to be the default pointer icon instead of the hand.
}