var Tab = function(id) {
	this.tab = document.getElementById(id);
	this.itemList = {};
	this.selectedItem = null;	
	
}

Tab.prototype = {
	open: function(key, item) {
		if(!this.itemList[key] && !item) {
			alert("error id: " + key);
			return;	
		}
		if(this.selectedItem)
			this.selectedItem.style.display = "none";
		if(!this.itemList[key] && item) {
			this.itemList[key] = item;
			this.tab.appendChild(item);
		}
		this.itemList[key].style.display = "block";
		this.selectedItem = this.itemList[key];
				
	},	
	
	openText: function(text) {
		if(!this.textContainer) {
			this.textContainer = document.createElement("div");	
		}
		this.textContainer.innerHTML = text;
		this.open("text", this.textContainer);
	},
	
	remove: function (key) {
		this.tab.removeChild(this.itemList[key]);
		this.itemList[key] = null;	
	}
}