/**
 * siteswift Watermark for jQUery
 * @Author: Christian Koban, 14.01.2011
 * @USAGE:
		$("#MyID").swWatermark({
			value:	"Suche...",
			emptyClass:	"swWatermark"
		});
*/

(function($) {

	$.fn.swWatermark = function(options){

		// defaults
		var defaults = {
				value: "Search...",		// string = text that is displayed on empty input field
				emptyClass: "swWatermark"	// string = class name for empty input field
		};

		var opts = $.extend(defaults, options);

		$(this).each(function() { // start each
				
				var obj = $(this);
				
				if ($(obj).val() == "") {
					$(obj).val(opts.value).addClass(opts.emptyClass);
				} else {
					$(obj).removeClass(opts.emptyClass);
				}
				
				$(obj).focus(function(){
					if ($(obj).val() == opts.value) {
						$(obj).val("").removeClass(opts.emptyClass);
					}
				});
				
				$(obj).blur(function(){
					if (($(obj).val() == opts.value) || ($(obj).val() == "")) {
						$(obj).val(opts.value).addClass(opts.emptyClass);
					}
				});
		
		}); // end each

	};

})(jQuery);
