// scans for any tables with class "dataTable" and applies a row hover style
function initDataTables()
{
	var tableList = document.getElementsByTagName("table");
	
	for (var i = 0; i < tableList.length; i++)
	{
		var table = tableList[i];
		
		if (table.className.indexOf("grid") >= 0)
		{
			var rows = table.getElementsByTagName("tr");
			
			for (var j = 0; j < rows.length; j++)
			{
				var row = rows[j];
				var rowLinks = row.getElementsByTagName("a");
				
				row.onmouseout = function(){this.className = this.className.replace(/\s*hover/gi, "")};
				row.onmouseover = function(){this.className+=" hover"};
				
				if (rowLinks.length == 1)
				{
					row.defaultLink = rowLinks[0];
					row.onclick = function(){window.location.href=this.defaultLink};
					row.style.cursor = "pointer";
				}
			}
		}
	}
}

// submits the site search
function submitSearch(elm)
{
	while (elm != null && elm.nodeName != "FORM")
	{
		elm = elm.parentNode;
	}
	
	if (elm && elm.submit)
	{
		elm.submit();
		return false;
	}
	
	return true;
}

// check for common object
if (!Tactica)
{
	alert("Required script 'scripts/tactica.js' is missing. Did you forget a script tag?");
}

// load required script
Tactica.loadScript("scripts/menus.js");
Tactica.loadScript("scripts/popups.js");
Tactica.loadScript("scripts/tactica.forms.js");

Tactica.addLoadFunction(initDataTables);
