$(function($) {
    
	// Clone HTML5's placeholder attribute functionality
	$('input').each(function() {
		if ($(this).attr('placeholder')) {
			// Store the placeholder text and then set the element's value
			$(this).data('placeholder', $(this).attr('placeholder'));
			
			if (!$(this).val())
			    $(this).val($(this).data('placeholder')).addClass('placeholder');

            $(this).attr('placeholder', '');

			// Handle the removal/addition of the placeholder text on focus/blur
			$(this).focus(function() {
				if ($(this).val() == $(this).data('placeholder')) {
					$(this).val('').removeClass('placeholder');
				}
			}).blur(function() {
				if ($(this).val().match(/^\s*$/)) {
					$(this).val($(this).data('placeholder')).addClass('placeholder');
				}
			});
		}
	});
	
	var hideTimer, showTimer, categories = $('#page-nav div.categories');
	categories.mouseover(prepareToShowCategories).mouseout(prepareToHideCategories).click(showCategories);
	
	function prepareToShowCategories() {
	    window.clearTimeout(hideTimer);
	    window.clearTimeout(showTimer);
	    
	    showTimer = window.setTimeout(showCategories, 200);
	    return false;
	}
	
	function prepareToHideCategories() {
        window.clearTimeout(hideTimer);
	    window.clearTimeout(showTimer);
	    
	    hideTimer = window.setTimeout(hideCategories, 200);
	    return false;
	}
	
	function showCategories() {
	    categories.addClass('categories-visible');
	}
	
	function hideCategories() {
	    categories.removeClass('categories-visible');
	}
});
