/**
 * Simple Plugin for toggling input fields
 *
 * Usage:
 *	$('input.searchTerm').toggleValue();
 *
 * Example Usage with custom class:
 *	$('input.searchTerm').toggleValue({ toggleClass: 'selected' });
 *
 * @author Marcel Eichner // Ephigenia <love@ephigenia.de>
 * @since 2009-06-22
 */
(function($){
	
	$.fn.extend({
		toggleValue: function (options) {
			// iterate over selected elements
			return this.each(function() {
				// default options
				defaults = {
					value: $(this).val(),
					toggleClass: 'active'
				};
				var options = $.extend({}, defaults, options);
				$(this).data('toggleValueOptions', options);
				
				// add focus and blur behavior
				$(this).focus(function() {
					if ($(this).val() == options.value) {
						$(this).val('').toggleClass(options.toggleClass);
					}
				}).blur(function() {
					if ($.trim($(this).val()) == '') {
						$(this).val(options.value).toggleClass(options.toggleClass);
					}
				});
				
			});
		} // toggleValue
	}); // extend

})(jQuery);
