OverLabel = Class.create({
    initialize: function(t) {
        this.prepare(t);
    },
    wrapClass: 'overWrap',
    showLabel: function () {
        this.label.style.display = this.field.value.toString() ? 'none' : '';
    },
    hideLabel: function () {
        this.label.style.display = 'none';
    },
    prepare: function(e) {
        if (!e && !e.htmlFor) return;

        var t = this,
                fId = e.htmlFor,
                fEl = $(e.htmlFor),
                fP = fEl.parentNode,
                fW = new Element('span', {'class': t.wrapClass}),
                re = new RegExp('\b' + t.wrapClass + '\b');

        if (!('value' in fEl)) return;

        if (re.test(fP.className)) {
            fW = fP;
        }
        else {
            fP.insertBefore(fW, fEl);
            fW.appendChild(fEl);
        }

        fW.appendChild(e);

        t.label = e;
        t.field = fEl;
        t.wrapper = fW;

        t.showLabel();
        Event.observe(t.field, 'blur', t.showLabel.bind(t));
        Event.observe(t.field, 'focus', t.hideLabel.bind(t));
        // Event.observe(t.field, 'change', t.showLabel.bind(t));
    }
});
