//Perquè un iframe faci que menu es superposi a SELECTS, APPLETS, etc.
//He afegit aquestes línies..., ja que Opera es mostra com a "msie" en l'userAgent, i posa variabe "ie" a true. Com Opera fa malament lo dels iframes, cal detectar-ho.
var agt=navigator.userAgent.toLowerCase();
var mac = (agt.indexOf("mac")!=-1);
var ie = (agt.indexOf("msie") != -1); 
var mac_ie = mac && ie;
var op = (navigator.userAgent.indexOf("Opera")!=-1);
var calIframePerTaparSelects = (ie && !mac_ie && !op)



//Francesc Roca: 14/10/2005. Codi propi pel funcionament del menus emergents de nivell2
var timeOn;
var showed="";

function show_menu(opcio){
	//Netejem timeout
	clearTimeout(timeOn);

	if (showed!="") {
		hide_menu_efectiu(showed);
	}

	showed=opcio;


	var DivRef = document.getElementById('divMenu'+opcio);
	var DivMenuN1 = document.getElementById('opcionsNivell1');
	var IfrRef = document.getElementById('menuN1ifr');

	try {
		//Intentem mostrar la div amb les subopcions 
		//Pot ser que no en tingui, com la home, per això fem try

		if (DivMenuN1 != null) {
			DivRef.style.top = ubicarYdunObjecte(DivMenuN1)+DivMenuN1.scrollHeight+'px';
			DivRef.style.width = DivMenuN1.offsetWidth-2+'px';
			DivRef.style.margin='0px';
		}
		DivRef.className = 'divMenuN2Visible';

		//Perquè un iframe faci que menu es superposi a SELECTS, APPLETS, etc.
		//Ara cal mostrar l´iframe per sota de la div del menú
		if (calIframePerTaparSelects) {
			//Fiquem un zIndex aquí, ja que no agafa be el z-index del css!!!
			DivRef.style.zIndex = 100;
			DivRef.style.display = "block";
			
			IfrRef.style.width = DivRef.offsetWidth;
			IfrRef.style.height = DivRef.offsetHeight;
			IfrRef.style.top = DivRef.style.top;
			IfrRef.style.zIndex = DivRef.style.zIndex - 1;
			IfrRef.style.display = "block";
		}

	} catch(errorinfo) {
		//No existeix menú per mostrar
	}
}



function hide_menu(opcio){
	clearTimeout(timeOn);
	timeOn = setTimeout('hide_menu_efectiu(\''+opcio+'\');',100);
}

function hide_menu_efectiu(opcio){
	try {
		//Intentem ocultar la div amb les subopcions 
		//  Pot ser que no en tingui, com la home, per això fem try
		document.getElementById('divMenu'+opcio).className = 'ocult';
		//Perquè un iframe faci que menu es superposi a SELECTS, APPLETS, etc.
		//Ara cal amagar l´iframe
		if (calIframePerTaparSelects) {
		    var IfrRef = document.getElementById('menuN1ifr');
		    IfrRef.style.display = "none";
		}

	} catch(errorinfo) {
	  //No existeix menú per ocultar
	}

	clearTimeout(timeOn);
	showed="";
}




function menuOnMouseMove() {
	clearTimeout(timeOn);
}

function menuOnMouseOut(opcio) {
//	if ambtimeout {
		timeOn = setTimeout('hide_menu_efectiu(\''+opcio+'\')', 100);
//	} else {
//		hide_menu_efectiu(opcio);
//	}
}


