// toggle() displays a hidden item, or hides a displayed item.
// areaId - String containing the Id of the areaassociated with the data.
function toggle(itemId) {
	// Get the item to show, if any.
	var itemToShow = document.getElementById(itemId);
	if (itemToShow!=null) {
		if (itemToShow.style.display=="none") {
			itemToShow.style.display="";
		} else {
			itemToShow.style.display="none";
		};  // if =="none" .. else
	};  // if !=null
};  // toggle()

// show() displays a hidden item.
// areaId - String containing the Id of the areaassociated with the data.
function show(itemId) {
	// Get the item to show, if any.
	var itemToShow = document.getElementById(itemId);
	if (itemToShow!=null) {
		if (itemToShow.style.display=="none") {
			itemToShow.style.display="";
		};  // if =="none" .. else
	};  // if !=null
};  // show()

// hide() hides a displayed item.
// areaId - String containing the Id of the areaassociated with the data.
function hide(itemId) {
	// Get the item to hide, if any.
	var itemToShow = document.getElementById(itemId);
	if (itemToShow!=null) {
		if (itemToShow.style.display!="none") {
			itemToShow.style.display="none";
		};  // if !="none"
	};  // if !=null
};  // hide()

// switchTo() displays one of a series of items with id's in the form "name2".
// seriesName - String containing the name of the series.  "name" above.
// seriesNumber - Number containing the number in the series.  2 above.
function switchTo(seriesName, seriesNumber) {
	var i = 0;
	var notExist = 0;
	var item
	do {
		item = document.getElementById(seriesName + i);
		if (item==null) {
			// Keep track of any non-existant items in the series.
			notExist++;
		} else {
			if (i==seriesNumber) {
				item.style.display="";
				notExist = 0;
			} else {
				item.style.display="none";
			};  // if == seriesNumber
		};  // if null..else
		i++;
	// Stop looking after three missing items in a row.
	// (Allows developers to safely remove single items.)
	} while (notExist<3);
};  // switchTo() 

// DCSE_tab() displays a specified tab in a DCSE_tabs_table.
// Changes the style of the clicked upon tab cell and the previously selected 
// tab cell, shows the corresponding page's row and hides the previously 
// selected tab's row.
// intTabNum - Number containing the tab number.
function DCSE_tab(intTabNum) {
	var tab_table, e, objClicked, currentTab;
	
	// Some browsers use "event", others use "Event".  
	// Javascript is case sensitive, so check and put whichever in "e".
	if((typeof(event)!='undefined')||(typeof(Event)!='undefined')) {
		if(typeof(event)!='undefined') {
			//alert("event");
			e=event;
		} else {
			if(typeof(Event)!='undefined') {
				//alert("Event");
				e=Event;
			};
		};
		//alert(e.srcElement.tagName);
	};  // if events
	
	if(e) {
		// User either fired the onClick event of the table cell or the link.
		// Determine which and get the parent table relative to it.
		objClicked = e.srcElement;
		//alert(objClicked.tagName);
		if (objClicked.tagName=="A") {
			tab_table = objClicked.parentElement.parentElement.parentElement.parentElement;
		} else {
			tab_table = objClicked.parentElement.parentElement.parentElement;
		};  //
		//window.status="Tab(" + intTabNum + ") called from " + objClicked.tagName + " in " + tab_table.tagName;

		// Find the currently visible row, and therefore the visible tab
		for(i=1;i<tab_table.rows.length;i++) {
			//if (tab_table.rows[i].style.display=="") {
			if (tab_table.rows[i].className=="visible") {
				currentTab = i;
			};  // if
		};  // for i
		
		// If selected a different tab, make it look selected and show its contents.
		// Also, make the old tab look unselected and hide its contents.
		if(intTabNum !=currentTab){
			//tab_table.rows[intTabNum].style.display="";
			tab_table.rows[intTabNum].className="visible";
			tab_table.rows[0].cells[(intTabNum*2)-1].style.backgroundColor="#ffffff";
			tab_table.rows[0].cells[(intTabNum*2)-1].style.borderBottom="none";
	
			//tab_table.rows[currentTab].style.display="none";
			tab_table.rows[currentTab].className="print";
			tab_table.rows[0].cells[(currentTab*2)-1].style.backgroundColor="#f5f5f5"; //#eef3f9
			tab_table.rows[0].cells[(currentTab*2)-1].style.borderBottom="1px solid #cccccc";
			tab_table.rows[0].cells[(currentTab*2)-1].style.border="1px solid #cccccc";
		};  // if not current tab
		
		// Return "false" to keep any other events from firing on this tab redundantly.
		if(objClicked.tagName=="A") {
			return(false);
		};  // if "A"
	};  // if event
};  // DCSE_tab()

// ETS_tab() displays a specified tab in a DCSE_tabs_table.
// Changes the style of the clicked upon tab cell and the previously selected 
// tab cell, shows the corresponding page's row and hides the previously 
// selected tab's row.
// intTabNum - Number containing the tab number.
function ETS_tab(intTabNum, objClicked) {
	var tab_table, e, tab_span, currentTab;

	if(typeof(objClicked)=="object") {
		// User either fired the onClick event of the table cell or the link.
		// Determine which and get the parent table relative to it.
		//alert(objClicked.tagName);
		if (objClicked.tagName=="A") {
			//alert("clicked a link");
			tab_table = objClicked.parentNode.parentNode.parentNode.parentNode.parentNode;
			tab_span = objClicked.parentElement;
		} else {
			//alert("clicked a span");
			tab_table = objClicked.parentNode.parentNode.parentNode.parentNode;
			tab_span = objClicked;
		};  //
		//alert("ETS_Tab(" + intTabNum + ") called from " + objClicked.tagName + " in " + tab_table.tagName);

		// Find the currently visible row, and therefore the visible tab
		for(i=1;i<tab_table.rows.length;i++) {
			//if (tab_table.rows[i].style.display=="") {
			if (tab_table.rows[i].className=="visible") {
				currentTab = i;
			};  // if
		};  // for i
		
		// If selected a different tab, make it look selected and show its contents.
		// Also, make the old tab look unselected and hide its contents.
		if(intTabNum !=currentTab){
			// Make all selected tabs unselected.  Should be only one.
			tabs = tab_table.rows[0].cells[0].childNodes;
			for (i = 0; i < tabs.length; i++) {
				if(tabs.item(i).className=="tabsel") {
					tabs.item(i).className = "tabnormal";
					tabs.item(i).childNodes.item(0).style.color="";
					tab_span.childNodes.item(0).style.text_decoration="";
				};  // if "tabsel"
			};  // for i
			
			//tab_table.rows[intTabNum].style.display="";
			tab_table.rows[currentTab].className="print";
			tab_table.rows[intTabNum].className="visible";
			//tab_table.rows[intTabNum].cells[0].style.border="1px solid #cccccc";
			//tab_table.rows[intTabNum].cells[0].style.borderTop="none";
			//tab_table.rows[intTabNum].cells[0].style.padding="4px";
			tab_span.className = "tabsel";
			// Make the text of the selected tab link black, and without an underline.
			tab_span.childNodes.item(0).style.color="black";
			tab_span.childNodes.item(0).style.text_decoration="none";
		};  // if not current tab
		
		// Return "false" to keep any other events from firing on this tab redundantly.
		//if(objClicked.tagName=="A") {
		//	return(false);
		//};  // if "A"
	};  // if event
};  // ETS_tab()
