/*
* *************************************************************
*
* FUNCTIONS
*
***************************************************************
*/

doLog = false;
var areMenusVisible = false;
/* this is just a placeholders to be replaced by real functions upon use */
function onHidden() {
 // status = "hidden";
}
function onVisible() {
 // status = "visible";
}
/* end of menu events*/

function isMenuVisible () {
 var oldState = areMenusVisible;
 for (mm in menus) {
  if (oldState) {
   // any visible keeps old state
   areMenusVisible = menus[mm].visible();
   if (areMenusVisible) break;
  } else {
   // any visible changes old state
   areMenusVisible = menus[mm].visible();
   if (areMenusVisible) break;
  }
 }
// invisible only if all menus are inivisble
return areMenusVisible;
} // isMenuVisible

function makeDiv (id) {
 return ("<DIV Style='position:absolute;visibility:visible;left:0;top:0'  ID=\"" + id + "\"></DIV>");
} makeDiv


/* this retrieves absolute offsets of an element */
function absOffsetX (o) {
return (isNN4 ? (o.parentLayer ? o.x - absOffsetX (o):o.x) : ((o.offsetParent==document.body) ? o.offsetLeft: 
o.offsetLeft + absOffsetX(o.offsetParent)));
}
function absOffsetY (o) {
 return (isNN4 ? (o.parentLayer ? o.y - absOffsetY (o):o.y): ((o.offsetParent==document.body) ? o.offsetTop: o.offsetTop + absOffsetY(o.offsetParent)));
}

/* 
 * define actions on mouseover/mouseout
 */
// INLINE
// 	* MOUSEOVER
function onMouseOver_inline  (ev) {
	// argument/event used for "popup" style, where event is used in IE to get event location
	var e = this.L;
	var parent = e.parent;
	parent.hideChildrenExcept(e); // hide all other sibling menus
	if (e.child) {
		var pc = parent.menuContainer; 
		parent.refresh();	// make sure parent collapse before continuing
		// position children indented relative to parent container
		posX = pc.left() + e.left() + e.indent;

		e.child.moveTo(posX, pc.top() + e.top() + e.selfHeight());
		e.child.visible (true); 	// show child menu
	}
	parent.refresh();	// make space
	parent.entry();
	e.isActive (true);

} // onMouseOver_inline
// 	* MOUSEOUT
function onMouseOut_inline () {
	this.L.parent.exit();
	this.L.isActive(false);
} // onMouseOut_inline 

// POPUP
function onMouseOver_popup  (ev) {
var posX, posY;
var allWidth = isNN4? window.innerWidth:(document.all?top.document.body.offsetWidth:800);
var allHeight = isNN4? window.innerHeight:(document.all?top.document.body.offsetHeight:600);

	var e = this.L;
	var parent = e.parent;
	if (parent) {parent.entry(); parent.hideChildrenExcept(e); if(e.parent.parent) e.parent.parent.isActive(true);}
	if (parent && parent.parent) {parent.parent.isActive(true);}

	if (!e.child && e.menuitem) {
		// if menu not yet created then do it!
//		e.child = e.menuitem.makeMenu(e.childWidth(), e.menustyle);
		e.child = e.menuitem.makeMenu(figureOutWidth(e.menuitem.children), e.menustyle);
		if (e.child) {
            e.child.parent=e;
		 e.child.parentMenu= e.parentMenu;
           }
	}
	if (e.child) {
		var pc = parent.menuContainer; 
		// position children at click position
		// place the child at the right margin
		posX = pc.left() + pc.width() + subMenuXOffset ; posY = pc.top() + e.top(); 
            // or hop it to other side if it goes outside screen
            if (posX+e.child.width()>allWidth &&pc.left()-e.child.width()>0) posX = pc.left() - e.child.width() - subMenuXOffset;
		if (posY+e.child.height()>allHeight) posY = posY - e.child.height() + e.height();
		e.child.moveTo(posX, posY);
     	if (e.child.timer) {clearTimeout(e.child.timer);}
		e.child.showDelayed();
	}

	e.isActive (true);

} // onMouseOver_popup

// 	* MOUSEOUT
function onMouseOut_popup (ev) {
	this.L.parent.exit(500);
	this.L.isActive(false);
} // onMouseOut_popup

/* hide menu */
function hideMenu(m) {
    if (m.timer) clearTimeout (m.timer); // clear old one and set a new one
	m.timer = setTimeout ("m=menus['" + m.ID + "'];m.visible(false);",hideDelay); 
	if (m.parent) m.parentMenu.refresh();
} // hideMenu

/* showDelayed */
function showDelayed(m) {
	m.timerS = setTimeout ("m=menus['" + m.ID + "'];m.visible(true);",showDelay); 
	if (m.parent) m.parentMenu.refresh();
} // showDelayed

function showDelayedClear(m) {
    // show and clear timeout if set in the meantime
	m.timerSkipExit = setTimeout ("m=menus['" + m.ID + "'];if(m.timer)clearTimeout(m.timer);m.timerSkipExit=false;m.visible(true);",showDelay); 
	if (m.parent) m.parentMenu.refresh();
} // showDelayedClear

/* hide branch  */
function hideBranch(m) {
	m.hideBranch();
} // hideBranch

var ScaleFactor = 7.8; // pixels per character (may change depending on font style in stylesheet menu and altMenu)

function figureOutWidth (childrenArray) {
  if(!childrenArray) return 0;
  // approximate a menu width so that any text in array will display in one line
  var i; var chars =0;
  for (i=0;i<childrenArray.length;i++) {
    if (childrenArray[i].title.length>chars) {chars = childrenArray[i].title.length ;}
  }
  return chars * ScaleFactor + 10;
} // figureOutWidth
doLog = false;
var areMenusVisible = false;
/* this is just a placeholders to be replaced by real functions upon use */
function onHidden() {
 // status = "hidden";
}
function onVisible() {
 // status = "visible";
}
/* end of menu events*/

function isMenuVisible () {
 var oldState = areMenusVisible;
 for (mm in menus) {
  if (oldState) {
   // any visible keeps old state
   areMenusVisible = menus[mm].visible();
   if (areMenusVisible) break;
  } else {
   // any visible changes old state
   areMenusVisible = menus[mm].visible();
   if (areMenusVisible) break;
  }
 }
// invisible only if all menus are inivisble
return areMenusVisible;
} // isMenuVisible

function makeDiv (id) {
 return ("<DIV Style='position:absolute;visibility:visible;left:0;top:0'  ID=\"" + id + "\"></DIV>");
} makeDiv


/* this retrieves absolute offsets of an element */
function absOffsetX (o) {
return (isNN4 ? (o.parentLayer ? o.x - absOffsetX (o):o.x) : ((o.offsetParent==document.body) ? o.offsetLeft: 
o.offsetLeft + absOffsetX(o.offsetParent)));
}
function absOffsetY (o) {
 return (isNN4 ? (o.parentLayer ? o.y - absOffsetY (o):o.y): ((o.offsetParent==document.body) ? o.offsetTop: o.offsetTop + absOffsetY(o.offsetParent)));
}

/* 
 * define actions on mouseover/mouseout
 */
// INLINE
// 	* MOUSEOVER
function onMouseOver_inline  (ev) {
	// argument/event used for "popup" style, where event is used in IE to get event location
	var e = this.L;
	var parent = e.parent;
	parent.hideChildrenExcept(e); // hide all other sibling menus
	if (e.child) {
		var pc = parent.menuContainer; 
		parent.refresh();	// make sure parent collapse before continuing
		// position children indented relative to parent container
		posX = pc.left() + e.left() + e.indent;

		e.child.moveTo(posX, pc.top() + e.top() + e.selfHeight());
		e.child.visible (true); 	// show child menu
	}
	parent.refresh();	// make space
	parent.entry();
	e.isActive (true);

} // onMouseOver_inline
// 	* MOUSEOUT
function onMouseOut_inline () {
	this.L.parent.exit();
	this.L.isActive(false);
} // onMouseOut_inline 

// POPUP
function onMouseOver_popup  (ev) {
var posX, posY;
var allWidth = isNN4? window.innerWidth:(document.all?top.document.body.offsetWidth:800);
var allHeight = isNN4? window.innerHeight:(document.all?top.document.body.offsetHeight:600);

	var e = this.L;
	var parent = e.parent;
	if (parent) {parent.entry(); parent.hideChildrenExcept(e); if(e.parent.parent) e.parent.parent.isActive(true);}
	if (parent && parent.parent) {parent.parent.isActive(true);}

	if (!e.child && e.menuitem) {
		// if menu not yet created then do it!
//		e.child = e.menuitem.makeMenu(e.childWidth(), e.menustyle);
		e.child = e.menuitem.makeMenu(figureOutWidth(e.menuitem.children), e.menustyle);
		if (e.child) {
            e.child.parent=e;
		 e.child.parentMenu= e.parentMenu;
           }
	}
	if (e.child) {
		var pc = parent.menuContainer; 
		// position children at click position
		// place the child at the right margin
		posX = pc.left() + pc.width() + subMenuXOffset ; posY = pc.top() + e.top(); 
            // or hop it to other side if it goes outside screen
            if (posX+e.child.width()>allWidth &&pc.left()-e.child.width()>0) posX = pc.left() - e.child.width() - subMenuXOffset;
		if (posY+e.child.height()>allHeight) posY = posY - e.child.height() + e.height();
		e.child.moveTo(posX, posY);
     	if (e.child.timer) {clearTimeout(e.child.timer);}
		e.child.showDelayed();
	}

	e.isActive (true);

} // onMouseOver_popup

// 	* MOUSEOUT
function onMouseOut_popup (ev) {
	this.L.parent.exit(500);
	this.L.isActive(false);
} // onMouseOut_popup

/* hide menu */
function hideMenu(m) {
    if (m.timer) clearTimeout (m.timer); // clear old one and set a new one
	m.timer = setTimeout ("m=menus['" + m.ID + "'];m.visible(false);",hideDelay); 
	if (m.parent) m.parentMenu.refresh();
} // hideMenu

/* showDelayed */
function showDelayed(m) {
	m.timerS = setTimeout ("m=menus['" + m.ID + "'];m.visible(true);",showDelay); 
	if (m.parent) m.parentMenu.refresh();
} // showDelayed

function showDelayedClear(m) {
    // show and clear timeout if set in the meantime
	m.timerSkipExit = setTimeout ("m=menus['" + m.ID + "'];if(m.timer)clearTimeout(m.timer);m.timerSkipExit=false;m.visible(true);",showDelay); 
	if (m.parent) m.parentMenu.refresh();
} // showDelayedClear

/* hide branch  */
function hideBranch(m) {
	m.hideBranch();
} // hideBranch

var ScaleFactor = 7.8; // pixels per character (may change depending on font style in stylesheet menu and altMenu)

function figureOutWidth (childrenArray) {
  if(!childrenArray) return 0;
  // approximate a menu width so that any text in array will display in one line
  var i; var chars =0;
  for (i=0;i<childrenArray.length;i++) {
    if (childrenArray[i].title.length>chars) {chars = childrenArray[i].title.length ;}
  }
  return chars * ScaleFactor + 10;
} // figureOutWidth

/*
* *************************************************************
*
* MENU AND LAYER OBJECTS
*
***************************************************************
*/

function layer (parent, w) {
var id; 
var theWidth = (arguments.length>1)?w:400;

this.parent; // parent layer
this.style;

id0 = "A" +10000*Math.random();
id = "id" + id0.substr(id0.indexOf("."));
this.id = id;

	if (arguments.length>0) {
		if (isNN4) {
			this.self = new Layer (theWidth, parent.self);
		} else {
			parent.self.insertAdjacentHTML ("BeforeEnd", makeDiv (id));
			this.self = parent.self.document.all[id];
		}
		this.parent = parent;
	}
	else if (BaseLayer) {
		if (isNN4) {
		 this.self = new Layer (theWidth, BaseLayer); 
		} else {
		 BaseLayer.body.insertAdjacentHTML ("BeforeEnd", makeDiv (id));
		 this.self = BaseLayer.all[id];
		}
    }
	else {
		if (isNN4) {
		 this.self = new Layer (theWidth); 
		} else {
		 document.body.insertAdjacentHTML ("BeforeEnd", makeDiv (id));
		 this.self = document.all[id];
		}
	}
// style applies to Layer in NN4 or layer.style in other
this.style = isNN4 ? this.self:this.self.style;

this.theWidth;
this.theHeight;
this.theHTML;
this.entries;

this.add = function () {
	if (!this.entries) {this.entries = new Array();}
	var L = new layer(this);
	this.entries[this.entries.length] = L;
	return L;
} // add {create a new layer}

this.html = function (html) {
if (arguments.length>0) {
	if (isNN4) {
 	 this.self.document.write(html);
	 this.self.document.close();
     this.theHTML = html;
    } else {
	 this.self.innerHTML = html;
    }
}
return isNN4 ? this.theHTML :this.self.innerHTML; 
} // html

this.assign = function (x, v) {
	this.self[x] = v;
} // assign
this.url = function (u) {
if (isNN4) {
	this.self.document.url = u; // NN pass to document
} else {
	this.self.url = u;
}
} // url

this.visible = function (state) {
	if (arguments.length>0) {
		if (state) {
			this.style.visibility = doShow;
		} else {
			this.style.visibility = doHide;
		}
	}
	return this.style.visibility == doShow || this.style.visibility == "visible" ; 
} //visible

this.left = function (l) {
	if (arguments.length==1) {
		this.style.left = l;
	}
	return (isNN4 ? this.style.left:this.style.pixelLeft);
}
this.top = function (t) {
	if (arguments.length==1) {
		this.style.top = t;
	}
	return (isNN4 ? this.style.top:this.style.pixelTop);
}

this.width = function (w) {
	if (arguments.length==1) {
		this.theWidth = w;
		if (isNN4) {
            this.self.clip.right = w; 
           } else {
            this.style.width = w; 
           }
	}
	return this.theWidth;
}

this.height = function (h) {
	if (arguments.length==1) {
		this.theHeight = h;
		if (isNN4) {
 		  this.self.clip.height = h;
           } else {
             this.style.height = h;
//             this.style.overflow = "hidden"; // use height as clip in NN
           }
	}
	if (this.theHeight) {
		return this.theHeight;
	} else {
		return isNN4 ? this.self.document.height: this.style.pixelHeight;
	}
}
this.bgColor = function (bgc) {
	if (arguments.length==1) {
if (isNN4) {
		this.style.bgColor=bgc;
} else {
		this.style.backgroundColor = bgc;
}
	}
	return isNN4 ? this.style.bgColor: this.style.backgroundColor;
}
this.moveTo = function (x,y) {
		this.left (x);  this.top(y);
} //moveTo
/*
Pass functions to contained layer
*/
this.onMouseOver = function (f) {
	this.self.onmouseover = f;
} // onMouseOver
this.onMouseOut = function (f) {
	this.self.onmouseout = f;
} // onMouseOut
this.onClick = function (f) {
if (isNN4){
	this.self.document.onclick = f; // NN
  } else {
	this.self.onClick = f; // IE
  }
} // onClick
/* END Pass functions to contained layer */

} // layer

/* menu item */
function item (title, url, parent)  {
	this.parent = parent; // parent item
	this.title = title;
	this.url = url;
	this.children; // array of children
	this.html = function () {
		return this.title + ((this.children &&this.level()>0) ? " <img src=" + iconExpand +">": "");
	};
    this.theLevel = 0;
    this.level = function (lev) {
        if (arguments.length>0) {
            this.theLevel = lev;
		 if (this.children &&lev>1) {
			for (i=0;i<this.children.length;i++) {
				this.children[i].level(lev-1);
			}
		}
        }
        return this.theLevel;
    } // level

	this.menu;
	this.onClick = function () {window.location = this.url;} // this triggers action?
	this.menustyle = "inline";

	this.makeMenu = function (w, menustyle, lev) {
	var MENU;
    if (arguments.length>2) {this.level (lev);}
    if (this.level()==0) {return;} // do not create a menu;

	if (this.children) {
		var i;
		MENU = new menuBlock ();
           MENU.title = this.title;
		if (arguments.length<2) {menustyle = "inline";} else {this.menustyle=menustyle}
		MENU.defineAs = this.menustyle;
		if (w) {MENU.width(w);}
		for (i=0;i<this.children.length;i++) {
			var e1 = MENU.addEntry (this.children[i].html()); // create a child item
 			e1.bgColor (colorMenuBack);
			e1.bgColorAlt (colorMenuBackAlt);
			if (this.children[i].url) {
				e1.url (this.children[i].url);
				e1.onClick (this.children[i].onClick); 
			} 
//			e1.child = this.children[i].makeMenu(e1.childWidth(), this.menustyle);
e1.menustyle = this.menustyle;
e1.menuitem = this.children[i];
e1.parentMenu = MENU; 
			if (e1.child) {
				e1.child.parent=e1;
				e1.child.parentMenu=MENU; // direct to parent menu
			}
		}
		MENU.refresh();
		MENU.level = this.level ();
		this.menu = MENU; // make a link from item to menu

		return MENU;
	}
	} //makeMenu

} // item

/*
menu block
*/
function menuBlock() {
	this.showAlways = false;// by default menu is hidden
	this.hideAlways = false;// by default menu may be shown
	this.level=0; // no level by default

	this.ID = "M" + Math.random(); // random id
	this.defineAs ="popup"; // default value
	this.childIndent = 20; 	// default indent

	this.menuContainer = new layer ();
	this.menuContainer.visible (false);
	this.menuContainer.bgColor(colorMenuBorderExt);

	menus[this.ID] = this; // record  it
	this.padding = paddingDefault; 	// default padding (use just ONE padding - border width and all
	this.borderExternal = iBorderExt;
	this.borderInternal = iBorderInt;

	this.borderInt = new layer (this.menuContainer);
	this.borderInt.html("&nbsp;");
	this.borderInt.left(this.borderExternal-this.borderInternal);
	this.borderInt.top(this.borderExternal-this.borderInternal);
	this.borderInt.visible (false);
	this.borderInt.bgColor(colorMenuBorder);

	this.entries = new Array(); // menu entries
	this.x = this.borderExternal ; // this.padding;
	this.y = this.borderExternal; // this.padding;
	this.contentWidth = function () {return this.width()-2*this.borderExternal; } // this.padding;}

this.showDelayed = function() {
   showDelayed(this);
} //
this.showDelayedClear = function() {
   showDelayedClear(this);
} //

this.exit = function (del) {
    this.hideChildrenDelayed (del); // trigger children
    this.hideThis (del); // and parent(s)
} //exit

/* same as exit only does not care about children */
this.hideThis = function (del) {
	 // set timer to close
    delStr = del ? del.toString():hideDelay; 
    hideMenu(this);
    if (this.timerS) {clearTimeout(this.timerS);} // if delayed show - remove
    p=this.parentMenu; if(p){p.hideThis(delStr)};
} //hideThis


this.hideBranch = function () {
  this.visible(false);
  if(this.timerS) clearTimeout (this.timerS);
  if(this.timerSkipExit) clearTimeout (this.timerSkipExit);
  for (i in this.entries) {
    if (this.entries[i].child) {this.entries[i].child.hideBranch();}
  }
} //hideBranch

this.entry = function () {
	if (this.parentMenu && ! this.parentMenu.hideAlways) this.parentMenu.entry();
	if (this.timer) clearTimeout(this.timer);
	this.visible(true);
} // entry

this.hideChildrenExcept = function (e) {
	for (i in this.entries) {
		if (this.entries[i]!=e && this.entries[i].child) {
			this.entries[i].child.visible(false);
		}
	}
} // hideChildrenExcept

this.hideChildrenDelayed = function (del) {
    var m;
	for (i in this.entries) {
		if (this.entries[i].child) {
           	if (this.entries[i].child.timerS) clearTimeout(this.entries[i].child.timerS); // clear "show" timer
			hideMenu(this.entries[i].child);
		}
	}
} // hideChildrenExcept

this.visible = function (state) {
	if (arguments.length>0) {
		if (!(this.showAlways || this.hideAlways)) {
			this.menuContainer.visible (state);
			this.borderInt.visible(state);
			for (i=0;i<this.entries.length;i++) {
				this.entries[i].visible (state);
			}
		}
	}
	return this.menuContainer.visible ();
} //visible

// default colors
this.width = function (w) {
	if (arguments.length==1) {
		this.borderInt.width(w-2*this.borderExternal+2*this.borderInternal);
		return	this.menuContainer.width(w);
	} else {
		return	this.menuContainer.width();
	}
} // width

this.height = function (h) {
	if (arguments.length==1) {
		this.borderInt.height(h-2*this.borderExternal+2*this.borderInternal);
		return	this.menuContainer.height(h);
	} else {
		return	this.menuContainer.height();
	}
} //height

this.refresh = function () {
	var t = this.borderExternal; // this.padding;
	for (i=0; i<this.entries.length; i++) {
		this.entries[i].top(t); 
		t = t + this.entries[i].height() + this.borderInternal; // this.padding;
	}
	this.y = t -  this.borderInternal +  this.borderExternal;
	this.height (this.y); // set height
}


this.bgColor = function (bgc) {this.menuContainer.bgColor(bgc);}
this.moveTo = function (x,y) {
	this.menuContainer.moveTo (x,y); //NN
	} //moveTo

this.addEntry = function (html, althtml) {
	w = this.contentWidth();
	if (arguments.length<2) {althtml = html;}
	var lay = new menuEntry (this, w, 0, html, althtml);

	this.entries[this.entries.length] = lay;
	lay.top (this.y);
	lay.left (this.x);
	lay.indent = this.childIndent;
	this.y = lay.top() + lay.height() + this.padding;
	this.refresh();
	return lay;
	} // addEntry
}
/* class for menu block item */
function menuEntry (parent,w,h,html, althtml) {
	this.parent = parent; 	// parent menu block
	this.child; 		// may contain menu block of child menu

// use this to create menu block on demand - passed from parent; used on mouseover to create menu if not exist
this.menuitem;
this.menustyle; 
this.menuwidth;

	this.html = html;
	this.theHeight=0;
	this.indent = 0; 	// indent (used for for inline style)
	this.menuStyle;
    this.visibility = false; 

	this.defineAs = function (t) {
		this.menuStyle = t;
		if (t=="inline") {
			// define "inline" behaviour (show all navigator - child layer takes space)
			this.inline = true; // inline navigator as opposed to popup
			this.onMouseOver = onMouseOver_inline;
			this.onMouseOut = onMouseOut_inline;

		} else {
			// define "popup" behaviour (show only active branch - child layer pop up over)
			this.inline = false; // popup
			this.onMouseOver = onMouseOver_popup; 
			this.onMouseOut= onMouseOut_popup;
		}
	} // defineAs

	this.defineAs (parent.defineAs) ; // get the style from parent menu

	this.childWidth = function () {
		if (this.menuStyle =="inline") {
			return this.parent.width() - this.indent- 2*this.parent.borderExternal;
		} else {
			return this.parent.width();
		}
	} // childWidth

if (arguments.length<=4) {althtml = html;};
	// init alternate (mouseover) menu entry
	this.altlayer = new layer (parent.menuContainer); 
	this.altlayer.html ("<p class=menuAlt>" + althtml);
	this.altlayer.visible (false);
	this.altlayer.height(menuItemHeight);

	this.altlayer.width(w); 
// init menu entry
	this.layer = new layer (parent.menuContainer); 
	this.layer.html ("<p class=menu>" + html );
	this.layer.visible (false);
	this.layer.height(menuItemHeight); // can't get layer height in IE ??
	this.layer.width(w); 

// this creates a layer that has onMouseOver and onClick actions
	this.actionlayer = new layer (parent.menuContainer);

	this.actionlayer.visible (false);

if (isNN4) {
	this.actionlayer.width (w);
	this.actionlayer.height (this.layer.height());
} else {
	// basically for IE5.5 but works with other IE as well
	this.actionlayer.html("<img style=\"cursor:hand\" src=/icons/ecblank.gif height=" + this.layer.height()+ " width=" + w +">"); 
}
	this.actionlayer.assign("L1", this.layer);
	this.actionlayer.assign("L2", this.altlayer);
	this.actionlayer.assign("L", this);

	this.childcontainer = new layer (parent.menuContainer); 
	this.childcontainer.bgColor ("gray");
	this.childcontainer.visible(false);

	this.actionlayer.onMouseOver (this.onMouseOver); // pass function down to layer
	this.actionlayer.onMouseOut (this.onMouseOut);
//	this.actionlayer.onClick (function (){window.location = this.url; });
var tmpHTML;
if (isNN4) {
//    this.actionlayer.self.document.onclick = function (){window.location = this.url; } 
     // lamely use document of action layer to store url for NN
     tmpHTML = "<a name=act href=\"about:blank\" onClick=\"window.location = document.theUrl;return false;\"><img src=\"/icons/ecblank.gif\" border=\"0\" width=\"";
      tmpHTML += this.actionlayer.width () + "\" height=\"" + menuItemHeight + "\"></a>"
      this.actionlayer.html(tmpHTML);
} else {
	this.actionlayer.self.onclick = function (){top.document.location = this.url; } 
}

this.visible = function (state) {
if (arguments.length>0) {
    this.visiblity = state;
	this.actionlayer.visible (state);
	this.layer.visible (state);
	this.altlayer.visible (state);
	this.childcontainer.visible (state);
    if (areMenusVisible!= isMenuVisible()) {
      if (areMenusVisible) onVisible(); else onHidden(); // call one event on state change (of all menus)
    }
} 
return this.visibility;
} // visible

this.isActive = function (state) {
// if any visible then swap
if (this.layer.visible() || this.altlayer.visible()) {
	this.layer.visible (!state);
	this.altlayer.visible (state);
}
if (state &&this.parent &&this.parent.parent) this.parent.parent.isActive(state);
} // isActive

this.onClick = function (f) {
	this.actionlayer.onClick(f); // pass down to action layer
} // onClick

this.url = function (u) {
	this.actionlayer.url(u.html); // pass down to action layer document
    if (isNN4) {this.actionlayer.self.document.theUrl=u;}      // lamely use document of action layer to store url for NN
} // url

this.top = function (t) {
	if (arguments.length>0) {
		this.layer.top (t);
		this.altlayer.top (t);
		this.actionlayer.top (t);
	}
	return this.layer.top();
} // top

this.left = function (l) {
	if (arguments.length>0) {
		this.layer.left(l);
		this.altlayer.left (l);
		this.actionlayer.left(l);
	}
	return this.layer.left();
} // left

this.height = function (h) {
	var childHeight = this.inline && this.child && this.child.visible () ? this.child.height():0 ;
	if (arguments.length>0) {
		this.theHeight = h;
		this.layer.height (h);
		this.actionlayer.height (h);
		this.parent.refresh();
	}
	if (this.theHeight==0) {
		return this.layer.height() +childHeight;
	} else {
		return this.theHeight + childHeight;
	}
} // height
// never include children
this.selfHeight = function () {
	if (this.theHeight==0) {
		return this.layer.height();
	} else {
		return this.theHeight;
	}
} // selfHeight

/* property pairs
 BACKGROUND */
this.bgColor = function (bgc) {
	if (arguments.length>0) {
		this.layer.bgColor (bgc);
	}
	return this.layer.bgColor();
} // bgColor
/* ALT BACKGROUND (MOUSEOVER) */
this.bgColorAlt = function (bgc) {
	if (arguments.length>0) {
		this.altlayer.bgColor (bgc);
	}
	return this.altlayer.bgColor ();
} // bgColorAlt

} // menuEntry
