// JavaScript Document
	var menu_accordion;
	var menu_array;
	
	//=================================================================================================
	
	function menu_llenar() {
		var div_todo = $("divMenu");
		var divTag_menu = new Element('div');
		var divTag_sub = new Element('div');
		var divTag_aux = new Element('div');
		var aTag;
		var count = 0;
		
		div_todo.empty();
		for (i=0; i<menu_array.length; i++) {
			
			divTag_menu = new Element('div');
			aTag = new Element('a', {'id':'m_'+i, 'html' : menu_array[i].nombre});
			
			if ( menu_array[i].submenu == 0 ) {
				if ( (div_todo.getChildren().length>0)&&(divTag_sub.getChildren().length>0) ) {
					div_todo.getLast().set('class','navSection');
					div_todo.getLast().getLast().set('href', 'javascript:click_menu('+count+', true)');
					divTag_sub.inject(div_todo);
				} 
				divTag_sub = new Element('div', {'class' : 'navItem'});
				
				aTag.set('href', 'javascript:click_menu('+i+', false)');
				aTag.set('class', 'lmenu'); 
				
				aTag.inject(divTag_menu);
				divTag_menu.inject(div_todo);
				count=i;
				
			} else {
				divTag_aux = new Element('div');
				
				aTag.set('href', 'javascript:click_sub('+i+')'); 
				aTag.set('class', 'lsub'); 
				
				aTag.inject(divTag_aux);
				divTag_aux.inject(divTag_sub);
				
			}
		}
		if ( divTag_sub.getChildren().length > 0 ) {
			div_todo.getLast().set('class','navSection');
			div_todo.getLast().getLast().set('href', 'javascript:click_menu('+count+', true)');
			divTag_sub.inject(div_todo);
		} 
		
		menu_accordion = new Fx.Accordion(div_todo, 'div.navSection', 'div.navItem', {
			opacity: false,
			display:-1,
			onActive: function(toggler, element){
				toggler.setStyle('font-weight', 'bold');
			},
			onBackground: function(toggler, element){
				toggler.setStyle('font-weight', 'normal');
			}
		});
		menu_accordion.cancel();
		
	}
	
	//=================================================================================================
	
	function click_menu(num, boo) {
		//if ( typeof(timeout) != "undefined" ) {
			clearTimeout(timeout);
		//}
		bold_change(num, "menu");
		if ( !boo ) {
			menu_accordion.display(-1);
		}
		if ( typeof(edicion) == "undefined" ) {
			click_url(num);
		}
	}
	
	//=================================================================================================
	
	function click_sub(num) {
		//if ( typeof(timeout) != "undefined" ) {
			clearTimeout(timeout);
		//}
		bold_change(num, 'sub');
		if ( typeof(edicion) == "undefined" ) {
			click_url(num);
		}
	}
	
	//=================================================================================================
	
	function click_url(num) {
		efecto_tela(false);
		//$('log').set('text', menu_array[num].url+"?id="+menu_array[num].id+"&excepcion="+menu_array[num].excepcion);
		if ( menu_array[num].url != ' ') {
			if ( menu_array[num].id == 12 ) {
				window.open('/wpg', '_blank');
			} else {
				new Request.HTML({
					evalScripts: true,
					method: 'get',
					update: 'contenido',
					url: menu_array[num].url+"?id="+menu_array[num].id+"&excepcion="+menu_array[num].excepcion, 
					onComplete: function() {  }
				}).send();
			}
		}	
	}
	
	//=================================================================================================
	
	function bold_change(num, seccion) {
		var link_menu = $("divMenu").getElementsByTagName("A");
		
		if (seccion == "menu") {
			$$('.lmenu').each(	function(el){
				el.set('styles', {'fontWeight': 'normal','color': '#b3b3b3'});
			});
			$$('.lsub').each(	function(el){
				el.set('styles', {'fontWeight': 'normal','color': '#b3b3b3'});
			});
		}
		
		if (seccion == "sub") {
			$$('.lsub').each(	function(el){
				el.set('styles', {'fontWeight': 'normal','color': '#b3b3b3'});
			});
		}
		$('m_'+num).set('styles', {'fontWeight': 'bold','color': '#d6de23'});
	}
	
	
	
