(function( $ ) {
  $.fn.labels = function( options ) {

    var settings = {};

    return this.each(function() {

      if ( options ) {
        $.extend( settings, options );
      }

			// Each label and input is grouped together by wrapping it in a <p> tag
			// Iterate through the <p> tags in the form and where there is a label 
			// set the value of the input with the value of the label
			$(this).find('p').each(function() {
				var label = $(this).children('label').text();

				var inputType = $(this).children('label').next();

				if (inputType[0]) {
					$(this).children('label').next().val(label);
					
					$(this).children('label').next().click(function() {

						if ($(this).val() == label) {
							$(this).val('');
						}
						
						$(this).blur(function() {
							if ($(this).val() == '') {
								$(this).val(label);
							}
						});
						
					});
				}
				
			});

    });

  };
})( jQuery );
