
/* 3/15/2010 These functions support Drop-Down Menus. It should not be necessary to change anything here when/if the Style chgaracteristics of the menys are changed. */

function ddm_FP_getObjectByID(id,o) {//v1.0 from Front Page Button-Maker Wizard
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=ddm_FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=ddm_FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}





function ddm_getElementCoords(idLocObj) { // receives an object's id and returns a 2-element (x,y of upper left corner) array
	// For all browsers except NN4 which does not have offset values. 

	// Locate the upper left corner
	anObj=ddm_FP_getObjectByID(idLocObj);
	// Step backwards through the containers until we reach the BODY (NN6 references even 'buried' objects directly to the body)
	anotherObj=anObj;			
	var yt=0; 
	var xt=0;
	
	do { // move backwards through containers, accumlating the offsets
		yt+=anotherObj.offsetTop; // get current offset
		xt+=anotherObj.offsetLeft;
		anotherObj=anotherObj.offsetParent; // move to next higher container	
	} while (anotherObj.tagName.toLowerCase() != 'body') // stop when the BODY has been reached
	var a_xy=new Array(xt, yt); // return an x,y array
	return a_xy;
}

/*
function ddm_setTimeoutEx() calls whatever is in a string expression after a timeout period.
It is like the standard setTimeout() function except it works for all 4+ browsers and allows the user to specify an
arbitrary number of arguments for the function to be called.
It returns the timeout ID number, which can be used to cancel the timer.
The description: ddm_setTimeoutEx(functionRef, msecDelay, [, funcarg1, ... functionargn).
The function name should be within quotes. (quotes only required for Linux Firefox and Linux Konqueror, but work for all).
Example: var _ct = ddm_setTimeoutEx('kickMe',1000;'Please kick me!',4,'times') is like kickMe('kick me',4,'times') with 1000msec delay.
It is the similar to the  conventional setTimeout() option provided with argument references which is not implemented in IE.
The original argument types seem to get through to the function called after the timeout.
*/

var 	_arArgs = new Array; // can't use arguments directly. They evaporate during the timeout period.
function ddm_setTimeoutEx() {
	_arArgs=ddm_setTimeoutEx.arguments;  // copy the arguments into a local variable
	// arArgs[0] is the function name, arArgs[1] is the time (ms), arArgs[2] ... arArgs[n] are the arguments to be called.
	var	str1="";
	for(i=2;i<ddm_setTimeoutEx.arguments.length-1;i++) // the arguments to go to the timed function
		str1 += '_arArgs[' + i + '],'; // arguments with comma trailer
	str1+= '_arArgs[' + i + ']';	// last argument  ... no trailing comma	
	str2='setTimeout("' +_arArgs[0]+ '('    + str1 +      ')'+'\"' +', _arArgs[1])'; // completed string

	return eval(str2) // execute
}	


function ddm_colorMenuElement(anObj, newBackColor, newTextColor, konq) {	
//	if(navigator.appName!='Konqueror')	
			anObj.style.background=newBackColor; 
	
		anObj.style.color=newTextColor;
}

var _ddm_menuBarShowingBackground;
var _ddm_menuBarShowingColor;
var _ddm_menuShowing=null;
var _titleShowingCell=null;

/* function ddm_showMenu(
Places the Moveable Menu just below the Main Menu selection.
	menuID=id of the menu to be shown
	titleCellID=the selected main menu cell containing the label.
*/
function ddm_showMenu(menuId, titleCellId) {
	// Get xy location where moveable menu is to be placed.
	var a_xy1=ddm_getElementCoords(titleCellId);
	var yLoc=a_xy1[1]+document.getElementById(titleCellId).offsetHeight;
	
	// move moveable menu to line up with left side of horizontal menu choice. If necessary to keep the whole moveable menu on screen.
	var mmWidth=document.getElementById(menuId).offsetWidth;	
	if((a_xy1[0] + mmWidth) >= document.body.clientWidth) a_xy1[0]=document.body.clientWidth-mmWidth-5;

	// Move the moveable menu just under the horizontal menu
	var menuObj=document.getElementById(menuId);		
	menuObj.style.left=a_xy1[0];
	menuObj.style.top= yLoc; ;

	// save the current menu; so that it can be restored later	
	_ddm_menuShowing = menuId;
	_titleShowingCell = titleCellId;

	// set the active main menu cell's background and color to indicate having been selected
	titleObj=ddm_FP_getObjectByID(_titleShowingCell);
	_ddm_menuBarShowingBackground=titleObj.style.background;
	_ddm_menuBarShowingColor=titleObj.style.color;
	
}


var _menuToOut=null; // static, used after Timeout
function ddm_clearMainMenuTimed() {
	_menuToOut=_ddm_menuShowing;	
	_ddm_timerID=setTimeout('ddm_clearMainMenu()',100);	
}

function ddm_clearMainMenu() {
	if(_ddm_menuShowing) {
		ddm_FP_getObjectByID(_menuToOut).style.top='-2000';  // move the menu out of sight			
		_ddm_menuShowing=null;
		
	titleObj=ddm_FP_getObjectByID(_titleShowingCell);	
	
	if(navigator.appName!='Konqueror')	
		titleObj.style.background =_ddm_menuBarShowingBackground;	
		
	// restore main menu cell's original color
	titleObj.style.color = _ddm_menuBarShowingColor;
	titleObj.style.background =_ddm_menuBarShowingBackground;	
	
	_ddm_menuShowing = null;
	_titleShowingCell = null;	
	}	
}

var _ddm_timerID=null;
function ddm_cancelRemoval() {
	if(_ddm_timerID)
		clearTimeout(_ddm_timerID);
}

