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'});  
	
	ocultaNoticias = new Array();
	ocultaNoticias[0]=0;
	ocultaLinksRapido = new Array();
	ocultaLinksRapido[0]=0;
	ocultaDireccion = new Array();
	ocultaDireccion[0]=0;
		
	ocultarNoticias.delay(0);
	ocultarLinksRapidos.delay(0);
	ocultarDireccion.delay(0);
		
	function ocultarNoticias()
	{
		var elementocultarNoticias = $$('#news')[0];
		elementocultarNoticias.set('tween', {duration: 'short'});
		elementocultarNoticias.tween('height', 22);
		ocultaNoticias[0]=1;
				
		return false; // alternative syntax to stop the event			
	}
	
	function ocultarLinksRapidos()
	{
		var elementocultarLinksRapidos = $$('#linksRapidos')[0];
		elementocultarLinksRapidos.set('tween', {duration: 'short'});
		elementocultarLinksRapidos.tween('height', 22);
		ocultaLinksRapido[0]=1;
				
		return false; // alternative syntax to stop the event			
	}
		
	window.ocultarDireccion = ocultarDireccion;	
	
	function ocultarDireccion()
	{			
		var elementocultarDireccion = $$('#addressholder')[0];
		elementocultarDireccion.set('tween', {duration: 'short'});
		elementocultarDireccion.tween('height', 22);
		ocultaDireccion[0]=1;
		
		//$('simbolo').setStyle("background-position", "0px 0px");
		
		
			var morph = new Fx.Morph($('simbolo'));
			morph.start({ color: '#CCC9BF'});
		
					
		return false; // alternative syntax to stop the event		
	}
			
	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 0px");
		
			var morph = new Fx.Morph($('simbolo'));
			morph.start({ color: '#CCC9BF'});
			
		}
		
		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;	
	//}
	
	//console.log(altoNoticias);
	$$('#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', ocultaLinksRapido);
		}
		else
		{
			ocultar(22,'#linksRapidos', ocultaLinksRapido);
		}

	});
	
	$$('#direccion').addEvent('click', function(e)
	{
			
		if (ocultaDireccion[0]==1)
		{
			e.stop(); 
			$('addressholder').setStyle('z-index',22);
			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');
		}
	});

	
});

