var tabIndex = 0;
var tabDiv = null;
/* Tigra Menu items structure */
var MENU_ITEMS = [
	['Home', 'home.htm',
		['Merchandise', 'buyit.htm'],
		['Registration', 'register.php'],
		['Travel', 'travel.htm'],
		['Visitors', 'http://www3.clustrmaps.com/counter/maps.php?url=http://gurkharugby.com']
	],
	['Calendar', 'schedule.php',
		['Schedule', 'schedule.php'],
		['News & Events', 'news.htm'],
		['Sevens', 'sevens.htm']
	],
	['Information', 'history.htm',
		['Constitution', 'constitution.htm'],
		['Conduct', 'conduct.htm'],
		['Corporation', 'corporation.htm',
			['501 (C)(3)', 'pdfs/501C3Proof.pdf'],
			['Contact', 'contactCorp.htm']
		],
		['Disclaimer', 'disclaim.htm'],
		['Golf Tournament', 'golf.htm'],
		['History', 'history.htm']
	],
	['Teams', 'Dues.php',
		['Dues', 'Dues.php'],
		['Gurkhas - Men', 'gurkhas/index.html',
			['Home', 'gurkhas/index.html'],
			['Schedule', 'gurkhas/schedule.php'],
			['History', 'gurkhas/history.htm'],
			['Pictures', 'gurkhas/gallery.htm'],
			['Videos', 'gurkhas/videos.htm']
		],
		['San Pasqual HS', 'SP/index.html',
			['Home', 'SP/index.html'],
			['Schedule', 'SP/schedule.php'],
			['History', 'SP/history.htm'],
			['Pictures', 'SP/gallery.htm']
		],
		['Barbarians (U19, U16)', 'barbarians/index.html',
			['Home', 'barbarians/index.html'],
			['Schedule', 'barbarians/schedule.php'],
			['History', 'barbarians/history.htm']
		],
		['Escondido - Bears', 'bvms/index.html',
			['Home', 'bvms/index.html'],
			['Location', 'BVMS.htm'],
			['Schedule', 'bvms/schedule.php'],
			['U14 Boys', 'bvms/u14boys.htm'],
//			['U16 Girls', 'bvms/u16girls.htm'],
			['U16 Girls', 'bvms/u16girls.htm',
				['Match Reports', 'bvms/u14girlsMR2008.htm'],
				['Pictures', 'bvms/u14girlsPictures2008.htm'],
				['Practice', 'bvms/u14girlsPractice.htm']
			]
		],
		['San Marcos Penguins', 'penguins/index.html',
			['Home', 'penguins/index.html'],
			['Location', 'BradleyPark.htm'],
			['Schedule', 'penguins/schedule.php']
//			['U14 Boys', 'penguins/u14boys.htm']
		]
	],
	['Articles', 'misc.htm',
		['Misc', 'misc.htm'],
		['Newsletters', 'newsltrs.htm'],
		['Positions', 'posns.htm'],
		['Tours', 'touring.htm'],
		['Video', 'trclips.htm']
	],
	['Links', 'links.htm'],
	['Members', 'Dues.php',
		['Dues', 'Dues.php'],
		['E-Groups', 'egroups.htm'],
		['Lists', 'MemberList.php'],
		['Registration', 'register.php'],
		['Login', 'password_protect.php?login&link=MemberInfo.php'],
		['Logout','password_protect.php?logout&link=blank.htm']
	],
	['Contact', 'contactCoaches.htm',
		['Coaches', 'contactCoaches.htm'],
		['Gurkha Executive', 'contactGurkhas.htm'],
		['NCRC Board', 'contactCorp.htm']
	]
];
function BtnLink(title, onclick, text)
{
 
//	var txt = '<td nowrap><a class="BtnLink" title="' + title + '" href="" onclick="' + onclick + '"><span class="BtnLeft"/><span class="BtnMiddle">' + text + '</span><span class="BtnRight"/></a></td>';
//	var txt = '<td nowrap class="BtnLink" title="' + title + '" onmousedown="this.className=\'BtnLinkDown\'" onmouseup="this.className=\'BtnLinkOver\'" onmouseover="this.className=\'BtnLinkOver\'" onmouseout="this.className=\'BtnLink\'" onclick="' + onclick + '"><span class="BtnLeft"/><span class="BtnMiddle"><span class="BtnText">' + text + '</span></span></td>';
	var txt = '<td nowrap class="BtnLink" title="' + title + '" onmousedown="this.className=\'BtnLinkDown\'" onmouseup="this.className=\'BtnLinkOver\'" onmouseover="this.className=\'BtnLinkOver\'" onmouseout="this.className=\'BtnLink\'" onclick="' + onclick + '"><span class="BtnLeft"/><span>' + text + '</span></td>';
	return txt;
}
function LoadTabber(section, item, page)
{
	var obj = document.getElementById("tab1");
	if (obj != null)
	{
		var txt = "";
		for (var c = 0; c < MENU_ITEMS.length; c++)
		{
			var t = MENU_ITEMS[c];
			txt = txt + "<div id=\"" + c + "\" class=\"tabbertab\" title=\"" + t[0] + "\"></div>";
		}
		obj.innerHTML = txt;
	}
	if (section != null)
	{
		tabIndex = BannerItem(section, item, page);
	}
	tabberAutomatic(tabberOptions);
}
function BannerItem1(v, t, item)
{
	if (t[0] == item)
	{
		return v;
	}
	return 0;
}
function BannerItem(section, item, page)
{
	for (var c = 0; c < MENU_ITEMS.length; c++)
	{
		var t = MENU_ITEMS[c];
		if (t[0] == section)
		{
			for (var i = 1; i < t.length; i++)
			{
				var r;
				if (t[i] != null)
				{
					r = BannerItem1(100*i, t[i], item);
					if (r > 0)
					{
						return c + r;
					}
				}
			}
		}
	}
	return tabIndex;
}
function LoadSubTabs1(id, v, c, val)
{
	var i = id % 100;
	if (v == null)
	{
		LoadSubTabs1(id, MENU_ITEMS[i], (id - i)/100, 100);
	}
	else
	{
		i = c % 100;
		if (c > 100)
			LoadSubTabs1(id, v[i], (c - i)/100, val * 100);
		else if (id < 100)
			LoadSubTabs(id);
		else
		{
			var txt = SubTabs(id, v[i], val * 100);
			txt = "<table class=\"BtnTbl\"><tr>" + txt + "</tr></table>";
			tabDiv.innerHTML = txt;
		}
	}
}
function SubTabs(id, t, val)
{
	var	txt = "";

	if (t != null && t.length > 2)
	{
		if (val > 9999)
			txt = BtnLink('Back', 'LoadSubTabs1(' + (id % (val/100)) + ')', '&nbsp;<b><</b>&nbsp;');
		for (var c = 2; c < t.length; c++)
		{
			var v = t[c];
			var onclick = "gotoURL('" + v[1] + "', 'content');";
			if (v.length > 2)
			{
				onclick = onclick + "LoadSubTabs1(" + (id + (c * val)) + ");";
			}
			txt = txt + BtnLink("", onclick, v[0]);
		}
	}
	return txt;
}
function GetItem(id, t)
{
	var i = id % 100;
	if (id < 100)
		return t;
	if (t != null && t.length > 2)
	{
		i = (id - i)/100;
		return GetItem(i, t[i % 100]);
	}
	return null;
}
function LoadSubTabs(id)
{
	var i = id % 100;
	var txt, t;
	if (id <= 9999)
	{
		txt = SubTabs(id, MENU_ITEMS[i], 100);
		tabDiv.innerHTML = "<table class=\"BtnTbl\"><tr>" + txt + "</tr></table>";
	}
	else
	{
		t = GetItem(id % 10000, MENU_ITEMS[i]);
		txt = SubTabs(id, t, 10000);
		tabDiv.innerHTML = "<table class=\"BtnTbl\"><tr>" + txt + "</tr></table>";
	}
	t = GetItem(id, MENU_ITEMS[i]);
	if (t[1] != null)
		gotoURL(t[1], 'content');
}
var tabberOptions = {

  'removeTitle':true,
/*  'manualStartup':true, */

    'onLoad': function(argsObj) 
  {
    //var t = argsObj.tabber; /* Tabber object */
    if (tabIndex >= 0)
    {
		this.tabShow(tabIndex % 100);
		tabDiv = this.tabs[tabIndex % 100].div;
		LoadSubTabs(tabIndex);
	}
	else
		tabIndex = 0;
  },
	'onClick': function(argsObj) 
  {
    tabIndex = argsObj.index; /* Which tab was clicked (0..n) */
	tabDiv = this.tabs[tabIndex].div;
	LoadSubTabs(tabIndex);
  }
}

