<!--

// IE/Mozilla dHTML Menus
// By Jim Richardson
// Contact: jim@djimm.co.uk

window.onresize = positionMenus

function DL_GetElementLeft(eElement)
{
    if (!eElement && this)                       // if argument is invalid
    {                                            // (not specified, is null or is 0)
        eElement = this;                         // and function is a method
    }                                            // identify the element as the method owner
    
    var nLeftPos = eElement.offsetLeft;          // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nLeftPos;                             // return the number calculated
}


function DL_GetElementTop(eElement)
{
    if (!eElement && this)
    {
        eElement = this;
    }

    var nTopPos = eElement.offsetTop;
    var eParElement = eElement.offsetParent;
    while (eParElement != null)
    {
        nTopPos += eParElement.offsetTop;
        eParElement = eParElement.offsetParent;
    }
    return nTopPos;
}

//elementReference.getTrueXPosition = DL_GetElementLeft;
//elementReference.getTrueYPosition = DL_GetElementTop;
//var nMyElementsTrueXPosition = elementReference.getTrueXPosition();
//var nMyElementsTrueYPosition = elementReference.getTrueYPosition();

//var nMyElementsTrueXPosition = DL_GetElementLeft(elementReference);
//var nMyElementsTrueYPosition = DL_GetElementTop(elementReference);

ActiveMenu = 0 //Stores current active menu
ActivesubMenu = 0 //Stores current active menu
timeMenu = 0	//Stores timeout (initialised to check if present)
subtimeMenu = 0	//Stores timeout (initialised to check if present) for SUBMENUS

donePosition = 0

function popMenuOn(menName,eventObj,collapsePrev){	//MENU ON - menName is layer reference, eventObj was about stopping bubbling - not sure it's necessary

	if(donePosition != 0){

	if(timeMenu != 0){ //Check if timeout in effect, if so cancel
		clearTimeout(timeMenu);
	}

	if(subtimeMenu != 0){ //Check if SUB timeout in effect, if so cancel
		clearTimeout(subtimeMenu);
	}

	if(ActiveMenu != 0 && collapsePrev == 1){ //Hide any visible drop downs
		document.getElementById(ActiveMenu).style.visibility = 'hidden';
	}

	if(ActivesubMenu != 0){
		document.getElementById(ActivesubMenu).style.visibility = 'hidden';
	}
	
	ActiveMenu = menName; //Set new active menu
	eventObj.cancelBubble = true; //Cancel event bubbling up through document, might not be necessary
	document.getElementById(menName).style.visibility = 'visible'; //Set visibility of menName to visible

	}

}

function popSubOn(menName,eventObj){	//MENU ON - menName is layer reference, eventObj was about stopping bubbling - not sure it's necessary

	if(timeMenu != 0){ //Check if timeout in effect, if so cancel
		clearTimeout(timeMenu);
	}

	//document.getElementById(ActiveMenu).style.visibility = 'visible'; //Set visibility of menName to visible

	if(subtimeMenu != 0){ //Check if SUB timeout in effect, if so cancel
		clearTimeout(subtimeMenu);
	}

	//if(ActiveMenu != 0 && collapsePrev == 1){ //Hide any visible drop downs
	//document.getElementById(ActiveMenu).style.visibility = 'hidden';
	//}
	
	ActivesubMenu = menName; //Set new active menu
	eventObj.cancelBubble = true; //Cancel event bubbling up through document, might not be necessary
	document.getElementById(menName).style.visibility = 'visible'; //Set visibility of menName to visible

}

function offTime(){	//Set short time out when rolling off menus - graceful
	timeMenu = setTimeout('popMenuOff()',400)
	}

function offSubTime(){	//Set short time out when rolling off menus - graceful
	subtimeMenu = setTimeout('popSubOff()',400)
	}
	

function popMenuOff(){ //MENU OFF

	if(ActiveMenu != 0){ //If there is a menu open
	document.getElementById(ActiveMenu).style.visibility = 'hidden'; //Set it 's visibility to hidden
	}

}

function popSubOff(){ //MENU OFF

	if(ActivesubMenu != 0){ //If there is a menu open
	document.getElementById(ActivesubMenu).style.visibility = 'hidden'; //Set it 's visibility to hidden
	document.getElementById(ActiveMenu).style.visibility = 'hidden'; //Set it 's visibility to hidden
	}

}

function positionMenus(){ //Position layers relative to nav - called on page load and resize

	//alert(DL_GetElementLeft(document.getElementById('au')));

	document.getElementById('auLayer').style.left = DL_GetElementLeft(document.getElementById('au'));
	document.getElementById('auLayer').style.top = DL_GetElementTop(document.getElementById('au')) + 23;
	document.getElementById('osLayer').style.left = DL_GetElementLeft(document.getElementById('os'));
	document.getElementById('osLayer').style.top = DL_GetElementTop(document.getElementById('os')) + 23;
	document.getElementById('oeLayer').style.left = DL_GetElementLeft(document.getElementById('oe'));
	document.getElementById('oeLayer').style.top = DL_GetElementTop(document.getElementById('oe')) + 23;
	document.getElementById('jobLayer').style.left = DL_GetElementLeft(document.getElementById('job'));
	document.getElementById('jobLayer').style.top = DL_GetElementTop(document.getElementById('job')) + 23;
	document.getElementById('resLayer').style.left = DL_GetElementLeft(document.getElementById('res'));
	document.getElementById('resLayer').style.top = DL_GetElementTop(document.getElementById('res')) + 23;
	document.getElementById('cuLayer').style.left = DL_GetElementLeft(document.getElementById('cu'));
	document.getElementById('cuLayer').style.top = DL_GetElementTop(document.getElementById('cu')) + 23;
	document.getElementById('rsasLayer').style.left = DL_GetElementLeft(document.getElementById('rsas')) + 160;
	document.getElementById('rsasLayer').style.top = DL_GetElementTop(document.getElementById('rsas'));

	donePosition = 1

}

//-->
