/*
 * jQuery Labelise Plugin v1.0
 * 
 * Copyright (c) 2008 Robert O'Rourke
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

;(function($) {
	$.fn.inline = function(){
		var $label = jQuery(this);
		var $input = jQuery("#" + $label.attr("for"));
		$label.addClass("hidden");
		var labeltext = $label.text();
		$input.focus(function(){
			if ( $input.val() == labeltext ) {
				jQuery(this).removeClass("islabel").val("");
			}}).blur(function(){
			if ( $input.val() == '' || $input.val() == labeltext ) {
				jQuery(this).addClass("islabel").val(labeltext);
			}}).blur().parents("form").submit(function(){
			if ( $input.val() == '' || $input.val() == labeltext ) {
				jQuery(':input:first',this).focus();
				return false;
			}
		});
	};
})(jQuery);