// <![CDATA[
// JS utility
// ----------
// (c) 2006, JF Rabasse, contact@e-artefact.net
// $Id: menus.js,v 1.2 2009/04/15 12:13:40 jf Exp $
//
// CSS handled lists for popup menus.
// Applications should :
// - Create <ul> with class "cssmenulist"
// - Configure this list (or these lists) with :
//   list-style-type: none; (plus display style, colors, etc.)
// - Configure list items <li> with :
//   position: relative (plus display style)
// - Configure sublists <ul> <ul> with :
//   position: absolute; display: none; (plus display style)
// - Place sublists wrt command link :
//   left: xxxx; top: xxxx;
// (NB: not a good idea to place sublists here, froma handler. it may
// vary a lot according to decorations etc., so probably the best is to
// setup position from the main style sheet.)
//
// $Log: menus.js,v $
// Revision 1.2  2009/04/15 12:13:40  jf
// Snapshot before importing OPV site.
//
// Revision 1.1  2009/04/11 23:39:19  jf
// Snapshot. Lists menus implemented.
//
//

// Configure a menu list
//
function setupMenuList(menu) 
{
	// Get all sublists 
	var lists = menu.getElementsByTagName("ul");
    for (var ii = 0; ii < lists.length; ii++) {

		// Get parent (a list item)
		var item = lists[ii].parentNode;

		// Configure command link
        item.getElementsByTagName("a")[0].className = "cssmenulink";

		// Hook display handler
	    item.onmouseover = function() {
    		// this.getElementsByTagName("ul")[0].style.left = 
			// 	this.parentNode.offsetWidth - 2 + "px"
		    this.getElementsByTagName("ul")[0].style.display = "block";
	    }

		// Hook hide handler
	    item.onmouseout = function() {
		    this.getElementsByTagName("ul")[0].style.display = "none";
	    }
    }
}

// Configure all lists of proper class
//
function setupMenuLists() 
{
	var menus = document.getElementsByTagName("ul");
    for (var ii = 0; ii < menus.length; ii++) {
		if( menus[ii].className == "cssmenulist" ) 
			setupMenuList(menus[ii]);
	}
}

// Do all this upon page loading
execOnload(setupMenuLists);

// ]]>
