$(function(){


// ** Header ***********************************


	// Seteamos el dropDown
	$("#header .dropdown").hover(function(){
		$(this).find("ul").slideDown("fast");
	},
	function(){
		$(this).find("ul").stop('false','true').fadeOut("fast");
	});
	
	// Seteamos el aside
	$("#nav ul.dropdown li ul").css("width", "0");
	$("#nav ul.dropdown").hover(function()
	{
		$("ul", this).show().animate(
		{
			width: 200
		},"fast");

	}, function(){
		$("#nav ul.dropdown li ul").stop('false','true').fadeOut("fast", function(){ $(this).css("width", "0") });
	});


// ** Textarea ***********************************


	var textarea = $("#textarea");
	
	// Activamos modales genéricos
	$.fn.nyroModal.settings.processHandler = function(settings) { settings.title = null; }
	$("a.modal", textarea).nyroModal({
		bgColor: '#00535F',
		contentError: 'Actualmente este contenido no está disponible.<br />Por favor, intente más tarde.<br /><a href="#" class="nyroModalClose">cerrar</a>',
		gallery: 'gal',
		closeButton: '<a href="#" class="nyroModalClose" id="closeBut"></a>',
		minWidth: 300,
  		minHeight: 270
	});
	
	// Lista de eventos
	var program = $("#program", textarea);
	
	$(".row:odd", program).addClass("odd");
	$(".fm .links", program).hide();
	$(".fm", program).hover(function()
	{
		$(this).children(".links").hide().show("fast");
		$(this).parent().find(".fi").animate({
			left: 220
		}, "fast");
		
	}, function()
	{
		$(this).children(".links").stop('false','true').hide("normal");
		$(this).parent().find(".fi").stop('false','true').animate({
			left: 125
		}, "normal");
	});
	
	// Iniciammos tooltips
	$(".tooltip", textarea).each(function()
	{
		if ( $(this).hasClass("north") )
			var grav = "n";
		if ( $(this).hasClass("east") )
			var grav = "e";
		if ( $(this).hasClass("west") )
			var grav = "w";
		if ( $(this).hasClass("south") )
			var grav = "s";
		$(this).tipsy(
		{
			fade: true,
			gravity: grav
		});
	});

});
