/* Default value for Input Boxes & Textareas.
 *
 * Populates a "default" text as specified by an element's "_default" attribute.
 *
 * Matthew Knight, (matt@reconstrukt.com) August 2008:
 * - on the couch
 * - Eden asleep
 * - windows open
 * - rained a while ago
 *

Sample usage:
 
	$(document).ready(function(){

		// Initialise INPUT or TEXTAREA element(s) with the defaults
		$("input[_default], textarea[_default]").inputDefault(myOptions);

	});
 
 */
jQuery.fn.inputDefault = function(o){

	return this.each(function(){
		
		var inputConfig = {			
			color: '#ababab'
		};		
		jQuery.extend(inputConfig, o);
	
		/*
		 *	Bind some events to the input textbox
		 */
		
		var fld = $(this);
		var def = fld.attr('_default');
		var col = fld.css('color');
		fld.blur(function(){
			if (fld.val() == '') {
				fld.css('color', inputConfig.color).val(def);
			}
		})
		.focus(function(){
			if (fld.val() == def) {
				fld.css('color', col).val( '' );
			}
		})
		.blur();
	});
};
