window.addEvent('domready', function() {
	
window.Laminova = window.Laminova || {}; 

/* codigo que inicializa menœ horizontal en el tope de la pagina */

var myMenu = new MenuMatic({id:'nav_root-sf'});  

/*  codigo para el control de los pulldowns de direcci—n, noticias y links rapidos */
	
	noticias = new Array();
	ocultaNoticias = new Array();
	ocultaNoticias[0]=0;
	ocultaLinksRapido = new Array();
	ocultaLinksRapido[0]=0;
	ocultaDireccion = new Array();
	ocultaDireccion[0]=0;
		
		
	function ocultarDireccion()
	{			
		var elementocultarDireccion = $$('#addressholder')[0];
		elementocultarDireccion.set('tween', {duration: 'short'});
		elementocultarDireccion.tween('height', 22);
		ocultaDireccion[0]=1;
		
		$('simbolo').setStyle("background-position", "0px -10px");

/*
		var morph = new Fx.Morph($('simbolo'));
		morph.start({ color: '#ffd53a'});
*/
			
		return false; // alternative syntax to stop the event		
	}
	window.ocultarDireccion = ocultarDireccion;	
	
	function ocultar(pixel, elemento, oculta)
	{	
		var elementOcultar = $$(elemento)[0];
		elementOcultar.set('tween', {duration: 'short'});
		elementOcultar.tween('height', pixel);
		oculta[0]=1;
		
		if (elemento == '#addressholder')
		{
		$('simbolo').setStyle("background-position", "0px -10px");
		
/*
			var morph = new Fx.Morph($('simbolo'));
			morph.start({ color: '#FFD53A'});
*/
		}
		
		return false; // alternative syntax to stop the event	
	}
	
	window.Laminova.ocultar = ocultar;
	
	function mostrar(pixel, elemento, oculta)
	{
		
		var elementMostrar = $$(elemento)[0];
		elementMostrar.set('tween', {duration: 'long'});
		elementMostrar.tween('height', pixel);
		//otherEl.erase('style');
		oculta[0]=0;
		
		if (elemento == '#addressholder')
		{
			$('simbolo').setStyle("background-position", "0px 0px");
/*
				
			var morph = new Fx.Morph($('simbolo'));
			morph.start({ color: '#CCC9BF'});
*/
		}
		
		return false; // alternative syntax to stop the event	
					
	}	
	
	window.Laminova.mostrar = mostrar;	
	var altoNoticias = 148;
	//var hijo = $('news').getFirst('div');
	//if(hijo){
	//	altoNoticias = hijo.getSize().y;	
	//}
	
	$$('#news h3').addEvent('click', function(e)
	{
				
		if (ocultaNoticias[0]==1)
		{
			e.stop(); 
			mostrar(altoNoticias,'#news',ocultaNoticias);
		}
		else
		{
			 ocultar(22,'#news',ocultaNoticias);
		}
	});	
	
	$$('#linksRapidos h3').addEvent('click', function(e)
	{
		if (ocultaLinksRapido[0]==1)
		{
			e.stop(); 
			mostrar(148,'#linksRapidos div', ocultaLinksRapido);
		}
		else
		{
			ocultar(22,'#linksRapidos div', ocultaLinksRapido);
		}

	});
	
	$$('#direccion').addEvent('click', function(e)
	{
		
		if (ocultaDireccion[0]==1)
		{
			e.stop(); 
			mostrar(148,'#addressholder', ocultaDireccion);
		}
		else
		{	
			e.stop();
			ocultar(22,'#addressholder', ocultaDireccion);
		}

	});
	
		$$('topmenu').addEvents({
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.set('tween', {
				duration: 1000,
				transition: Fx.Transitions.Bounce.easeOut // This could have been also 'bounce:out'
			}).tween('height', '150px');
		},
		'mouseleave': function(){
			// Resets the tween and changes the element back to its original size
			this.set('tween', {}).tween('height', '20px');
		}
	});

	

	
	
	
});
