function TabContent(contentDivId) {
	this.contentObj=document.getElementById(contentDivId);
	this.tabId=null;
} 


TabContent.prototype.show = function () {
	this.contentObj.style.display="block";
}

TabContent.prototype.hide = function () {
	this.contentObj.style.display="none";
}

TabContent.prototype.setTabId= function (tabId) {
	this.tabId=tabId;
}


function DynamicTabContent(tabMenuObject,url) {
	this.tabMenuObject=tabMenuObject;
	this.url=url;
	this.contentObj=null;
	this.tabId=null;
} 

DynamicTabContent.prototype.createContent=function() {
	var menuTabContainer=this.tabMenuObject.getContainerDiv();
	var	contentDiv=document.createElement("DIV");
	writeFileToDiv(this.url,contentDiv); // defined in writeFileToLayer.js
	menuTabContainer.appendChild(contentDiv);
	return contentDiv;
}

DynamicTabContent.prototype.show = function () {
	if (this.contentObj==null) {
		this.contentObj=this.createContent();
	} else {
		this.contentObj.style.display="block";
	}
}

DynamicTabContent.prototype.hide = function () {
	if (this.contentObj!=null) {
		this.contentObj.style.display="none";
	}
}

DynamicTabContent.prototype.setTabId= function (tabId) {
	this.tabId=tabId;
}


function Tab (tabObjId) {
	this.tabId=tabObjId;
	this.tabObj=document.getElementById(tabObjId);
}

Tab.prototype.getTabElement = function () {
	return this.tabObj;
}

Tab.prototype.getTabId = function () {
	return this.tabId;
}

Tab.prototype.displayNormal = function () {
	this.tabObj.style.color="#FFFFFF";
}

Tab.prototype.displayHighlight = function () {
	this.tabObj.style.color="#000000";
}


function TabMenu (containerDivId) {	
	this.containerObject=document.getElementById(containerDivId);
	this.tabs=new Array();
	this.tabcontent=new Array();
	this.selectedTabId=null;
}

TabMenu.prototype.setSelectedTab = function (tabId) {
	this.selectedTabId=tabId;
	this.tabs[tabId].displayHighlight();
	this.tabcontent[tabId].show();
}

TabMenu.prototype.getSelectedTab= function () {
	if (this.selectedTabId!=null) {
		return this.tabs[this.selectedTabId];
	} else {
		return null;
	}
}

TabMenu.prototype.getContainerDiv=function() {
	return this.containerObject;
}

TabMenu.prototype.getSelectedTabContent = function() {
	return this.tabcontent[this.selectedTabId];
}

TabMenu.prototype.addTab= function(tabObj,tabContentObj) {
	var tabId;
	var tabMenuObj=this;
	tabId=tabObj.getTabId();
	this.tabs[tabId]=tabObj;
	this.tabcontent[tabId]= tabContentObj;
	this.tabcontent[tabId].hide();
	this.tabcontent[tabId].setTabId(tabId);
	tabElement=tabObj.getTabElement();

	tabElement.onclick=function () {
		var selectedTab=tabMenuObj.getSelectedTab();
		if(selectedTab!=null) {
			tabMenuObj.getSelectedTabContent().hide();
			tabMenuObj.getSelectedTab().displayNormal();
		}
		tabMenuObj.setSelectedTab(tabId);		
	}
	
	tabElement.onmouseover=function() {
		tabMenuObj.tabs[tabId].displayHighlight();
	}
	
	tabElement.onmouseout=function() {
		var selectedTab=tabMenuObj.getSelectedTab();
		if (selectedTab==null) {
			tabMenuObj.tabs[tabId].displayNormal();
		} else {
			if (this!=selectedTab.getTabElement()) {
				tabMenuObj.tabs[tabId].displayNormal();
			}
		}
	}
	
}