/**
 * Plugin Watermark jQuery
 * Autor: Gustavo Michel - BiTS Business IT Solutions
 *
 * Ex.: <input type="text" class="watermark" value="teste" />
 *
 */
watermark = {

    init: function(){
        $('input.watermark[type="text"], input.watermark[type="password"], textarea.watermark').focus(function(){
            watermark.focus($(this));
        }).blur(function(){
            watermark.blur($(this));
        }).each(function(){
            $(this).attr('title', $(this).val());
        });
    },

    focus: function(valor){
        val = $(valor).val();
        if($(valor).val() == $(valor).attr('title')){
            $(valor).val('');
            $(valor).attr('alt', val);
        }
    },

    blur: function(valor){
        val = $(valor).attr('alt');
        if($(valor).val() == ''){
            $(valor).val(val);
            $(valor).attr('alt', '');
        }
    }

}