function TabContainer(id, parentId)
{
	this.container = document.createElement('div');
	this.container.id = id;
	this.tabHead = document.createElement('div');
	this.tabHead.className = "tabHeadDiv";	
	this.tabContent = document.createElement('div');
	this.tabContent.className = "tabContentDiv";
	
	this.container.appendChild(this.tabHead);
	this.container.appendChild(this.tabContent);
	document.getElementById(parentId).appendChild(this.container);
	this.opened = false;
	return this;
}

TabContainer.prototype.addTab = function(tabTitle, tabContent)
{
	var closedPointer=this;
	var newTab = document.createElement('a');
	newTab.href = "javascript://";
	newTab.onclick = function(e){onTabClick(e,closedPointer);};
	newTab.innerHTML = tabTitle;
	newTab.className = "tabhead";
	newTab.tabContent = tabContent;
	
	this.tabHead.appendChild(newTab);
	
	if(!this.opened)
	{
		this.tabContent.innerHTML = tabContent;
		newTab.className = "tabheadactive";
		this.opened=true;
	}
};

function onTabClick(e,clsPtr)
{
	e = eventify(e);
	
	var tab = e.target;
	
	clsPtr.tabContent.innerHTML = tab.tabContent;
	
	neutralizeHeads(clsPtr);
	
	tab.className = "tabheadactive";
}

function neutralizeHeads(clsPtr)
{
	var heads = clsPtr.tabHead.getElementsByTagName('a');
	for(i=0;i<heads.length;i++)
	{
		heads[i].className = "tabhead";		
	}
}

function eventify(e)
{
	if(!e) e = window.event;
	
	if(!e.target) e.target = e.srcElement;
	
	return e;
}