jQuery(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  jQuery('#slickbox').hide();
 // shows the slickbox on clicking the noted link
  jQuery('a#slick-show').click(function() {
  jQuery('#slickbox').show('slow');
  return false;
  });
 // hides the slickbox on clicking the noted link
  jQuery('a#slick-hide').click(function() {
  jQuery('#slickbox').hide('fast');
  return false;
  });
 // toggles the slickbox on clicking the noted link
  jQuery('a#slick-toggle').click(function() {
  jQuery('#slickbox').slideToggle(400);
  return false;
  });
  // fuzzy timestamps
  jQuery('time.timeago').timeago();

  // change the search
  $("#selectsearch").change(function() {
  var action = $(this).val() == "drink" ? "drinks" : "users";
  $("#SearchForm").attr("action", "/" + action + "/search/");
  $("#SearchQ").attr("search","data[User][search]");
  $("#SearchQ").attr("name","data[User][search]");
  });

  // toggles user drinks & user comments on user profile page
  $('.user-latest-comments').hide();
  $('.user-latest-wall').hide();
	
  $('#tabs li').click(function() 
	{
		var $this = $(this);
	
	    if ($this.attr("id") == ('tab-drink')) 
		{
				
			$("#tab-drink").removeClass().addClass("active");
			$("#tab-comment").removeClass("active").addClass();
			$("#tab-wall").removeClass("active").addClass();
			
			$('.user-latest-cocktails').show();
			$('.user-latest-comments').hide();
			$('.user-latest-wall').hide();
	    } 
		else if ($this.attr("id") == ('tab-comment')) 
		{
	    		$("#tab-drink").removeClass("active").addClass();
			$("#tab-comment").removeClass().addClass("active");
			$("#tab-wall").removeClass("active").addClass();
	
			$('.user-latest-comments').show();
			$('.user-latest-cocktails').hide();
			$('.user-latest-wall').hide();
	   	} 
		else if ($this.attr("id") == ('tab-wall')) 
		{
	    		$("#tab-drink").removeClass("active").addClass();
			$("#tab-comment").removeClass("active").addClass();
			$("#tab-wall").removeClass().addClass("active");
	
			$('.user-latest-comments').hide();
			$('.user-latest-cocktails').hide();
			$('.user-latest-wall').show();
	   	} 
		else 
		{
                        $('.user-latest-cocktails').show();
			$('.user-latest-comments').hide();
			$('.user-latest-wall').hide();
	    }

    return false;

	});

// shows drink name in overlay on hover in the mydrinks widget
  $("#my-drinks img").hover(function() {
            $(this).next("p").animate({opacity: "show", top: "-75"}, "slow");
          }, function() {
            $(this).next("p").animate({opacity: "hide", top: "-85"}, "fast");
  });

// hides flash message
  setTimeout(function() {
    $('#flashMessage').fadeOut('slow');
  }, 3000); // <-- time in milliseconds

// hides alert message 
  setTimeout(function() {
    $('#alert').hide('slow');
  }, 10000); // <-- time in milliseconds

// adds http:// to url field so user doesnt forget

  //  Initialize auto-hint fields
        $('INPUT#UserWebsite').focus(function(){
	  if($(this).val() == '') {
	    $(this).val($(this).attr('title'));
	  }
            
        });
	


});

