var ec_tiempoApertura = 500;
var ec_tiempoFundido = 500;
var ec_alturaNavegador;
var ec_alturaInicial = 0;
var ec_alturaMaxima = 0;

$(function(){
	
	var nav = $("#nav");
	var drops = nav.find(".drop");
	ec_alturaNavegador = nav.height();
	nav.css({height: "auto"});
	
	for (var i=0; i<drops.length; i++){
		if ($(drops[i]).height() > ec_alturaMaxima){
			ec_alturaMaxima = $(drops[i]).height();
		}
	}	

	var navegador = $(".navegador"); 
	
	ec_alturaInicial = navegador.height();
	ec_alturaMaxima += navegador.height();
	
	if (! $.browser.msie){
		ec_alturaMaxima += parseInt(drops.css("margin-bottom"),10);
	}
	
	nav.hover(
			function(){
				
				navegador.stop(true).delay(350).animate(
						{height:  ec_alturaMaxima },
						ec_tiempoApertura);
				
				drops.stop(true)
				.delay(350)
				.removeAttr("style")
				.hide()
				.css("opacity",0)
				.show(ec_tiempoApertura,
						function(){
							drops.fadeTo(ec_tiempoFundido,1
							);
						}						
				);
				}
			,
			function(){
				drops.stop(true);
				navegador.stop(true);
				var altura = navegador.height();
				navegador.css("height",altura);					
				drops.fadeOut(ec_tiempoFundido, 
						function(){	
							if (altura > ec_alturaNavegador){
								navegador.animate({"height" : ec_alturaNavegador},
									{
										duration: ec_tiempoApertura
										,
										complete: function(){
											navegador.css({height : "auto"});
										}
									}
								);
							}
						}
				);
			}
			);			
	
});
