/*==========================================================
	Toggle the visibility of HTML elements.
============================================================*/

/*

	--------------------------------------------------------------
	Toggle the visibility of a detail row in search results tables.
	The row is initially hidden.

	recordLocator	- an identifier for the row. This is combined
									with a set of prefixes to get elements IDs
									(dr- = detail row, dp- = padding cell,
									 dc- = detail cell, di- = detail icon)
	glyphPath			- the relative path to the 'plus.png'
									and 'minus.png' images. We will toggle
									between the two images.
	doShow				- optional. If set, its value will override
									the 'visible' variable. 'Y' = make visible.

*/

function toggleDetailRow(recordLocator, glyphPath, doShow) {

/* Get the various elements we need from their IDs. */

	var oRow = getStyleObject("dr-" + recordLocator);
	var oPadding = getStyleObject("dp-" + recordLocator);
	var oCell = getStyleObject("dc-" + recordLocator);
	var oIcon = getObject("di-" + recordLocator);
	var visible;
	var isIE = false;
	if (document.all) {
		isIE = true;
	}

	if(oRow && oPadding && oCell) {

/* If the doShow parameter is set, use it to determine
	 whether the row should be made visible; otherwise,
	 toggle the current visibility. */

		if (!doShow) {
			if(oRow.visibility == "visible")
				visible = true;
			else
				visible = false;
		}
		else
			visible = !(doShow == 'Y');

/* Show or hide the row by setting its CSS class visibility. */

		oRow.visibility=(visible) ? "hidden" : "visible";
		oRow.display=(visible) ? "none" : (isIE) ? "block" : "table-row";
		oPadding.visibility=(visible) ? "hidden" : "visible";
		oPadding.display=(visible) ? "none" : (isIE) ? "block" : "table-cell";
		oCell.visibility=(visible) ? "hidden" : "visible";
		oCell.display=(visible) ? "none" : (isIE) ? "block" : "table-cell";
		if(oIcon) {
			oIcon.src=(visible) ? glyphPath + "plus.png" : glyphPath + "minus.png";
		}
	} else {
		alert("Your browser does not support the DHTML features used on this site.");
	}
}


/*

	--------------------------------------------------------------
	Loop through all detail rows in a search results table,
	make each detail row visible or invisible. This function
	uses the toggleDetailRow function to do the dirty work.

	maxID 		- the maximum row ID value
	glyphPath			- the relative path to the 'plus.png'
									and 'minus.png' images. We will toggle
									between the two images.
	doShow				- optional. If set, its value will override
									the 'visible' variable. 'Y' = make visible.

*/

function toggleAll(maxID, glyphPath, doShow) {
	for (i=1; i<=maxID; i++) {
		toggleDetailRow(i, glyphPath, doShow);
	}
}


/*

	--------------------------------------------------------------
	Show or hide a single HTML element.
	This is used to show or hide option buttons
	on search pages, among others.

*/

function showHide(objID,linkID) {
	var oWhat = getStyleObject(objID);
	var visible;

	if(oWhat) {
		if(oWhat.visibility == "visible")
			visible = true;
		else
			visible = false;
		oWhat.visibility=(visible) ? "hidden" : "visible";
		oWhat.display=(visible) ? "none" : "block";
		if (linkID) {
			oWhat = getObject(linkID);
			if (visible)
				oWhat.innerHTML = 'Show';
			else
				oWhat.innerHTML = 'Hide';
		}
	} else {
		alert("Your browser does not support the DHTML features used on this site.");
	}
}

/*

	--------------------------------------------------------------
	Cross browser get object by ID.

*/

function getObject(id) {
	if(document.getElementById) return document.getElementById(id);
	else if(document.layers) return document.layers[id];
	else if(document.all) return document.all[id];
	else return false;
}

/*

	--------------------------------------------------------------
	Cross browser get CSS object by ID.

*/

function getStyleObject(id) {
	if(document.getElementById) return document.getElementById(id).style;
	else if(document.layers) return document.layers[id];
	else if(document.all) return document.all[id].style;
	else return false;
}

