/*
 * Focus Label - jQuery plugin
 * written by stenehall
 * http://stenehall.github.com
 *
 * Licensed under something...
 *
 *
 * Usage:
 *
 * Initialize the script with some options.
 ***********************************

	jQuery('#id').focuslabel();


 *
 * No idea if it works on any browser except FF3.6 on OS X 10.6
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */

/*global jQuery */

jQuery.fn.focuslabel = function (options) {

	// default configuration properties
	var defaults = {

	};
	options = jQuery.extend(defaults, options);

	function doIt(that) {
		var id = that.id;
		if (id == "")
		{
			id = jQuery(that).attr('name');
			jQuery(that).attr('id', id);
		}
		var label = jQuery('label[for="'+id+'"]');
		
		jQuery(label).addClass('focuslabel');
		jQuery(that).addClass('focuslabel');
		jQuery(that,label).focus(function() {
			jQuery('span.label',label).fadeOut();
		});
		jQuery(that).blur(function(){
			if (jQuery(that).attr('value') == "")
			{
				jQuery('span.label',label).fadeIn();
				
			}
		});
	}

	jQuery(this).each(function() {
		doIt(this);
	});

};
