/**
 * @author Raymond Chau raymond.chau@ionglobal.com
 */

/**
 * TextBox class represents the text box object on a web page 
 * @constructor
 * @param {string} id  ID of the HTML element
 */
TextBox = function(id) {
	this.input = document.getElementById(id);
	
	if (this.input && this.input.value != "")
	   this.input.text = this.input.value;
					
	//addEvent(this.input, 'focus', this.clearText);
	//addEvent(this.input, 'blur', this.setText);
}

TextBox.prototype = {  
  /**
   * Set appropriate text on the input field
   */
	setText : function()  {	
	  var input = (this.input) ? this.input : this;
	  if (input.value.replace(/(^\s+|\s+$)/g, '') == "")
      input.value = input.text;	  	  
	},
	/**
   * Clear the text on the input field
   */
	clearText : function()  {
  	var input = (this.input) ? this.input : this;
  	if (input.value == input.text)
  	   input.value = "";
	}
}
