/*
 * Copyright (C) 2009 WorkSmart Labs, Inc.
 *
 * This class make a TextView that displays some text (usually instructional) until the 
 * user clicks there, then it clears this text. Then when the user leaves the field, 
 * it restores the text if he did not enter anything.
 *
 * @author Vera <vera@worksmartlabs.com>
 */


function TextViewWithDefaultText(domTextView, defaultText) {
    this.textview_ = domTextView;
    this.defaultText_ = defaultText;

    setFocusHandler(this.textview_, this, this.removeText_);
    setBlurHandler(this.textview_, this, this.restoreText_);
} 

TextViewWithDefaultText.prototype.removeText_ = function() {
    if (this.textview_.value == this.defaultText_) {
        this.textview_.value = '';
    } else {
        return;
    }
}

TextViewWithDefaultText.prototype.restoreText_ = function(){
    if (this.textview_.value == '') {
        this.textview_.value = this.defaultText_;
    } else {
        return;
    }
}

TextViewWithDefaultText.prototype.clear = function(){
    this.textview_.value = '';
}

TextViewWithDefaultText.prototype.setDefault = function(){
    this.textview_.value = this.defaultText_;
}