
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(
menuID=id of the menu to be shown
locationCellID=id of the tiny main menu cell whose left-hand corner will be where the moveable menu is placed.
(this is the cell just below the selected main menu item's text label.)
titleCellID=the selected main menu cell containing the label.
widthCell_LeftID=a cell marking the left edge of the moveable (used to calculate the menu width).
widthCell_RightID= a cell marking the right edge of the meovable menu. (used to calculate the width).
*/
function ddm_showMenu(menuID, locationCellID, titleCellID, widthCell_LeftID, widthCell_RightID) {

	var a_xy1=new Array(); // right-oriented location
	var a_xy2=new Array(); // used to get left top of the menu to be displayed
	var a_xy3=new Array(); // used to get right top of the menu to be displayed

	
	a_xy1=ddm_getElementCoords(locationCellID);
	
	a_xy2=ddm_getElementCoords(widthCell_LeftID);
	a_xy3=ddm_getElementCoords(widthCell_RightID);

	var mmWidth =a_xy3[0] - a_xy2[0];
	
	// move to left to keep on screen, if necessary
	if((a_xy1[0] + mmWidth)>=document.body.clientWidth) a_xy1[0]=document.body.clientWidth-mmWidth-5;
	
	
	var menuObj=ddm_FP_getObjectByID(menuID);		
	menuObj.style.left=a_xy1[0];
	menuObj.style.top= a_xy1[1];
	
	_ddm_menuShowing = menuID;
	_titleShowingCell = titleCellID;
	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()',500);	
//	_ddm_timerID=ddm_setTimeoutEx("ddm_clearMenu", 300, "error ... you should not see this");

}

function ddm_clearMainMenu() {
	if(_ddm_menuShowing) {
		ddm_FP_getObjectByID(_menuToOut).style.top='-2000';			
		_ddm_menuShowing=null;
		
	titleObj=ddm_FP_getObjectByID(_titleShowingCell);	
	
	if(navigator.appName!='Konqueror')	
		titleObj.style.background =_ddm_menuBarShowingBackground;	
		
	titleObj.style.color = _ddm_menuBarShowingColor;
		
	_ddm_menuShowing = null;
	_titleShowingCell = null;	
	}	
}


function ddm_clearSubMenu() {
	if(_ddm_menuShowing) {
		ddm_FP_getObjectByID(_menuToOut).style.top='-2000';			
		_ddm_menuShowing=null;
		
	titleObj=ddm_FP_getObjectByID(_titleShowingCell);	
	
	if(navigator.appName!='Konqueror')	
		titleObj.style.background =_ddm_menuBarShowingBackground;	
		
	titleObj.style.color = _ddm_menuBarShowingColor;
		
	_ddm_menuShowing = null;
	_titleShowingCell = null;	
	}	
}




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