TextBox = function ()
{
	this.element = null;
	this.text = null;
	this.value = null;
}

TextBox.prototype = new Control();

TextBox.prototype.getDocumentElement = function ()
{
	return this.element;
}

TextBox.prototype.setDocumentElement = function (newElement)
{
	this.element = newElement;
}

TextBox.prototype.getText = function ()
{
	if (this.text == null || this.text == "")
	{
		return "&nbsp;";
	}
	else
	{
		return this.text;
	}
}

TextBox.prototype.setText = function (newText)
{
	this.text = newText;
}

TextBox.prototype.getValue = function ()
{
	return this.value;
}

TextBox.prototype.setValue = function (newValue)
{
	this.value = newValue;
}

TextBox.prototype.select = function ()
{
	var input = document.getElementById(this.element.id + "_value");
	input.focus();
	try
	{
		input.select();
	}
	catch (ex) { }
}

TextBox.prototype.deselect = function ()
{
	var input = document.getElementById(this.element.id + "_value");
	Control.prototype.deselect.call(this);
 	input.blur();
}

TextBox.prototype.setView = function ()
{
	var input = document.getElementById(this.element.id + "_value");
	input.value = (this.value != null)? this.value : "";
}

TextBox.prototype.setModel = function ()
{
	var input = document.getElementById(this.element.id + "_value");
	this.text = input.value;
	this.value = input.value;
}

//static variables and methods
TextBox.existent = new Array();

TextBox.create = function (textboxId, editable)
{
	TextBox.existent[textboxId] = new TextBox();
	TextBox.existent[textboxId].setDocumentElement(document.getElementById(textboxId));
	TextBox.existent[textboxId].setEditable(editable);
	Control.register(textboxId, TextBox.existent[textboxId]);
	return TextBox.existent[textboxId];
}

TextBox.get = function (textboxId)
{
	return TextBox.existent[textboxId];
}