// Functions.js
// Global functions available to all documents in site
function showTab(obj) {
	if(!document.getElementsByTagName) return false;
	var tab = obj.parentNode;
	if (tab.className.search(/selected/) != -1 || tab.className.search(/first-selected/) != -1 || tab.className.search(/last-selected/) != -1) return false;
	var tabs = obj.parentNode.parentNode;
	var tab_content = obj.parentNode.parentNode.parentNode;
	
	
	var content_number = 0;
	
	tabs = tabs.getElementsByTagName("li");
	
	for ( var i = 0; i < tabs.length; i++ )
	{
		
		if (tabs[i].className.search(/first-selected/) != -1)
		{
			if (tabs[i].className == "first-selected")
			{
				tabs[i].className = tabs[i].className.replace(/first-selected/i, "");
			}
			else {
				tabs[i].className = tabs[i].className.replace(/first-selected/i, "");
			}
		}
		if (tabs[i].className.search(/last-selected/) != -1)
		{
			if (tabs[i].className == "last-selected")
			{
				tabs[i].className = tabs[i].className.replace(/last-selected/i, "");
			}
			else {
				tabs[i].className = tabs[i].className.replace(/ last-selected/i, "");
			}
		}
		if (tabs[i].className.search(/selected/) != -1)
		{
			if (tabs[i].className == "selected")
			{
				tabs[i].className = tabs[i].className.replace(/selected/i, "");
			}
			else {
				tabs[i].className = tabs[i].className.replace(/ selected/i, "");
			}
		}
		
		if (tabs[i] == tab )
		{
			content_number = i;
		}
	}
	
	tab_content = tab_content.getElementsByTagName("div");
	
	var contentArray = new Array();
	var content_counter = 0;
	
	for (var i = 0; i < tab_content.length; i++)
	{
		
		if ( tab_content[i].className.search(/tab-content/) != -1 )
		{
		
			if (tab_content[i].className == "tab-content")
			{
				tab_content[i].className = tab_content[i].className.replace(/selected/i, "");
			}
			else {
				tab_content[i].className = tab_content[i].className.replace(/ selected/i, "");
			}
			
			contentArray[content_counter] = i;
			
			content_counter++;
		}
	}
	
	
	if (tab_content[contentArray[content_number]].className == "selected")
	{	
		tab_content[contentArray[content_number]].className = "selected";
	}
	else {
		tab_content[contentArray[content_number]].className += " selected";	
	}
	
	
	if (tab.className.search(/first/) != -1 )
	{
		if (tab.className == "")
		{
			tab.className == "first-selected";	
		}
		else {
			tab.className += " first-selected";
		}
	}
	else if ( tab.className.search(/last/) != -1)
	{
		if (tab.className == "")
		{
			tab.className == "last-selected";	
		}
		else {
			tab.className += " last-selected";
		}
	}
	else
	{
		if (tab.className == "")
		{
			tab.className == "selected";	
		}
		else {
			tab.className += " selected";
		}
	}
} //Function:ShowTab

function clearquery(obj) {
	input = document.getElementById(obj);
	input.value = "";
	return;
} //Function:clearquery

function toggleDiv(divid){
	if(document.getElementById(divid).style.display == 'none'){
		 document.getElementById(divid).style.display = 'block';
    }else{
		document.getElementById(divid).style.display = 'none';
    }
} //Function:toggleDiv