(function($) {
	
	$.fn.placeholder = function() {
		
		if (this[0] && 'placeholder' in document.createElement('input')) {
			return this;
		};

		function setPlaceholder($elem) {
			if ($elem.val() === '' || $elem.val() === $elem.attr('placeholder')) {
				$elem.addClass('placeholder').val($elem.attr('placeholder'));
			} else {
				$elem.removeClass('placeholder');
			};
		};

		$('form:has([placeholder])').submit(function() {
			$('.placeholder', this).val('');
		});

		$(window).unload(function() {
			$('.placeholder').val('');
		});

		return this.each(function() {
		
			var $input = $(this);
		
			if ($input.is(':password') || !$input.is(':input')) {
				return;
			};
		
			setPlaceholder($input);
		
			$input.focus(function() {
				if ($input.val() === $input.attr('placeholder')) {
					$input.val('').removeClass('placeholder');
				};
			}).blur(function() {
				setPlaceholder($input);
			});
		
		});
		
	};
	
})(jQuery);

$(function() {

	$("input").placeholder();

	var 	numAll		= 0,
			numBuried 	= 0,
			numFeatured = 0;

	$(".commentlist li").each(function() {

		$el = $(this);

		if ($el.hasClass("buried")) {
			$el.hide();
			numBuried++;
		} else if ($el.hasClass("featured")) {
			numFeatured++;
		}

		numAll++;

	});

	var featuredText = "<span class='featuredspan'>";
	var buriedText = "<span class='buriedspan'>";

	if (numAll > 0) {

		featuredText += "<em>" + numFeatured + "</em> featured!</span>";

		buriedText += numBuried + " buried <a href='#' id='buriedNote'>(show)</a></span>";

	}

	$("#comments").prepend(featuredText).append(buriedText);

	$("#buriedNote").click(function() {

		$("li.buried").slideToggle();
		return false;

	});

});
