//------------------------------
// DHTML Dropdown Script
// Charles Toepfer 11/17/2004
//------------------------------

//------------------------------
//Optional Settings:
var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ns6)
var nYoffset = 11; //Y Trim
else
var nYoffset = 33; //Y Trim

var nXoffset = 3; //X Trim
var nShowDelay = 500; //Time to wait before showing menu
var nHideDelay = 300; //Time to wait before hidding menu
var nSubHideDelay = 100;
//------------------------------
		
var nShowTimeoutID;
var nHideTimeoutID;
var sShowCmd;
var sHideCmd;
var nSubHideTimeoutID;
var sCache = new Array();
				
function DelayShow(obj)
{ 			
	//get subobject name (sub + main object name):
	sSubmenuID = 'sub' + obj.id;
	//clear any pending hide calls:
	window.clearTimeout(nHideTimeoutID);						
	
	//Hide Previous menu
	if(sShowCmd!=null) 
	{ 
		window.setTimeout(sShowCmd.replace('Show','Hide'), nShowDelay)
	}
			
	if (sCache[sSubmenuID]==null)
	{							
		//get positions:
		oC = getCoordinates(obj);
		//position object:
		sShowCmd = "Show('" + sSubmenuID + "'," + oC.x + "," + oC.y + ")";
		//identify layer has been positioned:
		sCache[sSubmenuID] = sShowCmd;
	}
	else
	{
		//retreived cached positions
		sShowCmd = sCache[sSubmenuID];
	}			
			
	nShowTimeoutID = window.setTimeout(sShowCmd, nShowDelay);			
}
		
		
		
function DelayHide(obj)
{ 			
	//Clear any pending show calls:
	window.clearTimeout(nShowTimeoutID);						
	//get subobject name (sub + main object name):
	sSubmenuID = 'sub' + obj.id;	
	//build command string:		
	sHideCmd = "Hide('" + sSubmenuID + "')"			
	nHideTimeoutID = window.setTimeout(sHideCmd, nHideDelay);			
}		
		
		
function subDelayHide(sSubmenuID)
{ 			
	//build command string:		
	sHideCmd = "Hide('" + sSubmenuID + "')"			
	nSubHideTimeoutID = window.setTimeout(sHideCmd, nHideDelay);			
}
		
function clearSubDelayHide()
{
	//cancels hide command from submenu:
	window.clearTimeout(nSubHideTimeoutID);
}
		
function Show(sID, iX, iY)			
{					
	//clear any pending hide calls:
	window.clearTimeout(nHideTimeoutID);								
	//set pos y axis:
	document.getElementById(sID).style.top = iY + nYoffset + "px";
	//set pos x axis:
	document.getElementById(sID).style.left = iX+ nXoffset + "px";
	//show:
	document.getElementById(sID).style.visibility='visible';
}
		
function Hide(sID)			
{	
	//hide:
	document.getElementById(sID).style.visibility='hidden';			
}
	
function getCoordinates(obj) 
{
	var oDescartes = new Object();
	//--Descartes, French mathematician who introduced the use of coordinates
	var sAnchorID = obj.id.toString();
	//Get fourth quadrant cartesian coordinates from parent object:
	oDescartes.x = GetXCoordinate(obj);
	oDescartes.y = GetYCoordinate(obj);
	return oDescartes;
}

function GetXCoordinate(oElement)
{
	//Get x coor pos:
	x = oElement.offsetLeft
	//Compensate for parent object:
	for (e = oElement.offsetParent; e; e = e.offsetParent)
	x += e.offsetLeft;
	return x
}
				
function GetYCoordinate(oElement)
{
	//Get y coor pos:
	y = oElement.offsetTop
	//Compensate for parent object:
	for (e = oElement.offsetParent; e; e = e.offsetParent)
	y += e.offsetTop;
	return y
} 
		
