//REPRODUCIR MUSICA DE FONDO EN LA WEB PARA INTERNET EXPLORER Y NETSCAPE/FIREFOX
var filename="musica/Waves.mid"; 
if (navigator.appName == "Microsoft Internet Explorer") 
   document.writeln ('<BGSOUND SRC="' + filename + '" loop=infinite>'); 
else if (navigator.appName == "Netscape") 
    document.writeln ('<EMBED SRC="' + filename + '" AUTOSTART=TRUE LOOP=TRUE hidden="true">'); 

//OJO CON LA HOJA DE ESTILO, SI SE PONE PADDING LEFT O RIGHT NO CUADRA IE CON NS
//MENÚ IZQUIERDA

//build or unhide submenu div...
function buildSubmenu(obj){
	
	//get common part of div id
	menuPath = obj.id.split('_');
	
	
	//unset mousout of parent menus and make sure they are visible...
	x = "div";
	for(i=0;i<menuPath.length;i++){
		x+= '_' + menuPath[i];
		if(document.getElementById(x)){
			if(tmr[x])
				window.clearTimeout(tmr[x]);
			document.getElementById(x).style.visibility = 'visible';
		}
	}
	
	//check if we have a submenu of the obj...
	if(submenu[obj.id]){
		//check if allready build...
		c = document.getElementById('div_' + obj.id);
		if(c){
			//unhide...
			c.style.visibility = 'visible';
			c.style.zIndex = last_zIndex++; 
		}else{
			//calc position of mouseover
			d = obj;
			if(d){
				//L_pos = d.offsetLeft + d.offsetWidth - 1;
				L_pos = d.offsetLeft; //Si queremos que salga a la derecha el menu hay que poner L_pos = d.offsetLeft + d.offsetWidth;
				T_pos = d.offsetTop + 18; 	//Elegimos que salga el menú 18px por debajo del menú principal
				while(d.offsetParent){
					d = d.offsetParent;
					L_pos+= d.offsetLeft;
					T_pos+= d.offsetTop;
				}
			}

			//patch first submenu to go right below the main buttons...
			/*if(obj.className.indexOf('menuItem') < 0){
				L_pos-= obj.offsetWidth;
				T_pos+= obj.offsetHeight;
			}*/
			
			//build new div
			subObj = document.createElement('div');
			subObj.id = 'div_' + obj.id;
			subObj.className = 'submenu';
			subObj.style.position = 'absolute';
			subObj.style.zIndex = last_zIndex++;
			subObj.style.width = menuWidth;
			subObj.style.top = T_pos;
			subObj.style.left = L_pos;
	
			//write div to the body...
			document.getElementsByTagName('body')[0].appendChild(subObj);	
			
			//build html for submenu
			content = "";
			m = submenu[obj.id];
			for(i=0;i<m.length;i++){
				//determin target
				if(!m[i][2]){
					tar = 'self';
				}else{
					//get javascript target (not tested yet)
					tar = "window.frames['"+tar+"']";
				}
				
				//make item
				content+= "<div onmouseout=\"hideSubmenu(this)\" onmouseover=\"buildSubmenu(this)\" "+ (m[i][1] ? "onclick=\""+tar+".location.href='" + m[i][1] + "'\" " : "") +"class=menuItem" + (i==0 ? 'First' : '') + " id=\"" + obj.id + "_" + i +"\">" + m[i][0] + "</div>";
				adj[i] = obj.id + "_" + i;
			}
			
			//insert new menu
			subObj.innerHTML = content;
			
			//make all just made div's the same width...
			for(i=0;i<adj.length;i++)
				document.getElementById(adj[i]).style.width = subObj.style.width;
		}
	}
}

//********************MENÚ DERECHA
function buildSubmenu2(obj){
	
	//get common part of div id
	menuPath = obj.id.split('_');
	
	
	//unset mousout of parent menus and make sure they are visible...
	x = "div";
	for(i=0;i<menuPath.length;i++){
		x+= '_' + menuPath[i];
		if(document.getElementById(x)){
			if(tmr[x])
				window.clearTimeout(tmr[x]);
			document.getElementById(x).style.visibility = 'visible';
		}
	}
	
	//check if we have a submenu of the obj...
	if(submenu[obj.id]){
		//check if allready build...
		c = document.getElementById('div_' + obj.id);
		if(c){
			//unhide...
			c.style.visibility = 'visible';
			c.style.zIndex = last_zIndex++; 
		}else{
			//calc position of mouseover
			d = obj;
			if(d){
				//L_pos = d.offsetLeft + d.offsetWidth - 1;
				//L_pos = d.offsetLeft - d.offsetWidth - 45;//MODIFICADO
				L_pos = d.offsetLeft - d.offsetWidth -16;//MODIFICADO
				T_pos = d.offsetTop - 1;
				while(d.offsetParent){
					d = d.offsetParent;
					L_pos+= d.offsetLeft;
					T_pos+= d.offsetTop;
				}
			}

			//patch first submenu to go right below the main buttons...
			/*if(obj.className.indexOf('menuItem') < 0){
				L_pos-= obj.offsetWidth;
				T_pos+= obj.offsetHeight;
			}*/
			
			//build new div
			subObj = document.createElement('div');
			subObj.id = 'div_' + obj.id;
			subObj.className = 'submenu';
			subObj.style.position = 'absolute';
			subObj.style.zIndex = last_zIndex++;
			//subObj.style.width = menuWidth;
			subObj.style.width = 105;
			subObj.style.top = T_pos;
			subObj.style.left = L_pos;
	
			//write div to the body...
			document.getElementsByTagName('body')[0].appendChild(subObj);	
			
			//build html for submenu
			content = "";
			m = submenu[obj.id];
			for(i=0;i<m.length;i++){
				//determin target
				if(!m[i][2]){
					tar = 'self';
				}else{
					//get javascript target (not tested yet)
					tar = "window.frames['"+tar+"']";
				}
				
				//make item
				content+= "<div onmouseout=\"hideSubmenu(this)\" onmouseover=\"buildSubmenu(this)\" "+ (m[i][1] ? "onclick=\""+tar+".location.href='" + m[i][1] + "'\" " : "") +"class=menuItem" + (i==0 ? 'First' : '') + " id=\"" + obj.id + "_" + i +"\">" + m[i][0] + "</div>";
				adj[i] = obj.id + "_" + i;
			}
			
			//insert new menu
			subObj.innerHTML = content;
			
			//make all just made div's the same width...
			for(i=0;i<adj.length;i++)
				document.getElementById(adj[i]).style.width = subObj.style.width;
		}
	}
}




//********************
//hide a submebu div
function hideSubmenu(obj){
	//get common part of div id
	closePath = obj.id.split('_');

	//hide path
	x = "div";
	for(i=0;i<closePath.length;i++){
		x+= '_' + closePath[i];
		if(document.getElementById(x))
			tmr[x] = window.setTimeout("document.getElementById('"+x+"').style.visibility = 'hidden';",100);
		//The timeout above is needed for MSIE browsers... Or else the menu's will disapear on EVERY mousout!!!
		//Please get a normal browser like Firefox, Mozilla or Opera!!
	}
}

//add an menu item to the config array (called in the config lines)
function menuItem(txt,url,tar){
	return new Array(txt,url,tar);
}

//*** Now a patch for MSIE lag of CSS2 compliance!!
if(navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('Opera')==-1){
	document.onmouseover = function(){
		obj = event.srcElement;
		if(obj.className == 'menuItem' || obj.className == 'menuItemFirst')
			obj.className+='Over';
	}
	document.onmouseout = function(){
		obj = event.srcElement;
		if(obj.className == 'menuItemOver' || obj.className == 'menuItemFirstOver')
			obj.className = obj.className.substring(0,(obj.className.length - 4));
	}
}
//*** End of msie patch

