// ===========================================================================
// Show/Hide Hidden Text Block Functions - accomplished via DIVs
// Based upon online discussion located at:
//   http://www.webmasterworld.com/forum91/441.htm
// Not currently supporting show/hide for browsers which don't support getElementById

// Show or Hide (toggle) div's visibility
function showHideDiv(divID)
{ 
    showHideElements('div',divID,true);
} 

// Show Div - afterwards can not be hidden
function showDiv(divID)
{ 
    showElements('div',divID,true);
} 

// Hide Div - only hides the requested div
function hideDiv(divID)
{ 
    hideElements('div',divID,true);
} 

// ===========================================================================
// Show/Hide Hidden Text Block Functions - accomplished via TRs
// Not currently supporting show/hide for browsers which don't support getElementById

// Show or Hide (toggle) TR's visibility
function showHideTR(trID,exactmatch)
{ 
    showHideElements('tr',trID,exactmatch);
} 

// Show TR - afterwards can not be hidden
function showTR(trID,exactmatch)
{ 
    showElements('tr',trID,exactmatch);
} 

// Hide TR - only hides the requested TR
function hideTR(trID,exactmatch)
{ 
    hideElements('tr',trID,exactmatch);
} 

// Show or Hide (toggle) an Element's visibility
function showHideElements(tag, elementID, exactmatch)
{ 
	var elements = document.getElementsByTagName(tag); 

	for(i=0;i<elements.length;i++)
	{ 
      if (elements[i].id.length > 0)
      {
          if (exactmatch)
          {
            // If we have the requested element let's toggle it's display state.
            if (elements[i].id == elementID)
            {
                if (document.getElementById) // DOM3 = IE5, NS6 
                    if (elements[i].style.display != "")
                        elements[i].style.display = "";// show
                    else
                        elements[i].style.display = "none";// hide 
            }
          }
          else
          {
            // If we have a element matching the requested ID let's toggle it's display state.
            if (elements[i].id.toLowerCase().indexOf(elementID.toLowerCase()) > -1)
            {
                if (document.getElementById) // DOM3 = IE5, NS6 
                    if (elements[i].style.display != "")
                        elements[i].style.display = "";// show
                    else
                        elements[i].style.display = "none";// hide 
            }
          }
      }
	} 
} 

// Show element by tag and id
function showElements(tag, elementID, exactmatch)
{ 
	var elements = document.getElementsByTagName(tag); 

	for(i=0;i<elements.length;i++)
	{ 
      if (elements[i].id.length > 0)
      {
          if (exactmatch)
          {
            // If we have the requested element let's set it to show
            if (elements[i].id == elementID)
            {
                if (document.getElementById) // DOM3 = IE5, NS6 
                    if (elements[i].style.display != "")
                        elements[i].style.display = "";// show
            }
          }
          else
          {
            // If we have the requested element let's set it to show
            if (elements[i].id.toLowerCase().indexOf(elementID.toLowerCase()) > -1)
            {
                if (document.getElementById) // DOM3 = IE5, NS6 
                    if (elements[i].style.display != "")
                        elements[i].style.display = "";// show
            }
          }
      }
	} 
} 

// Hide element by tag and id
function hideElements(tag, elementID, exactmatch)
{ 
	var elements = document.getElementsByTagName(tag); 

	for(i=0;i<elements.length;i++)
	{ 
      if (elements[i].id.length > 0)
      {
          if (exactmatch)
          {
            // If we have the requested element let's set it to NOT show
            if (elements[i].id == elementID)
            {
                if (document.getElementById) // DOM3 = IE5, NS6 
                    if (elements[i].style.display == "")
                        elements[i].style.display = "none";// hide 
            }
          }
          else
          {
            // If we have the requested element let's set it to NOT show
            if (elements[i].id.toLowerCase().indexOf(elementID.toLowerCase()) > -1)
            {
                if (document.getElementById) // DOM3 = IE5, NS6 
                    if (elements[i].style.display == "")
                        elements[i].style.display = "none";// hide 
            }
          }
      }
	} 
} 
