window.jscontrols = new Array();

/** 
* TjsControl Contructor
*
* @param pvHtmlElId The ID of the TjsControl's HTML element. The HTML element will be created when element with this ID doesn't exist.
* @param pvTagName The tagname of the TJsControl's HTML element.
* @param pvParent The HTML element to which the TJsControl's HTML element must be added as a childnode.
*/
function TJsControl(pvHtmlElId, pvTagName, pvParent)
{
	this.htmlel = getEl(pvHtmlElId);
	this.visible = true;
	if (this.htmlel == null)
	{
		this.htmlel = (pvTagName == null) ? createEl("div") : createEl(pvTagName);
		if (pvHtmlElId != null) { this.htmlel.id = pvHtmlElId; }
		if (arguments.length == 3)
		{
			if (pvParent == null) { pvParent = document.body; }
			pvParent.appendChild(this.htmlel);
		}
	}

	this.jsindex = window.jscontrols.push(this) - 1;
	this.allowedcategories = null;
	this.allowtype = 2;
	this.callerfunctions = new Array();
	this.callerindex = -1;
	this.callerfuncindex = -1;
	this.connectionid = "";
	this.counter = 0;
}

/** 
* Gets a string representation of the TJSControl's array reference
*/
TJsControl.prototype.toArrayString = function()
{
	return "window.jscontrols[" + this.jsindex + "]";
}

/** 
* Returns an unique number for the TJSControl
*/
TJsControl.prototype.uniqueInt = function()
{
	this.counter++;
	return this.counter;
}

/** 
* Makes the TJsControl's HTML element invisible.
*/
TJsControl.prototype.hide = function()
{
	if (this.visible)
	{
		this.htmlel.setAttribute("d", this.htmlel.style.display);
		this.htmlel.style.display = "none";
		this.visible = false;
	}
}

/** 
* Makes the TJsControl's HTML element visible.
*/
TJsControl.prototype.show = function()
{
	if (!this.visible)
	{
		var lvDisplay = (this.htmlel.getAttribute("d") == null) ? "" : this.htmlel.getAttribute("d");
		this.htmlel.style.display = lvDisplay;
		this.visible = true;
	}
}

/** 
* Removes the TJsControl's HTML element from the webpage and sets the htmlel property to null.
*/
TJsControl.prototype.destroy = function()
{
	if (this.htmlel.parentNode != null) { this.htmlel.parentNode.removeChild(this.htmlel); }
	this.htmlel = null;
}