/*
 * jQuery InputHint Plugin 1.0.0
 * Hover the associated label element over a text input field
 * to provide an input example.  The label is hidden when 
 *
 * e.g.
 *  $('input#id').inputHint();
 *
 */
 (function($) {
 	$.fn.inputHint = function() {
    
    	return this.each(function() {
      
	    	var $this = $(this);
	      	var label = $('form.validate label[@for=' + $this.attr('id') + ']');
	      	
	      	/* display the hint by default */
	      	label.show();
	      	
	      	/* hide the label onclick and place the focus on the element */
	      	label.click(function() {
	      		$(this).hide();	
	      		$('#' + $(this).attr('for')).focus();
	      	});
	      	
	      	/* Hide the label when the input is focused on */
	      	$this.focus(function() {
	      		$('form.validate label[@for=' + $(this).attr('id') + ']').hide();
	      	});
	      	
	      	/* Make the example text reappear if the input is blank on blurring. */
	      	$this.blur(function() {
	        	if ($(this).val() == '') {
	        		$('form.validate label[@for=' + $(this).attr('id') + ']').css('display', 'inline');
	      		}
	      	});
   		});
 	};
})(jQuery);