/*

fieldDefaults by Ralph Joson
Date Created: August 21, 2008

*/

jQuery.fn.fieldDefaults = function() {
this.each(function() {
				   
		// if node is not an input or textarea, skip
		if((this.nodeName.toLowerCase() != "input"
			&& this.nodeName.toLowerCase() != "textarea")
			// also skip the following types of inputs:
			|| this.type == "checkbox"
			|| this.type == "radio"
			|| this.type == "image"
			|| this.type == "reset"
			|| this.type == "submit")
		{
			return;
		}
		
		if( $(this).val() == '' ) {
			$(this).val( $(this).attr("title") );
		}

		
		var $this = $(this);
		
		$this.focus(
			function()
			{
				if( $(this).val() == $(this).attr("title") ) {
					$(this).val('');
				}
			}
		)
		.blur(
			function()
			{
				if( $(this).val() == '' ) {
					$(this).val( $(this).attr("title") );
				}
			}
		);
	
	});
	return this;
}