jQuery(function ($) {
	
    $(".nav a").click(function () {
      $(".active").removeClass("active");
      $(this).addClass("active");
    });
	$("a.btn").click(function () {
      $(".active").removeClass("active");
      $(this).addClass("active");
    });

    $.gCalReader({
		feedUri: 'http://www.google.com/calendar/feeds/enf69qbpld0ar8rklq1i6s2a94@group.calendar.google.com/public/full',
		maxresults: 6, displayCount: 0
	});

	$("input").focus(function(srcc)
	    {
	        if ($(this).val() == $(this)[0].title)
	        {
	            //$(this).removeClass("defaultTextActive");
	            $(this).val("");
	        }
	});
	$("input").blur(function()
	    {
	        if ($(this).val() == "")
	        {
	            //$(this).addClass("defaultTextActive");
	            $(this).val($(this)[0].title);
	        }
	});
	$("input").blur();
	$('.bubbleDown').each(function () {
        var distance = -20;
        var time = 250;
        var hideDelay = 500;
		var startHeight=260;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
		
		var trigger = $('.trigger', this);
        var info = $('.popdown', this).css('opacity', 0);

		$([trigger.get(0), info.get(0)]).click(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown){hide_info();}
			else{show_info();}
		});
		
		$(this).hoverIntent({
			interval: 150, // milliseconds delay before onMouseOver
			over: resetDelay, 
			timeout: 700, // milliseconds delay before onMouseOut
			out: hide_info
		});
        
		function resetDelay(){
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
        }
        
		function hide_info(){
                beingShown = false;

                info.css({
                    top: startHeight-distance,
                    display: 'block'
                }).animate({
                    top: '-=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = false;
                });
        }
		
		function show_info(){
                beingShown = true;

                info.css({
                    top: startHeight,
                    display: 'block'
                }).animate({
                    top: '-=' + distance + 'px',
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                }); 
        }
    });
});
