function confirm_delete(id, text, formID)
{
    if(confirm("Are you sure you wish to delete " +text+ "?"))
    {
		if(!formID)
		{
        	document.getElementById("deleteForm"+id).submit();
		}
		else
		{
			document.getElementById(formID).submit();
		}
    }
}

function Switch_TreeNode(node)
{
	if(node.getElementsByTagName('DIV')[0].style.display == "block")
	{
		Hide_ChildNodes(node);
	}
	else
	{
		Show_ChildNodes(node);
	}
}

function Hide_ChildNodes(node)
{
	for(var child in node.childNodes)
	{
		if(node.childNodes[child].tagName == "DIV")
		{
			node.childNodes[child].style.display = "none";
		}
		if(node.childNodes[child].tagName == "IMG")
		{
			node.childNodes[child].className = "";
		}
	}
}

function Show_ChildNodes(node)
{
	for(var child in node.childNodes)
	{
		if(node.childNodes[child].tagName == "DIV")
		{
			node.childNodes[child].style.display = "block";
		}
		if(node.childNodes[child].tagName == "IMG")
		{
			node.childNodes[child].className = "TreeExpanded";
		}
	}
}

function switchTab(id)
{
	for(var child in document.getElementById("tab_menu").childNodes)
	{
		document.getElementById("tab_menu").childNodes[child].className = "tab_link";
	}
	for(var child in document.getElementById("tabContentBox").childNodes)
	{
		if(document.getElementById("tabContentBox").childNodes[child].tagName == "DIV")
		{
			document.getElementById("tabContentBox").childNodes[child].style.display = "none";
		}
	}
	document.getElementById("tabLink"+id).className = "tab_link_active";
	document.getElementById("tabContent"+id).style.display = "block";
	
	window.location.hash = "#" + id;
}

function getTabFromURL()
{
	var tab = window.location.hash;
    if(tab)
	{
		tab = tab.substring(1);
		switchTab(tab);
	}
}

window.onload = getTabFromURL;