//
// TabController class. Remember to re-make the CSSClass'
//
TabController = {
	selectedTab : null,
	init : function()
	{
		var tabs = document.getElementById("parentTabContainer").getElementsByTagName("div");
		var childs = document.getElementById("childTabContainer").getElementsByTagName("td");
	
		// Select the first tab
		TabController.select( tabs[1], "cartage" );

		// Set hover events on parents
		for( var x = 0; x < tabs.length; x++ )
		{
			tabs[x].onmouseover = this.mouseover;
			tabs[x].onmouseout = this.mouseout;
		}

		// Set hover events on childs
		for( var x = 0; x < childs.length; x++ )
		{
			childs[x].style.borderLeft = "#C0C0C0 2px solid"
			childs[x].style.borderRight = "#C0C0C0 2px solid"

			childs[x].onmouseover = function()
			{
				this.style.backgroundColor = "#DDDDDD";
				this.style.borderColor = "#FFFFFF";
			}
			childs[x].onmouseout = function()
			{
				this.style.backgroundColor = "#C0C0C0";
				this.style.borderColor = "#C0C0C0";
			}
		}

		return;
	},
	select : function( aTabObj, aSelectedSubTabId, redirUrl )
	{
		this.selectedTab = aTabObj;

		var oChildTabChildren = document.getElementById("childTabContainer").getElementsByTagName("div");
		var oParentTabChildren = document.getElementById("parentTabContainer").getElementsByTagName("div");

		for( var x = 0; x < oChildTabChildren.length; x++ )
		{
			oChildTabChildren[x].style.display = (oChildTabChildren[x].id == aSelectedSubTabId ) ? "block" : "none";
		}
		for( var x = 0; x < oParentTabChildren.length; x++ )
		{
			oParentTabChildren[x].className = ( oParentTabChildren[x] == aTabObj ) ? "tab selectedTab" : "tab deselectedTab";
		}

		if( redirUrl != null )
		{
			document.getElementById("iframe_mainContent").src = redirUrl;
		}

		return;
	},
	mouseover : function()
	{
		if( this != TabController.selectedTab )
		{
			
		}

		return;
	},
	mouseout : function()
	{
		if( this != TabController.selectedTab )
		{
			
		}

		return;
	}
}
