﻿// JScript 文件

function TabPage(tabControl, name)
{
	var Item = null;
	this.Index = 0;
	this.Name = name;
	this.TabControl = tabControl;
	this.Button = null;
	this.Panel = null;
	
	this.Init = function(item, text)
	{
		Item = item;
		this.Index = this.TabControl.Collection.length + 1;
		this.Button = document.getElementById(this.Name);
		this.Button.style.cursor = "pointer";
		this.Button.title = text;
		if($.browser.msie)
		    this.Button.innerText = text;   //IE
		else
		    this.Button.textContent = text; //火狐
		this.Panel = document.getElementById(this.Name + "_Panel");
		this.Button.onclick = function(){Item.Popup(true)};
	}
	
	this.Popup = function(popup)
	{
		if(popup)
		{
			if(this.Panel.style.display != "")
			{
			    if(this.TabControl.SelectItem != null)
			    {
				    this.TabControl.SelectItem.Popup(false);
				}
				this.Panel.style.display = "";
				this.Button.className = "tbBtnShow" + this.Index;
				var btnPanel = document.getElementById("Btn_Panel");
				btnPanel.className = "tbBtn" + this.Index + "_Panel";
				this.TabControl.SelectItem = this;
			}
		}
		else
		{
			if(this.Panel.style.display != "none")
			{
				this.Panel.style.display = "none";
				this.Button.className = "tbBtnHidden" + this.Index;
			}
		}
	}
}

function TabControl()
{
	this.Collection = new Array();
	this.SelectItem = null;
	
	this.Add = function(name, text)
	{
		var item = new TabPage(this, name);
		item.Init(item, text);
		if(this.Collection.length == 0)
		{
			item.Popup(true);
		}
		else
		{
			item.Popup(false);
		}
		this.Collection[this.Collection.length] = item;
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////////

function TabMovePage(tabControl, name)
{
	var Item = null;
	this.Index = 0;
	this.Name = name;
	this.TabControl = tabControl;
	this.Button = null;
	this.Panel = null;
	
	this.Init = function(item, text)
	{
		Item = item;
		this.Index = this.TabControl.Collection.length + 1;
		this.Button = document.getElementById(this.Name);
		this.Button.style.cursor = "pointer";
		this.Button.title = text;
		this.Button.innerText = text;
		this.Panel = document.getElementById(this.Name + "_Panel");
		this.Button.onclick = function(){Item.Popup(true)};
	}
	
	this.Popup = function(popup)
	{
		if(popup)
		{
			if(this.Panel.style.display != "")
			{
			    if(this.TabControl.SelectItem != null)
			    {
				    this.TabControl.SelectItem.Popup(false);
				}
				this.Panel.style.display = "";
				this.Button.className = "rnpDivTitleShow";
				this.TabControl.SelectItem = this;
			}
		}
		else
		{
			if(this.Panel.style.display != "none")
			{
				this.Panel.style.display = "none";
				this.Button.className = "rnpDivTitleHidden";
			}
		}
	}
}

function TabMoveControl()
{
	this.Collection = new Array();
	this.SelectItem = null;
	
	this.Add = function(name, text)
	{
		var item = new TabMovePage(this, name);
		item.Init(item, text);
		if(this.Collection.length == 0)
		{
			item.Popup(true);
		}
		else
		{
			item.Popup(false);
		}
		this.Collection[this.Collection.length] = item;
	}
}