﻿function TabPage(tabControl, name, normalStyle, selectStyle)
{
	var Item = null;
	this.Name = name;
	this.TabControl = tabControl;
	this.Button = null;
	this.Panel = null;
	
	this.Init = function(item)
	{
		Item = item;
		this.Button = document.getElementById(this.Name);
		this.Panel = document.getElementById(this.Name + "_Sub");
		this.Button.onmouseover = function(){Item.Popup(true)};
	}
	
	this.Popup = function(popup)
	{
		if(popup)
		{
			if(this.Panel.style.display != "")
			{
				this.TabControl.SelectItem.Popup(false);
				this.Panel.style.display = "";
				this.TabControl.SelectItem = this;
			}
		}
		else
		{
			if(this.Panel.style.display != "none")
			{
				this.Panel.style.display = "none";
			}
		}
	}
}

function TabControl()
{
	this.Collection = new Array();
	this.SelectItem = null;
	
	this.Add = function(name)
	{
		var item = new TabPage(this, name);
		item.Init(item);
		if(this.Collection.length == 0)
		{
			this.SelectItem = item;
			item.Popup(true);
		}
		else
		{
			item.Popup(false);
		}
		this.Collection[this.Collection.length] = item;
	}
}