
function EnterraTabs()
{
	this.name = '';
	this.prefix = '';
	this.state = 0;
	this.current = -1;
	this.tabs = new Array();

	this.addTab = function (title, descr)
	{
		if (typeof(title) == 'string' && title != '' &&
		    typeof(descr) == 'string')
		{
			var index = this.tabs.length;
			this.tabs[index] = new Object();
			this.tabs[index].title = title;
			this.tabs[index].descr = descr;
			return true;
		}
		return false;
	}

	this.showTab = function (index)
	{
		if (this.state == 0 && typeof(index) == 'number' && index >= 0 && index < this.tabs.length && this.current != index)
		{
			this.state = 1;
			var newTab = document.getElementById(this.prefix + index);
			var oldIndex = this.current;
			var tabsObject = this;
			var tmpFunc = function ()
			{
				var container = document.getElementById(tabsObject.name + '-content');
				//container.innerHTML = tabsObject.tabs[index].descr;
				/*setTimeout(
					function ()
					{
					}, 300);*/
					$("#tab-body-" + tabsObject.name + '-' + tabsObject.current).show("normal", function (){ tabsObject.state = 0; });
			}
			if (this.current == -1)
			{
				tmpFunc();
			}
			else
			{
				this.hideTab(tmpFunc);
			}
			if (typeof(newTab) == 'object' && newTab != null)
			{
		        
				newTab.className = 'tab-item tab-item-active';
				this.current = index;
			}
		}
	}

	this.hideTab = function (eventCallback)
	{
		if (this.current >= 0)
		{
			var oldTab = document.getElementById(this.prefix + this.current);
			oldTab.className = 'tab-item tab-item-usual';
			$("#tab-body-" + this.name + '-' + this.current).hide("normal", eventCallback);
		}
	}
}