﻿/// <reference path="../src/jquery-1.4.1-vsdoc.js" />
/// <reference path="pc3_JavaScript.js" />
/// <reference path="button.js" />

function ButtonTab(ID, Group, Name, OtherGroupsArray, targetContentID, isActive, isSelected)
{
	this.constructor(ID, Group, Name, OtherGroupsArray);

	this.Options.OnClickAllowUnselect = false;
	this.Options.OnClickDeActivateLaterButtons = false;

	if (isActive) this.Activate(); else this.DeActivate();
	if (isSelected) this.Select();

	var TargetContentID = targetContentID;
	var TargetContentJQ = JQ;

	this.getTargetContentJQ = function ()
	{
		return TargetContentJQ;
	};

	this.onInitFunc = function ()
	{
		TargetContentJQ = $("#" + TargetContentID);
	};

	this.onUnSelectFunc = function ()
	{
		TargetContentJQ.offset({ left: -10000, top: -10000 });
	};

	this.getButtonIndex = function ()
	{
		var group = this.getGroupObject();
		for (var i = 0; i < group.getButtons().length; i++)
		{
			if (group.getButtons()[i].getObjectID() == this.getObjectID())
			{
				return i;
			}
		}
	};

	this.onSelectFunc = function ()
	{
		var par = TargetContentJQ.parent();
		if (par && par.offset())
		{
			var L = par.offset().left;
			var T = par.offset().top;
			TargetContentJQ.offset({ left: L, top: T });
			TargetContentJQ.offset({ left: L, top: T });
		}
		if (this.Options.OnClickDeActivateLaterButtons)
		{
			var index = this.getButtonIndex();
			var group = this.getGroupObject();
			for (var i = index + 1; i < group.getButtons().length; i++)
			{
				group.getButtons()[i].DeActivate(false, false);
			}
		}
	};
}
ButtonTab.prototype.constructor = ToolButton;
