/**
 * Legt ein Default-Value fuer eine Textbox fest.
 * Wird auf die Textbox geklickt, die den Default-Value enthaelt, wird dieser aus der
 * Textbox geloescht. Wird die Textbox ohne Eingabe verlassen, wird der Inhalt wieder
 * auf den Default-Value zurueckgesetzt.
 *
 * @param value string Default-Wert der Textbox
 * @param options Object
 *                  - class : CSS-Klasse der Textbox die den Default-Value enthaelt
 * 
 * @version 1.0
 */
$.fn.setDefaultValue = function(options)
{
    var options = $.extend(
    {
        css : 'changed'
    }, options);

    return this.each(function()
    {
        var $this = $(this);

        var value = $this.attr('title');

        $(this).attr('autocomplete','off');

        if($this.val().length <= 0 || $this.val() == value)
        {
            $this.val(value);
            $(this.parentNode).removeClass(options.css);
        }

        $this.click(clear);

        $this.blur(fill);

        $this.focus(clear).blur();

        function clear()
        {
            $(this.parentNode).addClass(options.css);
            if($this.hasClass(options.css) || $this.val() == value)
            {
                $this.val('');
            }
        }

        function fill()
        {
            //console.log('FILL');
            $(this.parentNode).removeClass(options.css);
            if($this.val().length <= 0)
            {
                $this.val(value);
            }
        }
        $(window).unload(clear); // Firefox-Autocomplete
    });
};
