function InicializaMenu()
{
	if(typeof menu_activo != 'undefined') menu_activo = DynObject.all[menu_activo];
	else menu_activo = null;
	menu_tmr = null;
	menu_t = 250;

	var lyrs = DynAPI.document.getAll();
	for(var lyr in lyrs) {
		if(/(\w+)MENU$/.test(lyr)) {
			var obj = lyrs[lyr];
			obj.img = obj.doc.images[RegExp.$1 + 'IMG'];
			obj.imgover = new Image();
			obj.imgover.src = obj.img.src.replace(/(.gif|.jpg|.png)$/, '_over$1');
			obj.imgorig = new Image();
			obj.imgorig.src = obj.img.src;

			obj.listener = new EventListener(DynAPI.document);
			obj.listener.onmouseover = function(ev) {
				if(menu_tmr) {
					clearTimeout(menu_tmr);
					menu_tmr = null;
				}

				var obj = ev.getSource();
				obj.img.src = obj.imgover.src;
				if(menu_activo && obj != menu_activo) {
					menu_activo.img.src = menu_activo.imgorig.src;
				}
			};
			obj.listener.onmouseout = function(ev) {
				var obj = ev.getSource();
				if(obj != menu_activo) {
					obj.img.src = obj.imgorig.src;
					if(menu_activo) menu_tmr = setTimeout('ActivarItem()', menu_t);
				}
			};
			obj.addEventListener(obj.listener);
		}
	}
	if(menu_activo) ActivarItem();

	loaded = true;
}

//dynapi.onLoad(InicializaMenu);

DynAPI.addLoadFunction('InicializaMenu()');

function ActivarItem()
{
	menu_tmr = null;
	menu_activo.img.src = menu_activo.imgover.src;
}

// Función para los combos que saltan a urls
function Saltar(elm)
{
	var url = elm[elm.selectedIndex].value;
	if(url == '') elm.selectedIndex = 0;
	else location.href = url;
}

/*
	Función para abrir una ventana. Puede recibir los siguientes parámetros:

	url	-> Página web que mostrará la ventana. Por defecto página en blanco. Ejemplo: 'aviso.phpl'.
	target	-> Ventana en la que se abrirá la url. Por defecto en una nueva ventana cada vez. Ejemplo: '_blank'.
	width	-> Ancho en píxeles de la ventana. Por defecto 250 píxeles. Ejemplo: 300
	height	-> Alto en píxeles de la ventana. Por defecto 250 píxeles. Ejemplo: 125
	left	-> Distancia en píxeles al borde izquierdo de la pantalla. Por defecto centrada horizontalmente. Ejemplo: 100
	top	-> Distancia en píxeles al borde superior de la pantalla. Por defecto centrada verticalmente. Ejemplo: 100
	resizable	-> Indica si el usuario puede modificar el tamaño de la ventana. Por defecto no. Ejemplo: 'yes' o true
		Valores posibles: 'yes', 'no', '1', '0', true, false.
	scrollbars	-> Indica si la ventana tendrá barras de scroll. Por defecto no. Ejemplo: 'no' o false
		Valores posibles: 'yes', 'no', '1', '0', true, false.

	Poner un parámetro a null o no pasarlo es lo mismo.

	Ejemplo:

	// Abrir aviso.phpl en una nueva ventana, con tamaño 250x125, centrada horizontalmente
	// pero a 100 píxeles del borde superior.

	AbrirVentana('avisolegal.php', '_blank', 250, 125, null, 100);
*/
function AbrirVentana(url, target, width, height, left, top, resizable, scrollbars)
{
	if(typeof(url) == 'undefined' || url == null) url = '';
	if(typeof(target) == 'undefined' || target == null) target = '';

	if(typeof(width) == 'undefined' || width == null) width = 350;
	if(typeof(height) == 'undefined' || height == null) height = 350;

	if(typeof(window.screen) == 'undefined') {
		var sw = 800;
		var sh = 600;
	} else {
		var sw = window.screen.width;
		var sh = window.screen.height;
	}

	if(typeof(left) == 'undefined' || left == null) left = Math.round(0.5 * (sw - width));
	if(typeof(top) == 'undefined' || top == null) top = Math.round(0.5 * (sh - height));

	if(typeof(resizable) == 'undefined' || resizable == 'no' || !resizable) resizable = 0;
	else resizable = 1;

	if(typeof(scrollbars) == 'undefined' || scrollbars == 'yes' || !scrollbars) scrollbars = 1;
	else scrollbars = 1;

	var win = window.open(url, target, 'left=' + left + ',top=' + top + ',width=' + width + ',height=' + height + ',directories=0,location=0,menubar=0,resizable=' + resizable +',scrollbars=' + scrollbars + ',status=0,toolbar=0');
	win.focus();
}
