(function($) {
	// from Mark Pilgrim
	// Dive into HTML5
	function supports_input_placeholder() { var i = document.createElement('input'); return 'placeholder' in i; }
	
	$.fn.placeholder = function(options) {
		
		// defaults
		var phClass		= 'placeholder',
			attr 		= 'placeholder';
		
		
		//console.log(options);
		
		if(options) {
			phClass		= (options.phClass) ? options.phClass : phClass;	// a class to add to elements carrying placeholder text
			attr		= (options.attr) ? options.attr : attr;			// attribute to pull text from
		}
		
		// if the browser has no placeholder support, or
		// if they went with a different attribute name let's mimic it
		if(!supports_input_placeholder() || attr != 'placeholder') {
			this.each(function() {
				// self-reference
				var $target = $(this);
				
				// get its placeholder value
				var placeholder = $target.attr(attr);
				
				// if it has a placeholder value
				if(placeholder != undefined) {
					$target.val(placeholder).addClass(phClass);
					$target.focus(function() {
						if ($target.val() == placeholder) $target.val('').removeClass(phClass);
					}).blur(function() {
						if ($target.val() == '') $target.val(placeholder).addClass(phClass);
					});
				}
			});
		}
		
		// support chaining
		return this;
	}
	
})(jQuery)
