/**
 * Zurücksetzen des Textfeldes von input und textarea
 * @author Christian
 * @version 0.1
 * @since 04.07.2009 
 * 
 * @param string text Standardtext der gelöscht werden soll aus dem Textfeld sobald reingeklickt wird oder es den focus erhält 
 * 
 * @example 
 * 		$('.ad_title').unsetTextfield({text:'enter'});
 * @return jQuery Object
 */

(function($) {
	
jQuery.fn.unsetTextfield = function(options) {
 var defaults = {
	 text: $(this).val()
 };
 var options = $.extend(defaults, options);

  return this.each(function(){

       // Textfeld erhält Focus
	$(this).bind('focus', function(event) {
		var textvalue = $(this).val();
		if (textvalue == options.text) {
			$(this).val('');
			$(this).removeClass('removeContentBeforeValidation');
		}
	});

       // Textfeld verliert Focus
	$(this).bind('blur', function(event) {
		var textvalue = $(this).val();
		if (textvalue == '') {
			$(this).val(options.text);
  		       $(this).addClass('removeContentBeforeValidation');
		}
	});

	// remove value if is equal to initial value and form is sent
	$('form').each(function(){
		$(this).bind('submit', function(event) {
           		$('.removeContentBeforeValidation').each(function(){
				$(this).val('');
			});
		});	
	});

	// set initial description text - only if value is empty
       var textvalue = $(this).val();
	if (textvalue == '') {
		$(this).val(options.text);
		$(this).addClass('removeContentBeforeValidation');
	}

  });
};

})(jQuery);
