// ================================================================
// ACCESSIBLE COMBO MENU SCRIPT: SELMENU v1.0 
// (c)2004 Sergi Meseguer (http://zigotica.com/) under CC license:
// http://creativecommons.org/licenses/by-sa/2.0/
// Requires EXTRAS namespace (extras.js in this folder)
// ================================================================
var SELMENU = {
	
	selmenus : [], 	// [i][0]: parent element reference
			// [i][1]: title reference
			// [i][2]: list menu reference
			// only restriction: have *one* title and menu for each "selmenu"

	start : function(){ 
		var sm = EXTRAS.getElementsByClass("selmenu");
		for (var i = 0; i < sm.length; i++) {
			var caja = sm[i];

			var titulos = EXTRAS.getElementsByClass("selmenutitulo",caja);
			var titulo = titulos[0];

			var menus = EXTRAS.getElementsByClass("selmenulista",caja);
			var menu = menus[0];
			
			var enlaces = menu.getElementsByTagName("A");
			for (var a = 0; a < enlaces.length; a++) {
				enlaces[a].style.display = "block";
				enlaces[a].style.width = "100%"; 
			}
			SELMENU.selmenus.push([caja,titulo,menu]);
		}
			
		for (var z = 0; z < SELMENU.selmenus.length; z++) {
			SELMENU.prepare(SELMENU.selmenus[z][0],SELMENU.selmenus[z][1],SELMENU.selmenus[z][2],CSS.getStyle(SELMENU.selmenus[z][0], "zIndex"));
		}
	},
	
	prepare : function(menu,titulo,enlaces,z){ 
		if(z=="auto" || z==0) z=1;
		
		titulo.style.backgroundImage = "url(select.gif)";
		titulo.style.backgroundPosition =  "99% 2px";
		titulo.style.backgroundRepeat = "no-repeat";

		enlaces.style.display = "none";
		enlaces.style.position = "absolute";
		enlaces.style.top = parseInt(CSS.getStyle(titulo, "height")-1) + "px";
		enlaces.style.left = "0px";
		
		menu.onmouseover = function(){
			enlaces.style.display = "block";
			menu.style.zIndex = z+5555;
		}
		menu.onmouseout = function(){
			enlaces.style.display = "none";
			menu.style.zIndex = z;
		}
	}

}

if (document.getElementsByTagName) EXTRAS.addEvent(window, 'load', SELMENU.start, false);
