/**
 * JS
 * @author Darío Ruellan <druellan@ecimtech.com>
 * @copyright ecimTech 2009
 */

$(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 li.dropdown ul").css("width", "0");
	$("#nav ul li.dropdown").hover(function()
	{
		$("ul:first", this).show().animate(
		{
			width: 200
		},"fast");

	}, function(){
		$("ul:first", this).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: '#000000',
		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
	});

	// Activamos modales en el aside
	$("#nav a.modal").nyroModal(
	{
		bgColor: '#000000',
		contentError: 'Actualmente este contenido no está disponible.<br />Por favor, intente más tarde.<br /><a href="#" class="nyroModalClose">cerrar</a>',
		closeButton: '<a href="#" class="nyroModalClose" id="closeBut"></a>',
		minWidth: 700,
  		minHeight: 600
	});

	// Iniciammos tooltips
	$(".tooltip").each(function()
	{
		var grav = "s";
		if ( $(this).hasClass("north") )
			grav = "n";
		if ( $(this).hasClass("east") )
			grav = "e";
		if ( $(this).hasClass("west") )
			grav = "w";
		if ( $(this).hasClass("south") )
			grav = "s";
		$(this).tipsy(
		{
			fade: true,
			gravity: grav
		});
	});

});
