(function($) {
	
	$.fn.defaultValue = function() {
		
		// Scope
		var elements = this;
		var args = arguments;
		var c = 0;
		
		return(
			elements.each(function(i) {				
				
				// Default values within scope
				var field = $(this);
				var promptField = field;
				var promptText = null;
				var promptColour = null;
				var promptStyle = null;
				
				if (args.length > c) {
					
					// Get the arguments
					promptText = args[c++];
					if (args.length > c) promptColour = args[c++];
					if (args.length > c) promptStyle = args[c++];
					
					// Replace the field with a text field to use for prompting
					promptField = $('<input type="text"></input>');
					promptField.attr('title', field.attr('title'));
					promptField.attr('class', field.attr('class'));
					if (promptColour != null) promptField.css("color", promptColour);
					if (promptStyle != null) promptField.css("font-style", promptStyle);
					field.after(promptField);
					if (field.val() == "") {
						field.hide();
					} else {
						promptField.hide();
					}
					
					// Bind the focus event to the prompt field
					promptField.val(promptText).focus(function() {
						if(promptField.val() == promptText) {
							promptField.hide();
							field.show();
							field.focus();
						}
					});
					
					// Bind the blur event to the real field
					field.blur(function() {
						if(field.val() == "") {
							field.hide();
							promptField.show();
						}
					});
					
				}
				
			})
		);
	}
})(jQuery)