/*
$(document).ready(function() {
	$('input[type="text"]').focus(function() {
		$(this).prev('label').addClass('focus');
	});
});
*/			


(function($) {
	function dimLabel() {
		$(this).prev('label').addClass('focus');
	}

	function hideLabel() {
		var input = this;
		setTimeout(function() {
			if (!$(input).val()) {
				$(input).prev('label').css('visibility', '');
			} else {
				$(input).prev('label').css('visibility', 'hidden');
			}
		}, 0);
	};

	function resetField() {
		if (!$(this).val()) {
			$(this).prev('label').css('visibility', '');
		}
		$(this).prev('label').removeClass('focus');
	};

	$('input, textarea').live('keydown', hideLabel);
	$('select').live('change', hideLabel);

	$(function() {
		$('input, textarea').focus(dimLabel);
		$('input, textarea').blur(resetField);
		$('input, textarea').each(hideLabel);
	});

})(jQuery);




/*
(function($) {
    function toggleLabel() {
        var input = this;
        setTimeout(function() {
        var def = $(input).attr('title');
        if (!$(input).val() || ($(input).val() == def)) {
            $(input).prev('span').css('visibility', '');
            if (def) {
                var dummy = $('<label></label>').text(def).css('visibility','hidden').appendTo('body');
                $(input).prev('span').css('margin-left', dummy.width() + 3 + 'px');
                dummy.remove();
            }
        } else {
            $(input).prev('span').css('visibility', 'hidden');
        }
        }, 0);
    };

    function resetField() {
        var def = $(this).attr('title');
        if (!$(this).val() || ($(this).val() == def)) {
            $(this).val(def);
            $(this).prev('span').css('visibility', '');
        }
    };

    $('input, textarea').live('keydown', toggleLabel);
    $('select').live('change', toggleLabel);

    $(function() {
        $('input, textarea').blur(resetField);
        $('input, textarea').each(toggleLabel);
    });

})(jQuery);
*/
