<!--

// IE/Mozilla dHTML Menus
// By Jim Richardson
// Contact: djimmulator@yahoo.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
timeMenu = 0	//Stores timeout (initialised to check if present)

activeNavImage = 0

imgState = 0

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(ActiveMenu != 0 && collapsePrev == 1){ //Hide any visible drop downs
		popMenuOff();
	}
	
	ActiveMenu = menName; //Set new active menu
	//activeNavImage = imgName;

	/*if(imgState == 0){
		eval('swapImgOver\(\'' + imgName + '\',\'' + newSrc + '\'\)');
		imgState = 1;
	}*/

	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 popMenuOff(){ //MENU OFF

	if(ActiveMenu != 0){ //If there is a menu open
		document.getElementById(ActiveMenu).style.visibility = 'hidden'; //Set it 's visibility to hidden
		//eval('swapImgOut(\'' + activeNavImage + '\'\)');
		imgState = 0;
		}

}

function positionMenus(){ //Position layers relative to nav - called on page load and resize

	if(navigator.appName.indexOf('Explorer') != -1){ //Vary positioning for IE and non-IE
		offset = 17;
	}
	else{
		offset = 18;
	}

	menLeft = (eval(DL_GetElementLeft(document.getElementById('nav_cb'))) - 0) + "px";
	
	menTop = (eval(DL_GetElementTop(document.getElementById('nav_cb'))) + offset) + "px";
	
	document.getElementById('cblayer').style.left = menLeft;
	document.getElementById('cblayer').style.top = menTop;
	
	menLeft = (eval(DL_GetElementLeft(document.getElementById('nav_prod'))) - 0) + "px";
	
	menTop = (eval(DL_GetElementTop(document.getElementById('nav_prod'))) + offset) + "px";
	
	document.getElementById('prodlayer').style.left = menLeft;
	document.getElementById('prodlayer').style.top = menTop;
	
	menLeft = (eval(DL_GetElementLeft(document.getElementById('nav_cu'))) - 0) + "px";
	
	menTop = (eval(DL_GetElementTop(document.getElementById('nav_cu'))) + offset) + "px";
	
	document.getElementById('culayer').style.left = menLeft;
	document.getElementById('culayer').style.top = menTop;
	
	//menLeft = (eval(DL_GetElementLeft(document.getElementById('menu2'))) - 1) + "px";
	
	//menTop = (eval(DL_GetElementTop(document.getElementById('menu2'))) + offset) + "px";
	
	//document.getElementById('demolayer').style.left = menLeft;
	//document.getElementById('demolayer').style.top = menTop;
	
	//menLeft = (eval(DL_GetElementLeft(document.getElementById('menu3'))) - 1) + "px";
	
	//menTop = (eval(DL_GetElementTop(document.getElementById('menu3'))) + offset) + "px";
	
	//document.getElementById('supportlayer').style.left = menLeft;
	//document.getElementById('supportlayer').style.top = menTop;
	
	donePosition = 1;

};

//-->