var nodes = [];

function initTable() {
	nodes = document.getElementsByTagName("tr");
	for (var i=0; i<nodes.length; i++)
	 {
nodes[i].onmouseover = function()
		{
			this.className += " hover";
		};
		nodes[i].onmouseout = function()
		{
			this.className = this.className.replace("hover", "");
		};
		var _links = nodes[i].getElementsByTagName("a");
		for (k = 0; k < _links.length; k++)
		{
			if (_links[k].className == "more")
			{
				_links[k]._parent = i;
				_links[k].onclick = function() {
					var _next = nodes[this._parent+1];
					if (_next)
					{
						if (nodes[this._parent].className.indexOf("opened") == -1)
						{
							if (nodes[this._parent+1].className.indexOf("opened") == -1)
							{
								for (i =0; i < nodes.length; i++)
								{
									nodes[i].className = nodes[i].className.replace("opened", "");
								}
								nodes[this._parent].className += " opened";
								nodes[this._parent+1].className += " opened";
								//nodes[this._parent+1].className = nodes[this._parent+1].className.replace("closed", "opened");
							}
						}
						else
						{
							if (nodes[this._parent+1].className.indexOf("opened") != -1)
							{
								nodes[this._parent].className = nodes[this._parent].className.replace("opened", "");
								nodes[this._parent+1].className = nodes[this._parent+1].className.replace("opened", "");
							}
						}
					}
					return false;
				};
				_links[k].onserverclick = "TTNotes";
			}
		}
		
	}

	initTabs();
}
function initTabs()
{
	var sets = document.getElementsByTagName("div");
	for (var i = 0; i < sets.length; i++)
	{
		if (sets[i].className.indexOf("tabset") != -1)
		{
			var tabs = [];
			var links = sets[i].getElementsByTagName("a");
			for (var j = 0; j < links.length; j++)
			{
				if (links[j].className.indexOf("tab") != -1)
				{
					tabs.push(links[j]);
					links[j].tabs = tabs;
					var c = document.getElementById(links[j].href.substr(links[j].href.indexOf("#") + 1));

					//reset all tabs on start
					if (c) if (links[j].className.indexOf("active") != -1)
					{
						c.style.position = "static";
						c.style.top = "auto";
						c.style.left = "auto";
						c.style.height = "auto";
					}
					else 
					{
						c.style.position = "relative";
						c.style.top = "-9999px";
						c.style.left = "-9999px";
						c.style.height = "0";
					}

					links[j].onclick = function ()
					{
						var c = document.getElementById(this.href.substr(this.href.indexOf("#") + 1));
						if (c)
						{
							//reset all tabs before change
							for (var i = 0; i < this.tabs.length; i++)
							{
								var tab = document.getElementById(this.tabs[i].href.substr(this.tabs[i].href.indexOf("#") + 1));
								if (tab)
								{
									tab.style.position = "relative";
									tab.style.top = "-9999px";
									tab.style.left = "-9999px";
									tab.style.height = "0";
								}
								this.tabs[i].className = this.tabs[i].className.replace("active", "");
							}
							this.className += " active";
							c.style.position = "static";
							c.style.height = "auto";
							c.style.top = "auto";
							c.style.left = "auto";
							return false;
						}
					}
				}
			}
		}
	}
}

if (window.addEventListener) {
	//window.addEventListener("load", initTable, false);
	//window.addEventListener("load", initTabs, false);
}
else if (window.attachEvent && !window.opera) {
	//window.attachEvent("onload", initTable);
	//window.attachEvent("onload", initTabs);
}
