$.fn.inlineInputs = function(options) {
	var formId = $(this).attr('id');
	var defaults = {
		inputWidth: 270,
		colorRequired: '#900',
		colorOptional: '#999',
		colorInput: '#000'
	};
	
	options = $.extend({}, defaults, options);
	
	$('#' + formId + ' label').each( function(i) {
		var label = $(this);
		var span = $(this).children('span');
		var input = $(this).next('input, textarea');
		
		if( input.attr('type') == 'text' || input.attr('type') == 'textarea' ) {
			label.html(label.html().replace(': ',''));
			if( span.html() != null ) {
				$('span',label).remove();
				input.data('required',true);
				if(input.val() == "") {
					input.css("color",options.colorRequired);
				}
			} else {
				input.data('required',false);
				if(input.val() == "") {
					input.css("color",options.colorOptional);
				}
			}
			
			if(input.val() == "") {
				input.val(label.html());
			}
			input.css("width",options.inputWidth + "px");
			label.css("display", "none");
		}
	});
	
	$('input, textarea').focus( function () {
		if( $(this).val() == $(this).prev('label').html() ) {
			$(this).css('color',options.colorInput);
			$(this).val('');
		};
	}).blur(function() {
		if($(this).val() == '') {
			if( $(this).data('required') ) {
				$(this).css('color',options.colorRequired);
			} else {
				$(this).css('color',options.colorOptional);
			}
			$(this).val($(this).prev('label').html());
		};
	});
	
	$(this).submit( function() {
		$('#' + formId + ' label').each( function(i) {
			var label = $(this);
			var input = $(this).next('input, textarea');
			
			if( input.attr('type') == 'text' || input.attr('type') == 'textarea' ) {
				if(input.val() == input.prev('label').html()) {
					input.val("");
				}
			}
		});
	});
};

