/**
 * JavaScript effects for form elements.
 * 
 * @author Dave Lane [dclane21@tntech.edu]
 **/

var isListRow = 'false';

/**
 * Hide the specified DIV tag.
 * 
 * @param divName String name of the DIV tag's id attribute.
 **/
function divHide(divName)
{
	myDiv = document.getElementById(divName);
	myDiv.style.visibility = 'hidden';
	myDiv.setAttribute('style', 'max-height:0px;');
	myDiv.style.display = 'none';
}

/**
 * Show the specified DIV tag.
 * 
 * @param divName String name of the DIV tag's id attribute.
 **/
function divShow(divName)
{
	myDiv = document.getElementById(divName);
	myDiv.style.visibility = 'visible';
	myDiv.setAttribute('style', 'max-height:9999px');
	myDiv.style.display = 'inline';
}

/**
 * Toggle the visibility of the specified DIV tag.
 * 
 * @param divName String name of the DIV tag's id attribute.
 **/
function divToggle(divName)
{
	myDiv = document.getElementById(divName);
	
	if(myDiv.style.display == 'none')  // show the DIV.
	{
		divShow(divName);
	}
	else  // hide the DIV.
	{
		divHide(divName);
	}
}

/**
 * Highlights the specified row.
 *
 * @param row Row (TR) table element.
 **/
function highlight(row)
{
	row.bgColor = '#FFFFCC';
}

/**
 * Sets the isListRow value (used for highlighting 
 * and unhighlighting).
 * 
 * @param myVal Boolean value; true if the list row effects are to be used.
 **/
function setListRow(myVal)
{
	isListRow = myVal;
}

/**
 * Unhighlights the specified row.
 * 
 * @param row Row (TR) table element.
 **/
// unhighlight the specified row.

function unHighlight(row)
{
	row.bgColor = '#FFFFFF';
}

/**
 * Toggles the checkbox input value.
 * 
 * @param checkbox Checkbox form element.
 **/
function toggle(checkbox)
{
	if(isListRow == true)
	{
		checkbox.checked = !(checkbox.checked);
	}
}

/**
 * Toggles the first checkbox input value in the 
 * first table cell on the specified row.
 *
 * @param row Row (TR) table element.
 **/
function toggleCheckedRow(row)
{
	checkbox = row.getElementsByTagName('TD')[0].getElementsByTagName('INPUT')[0];
	checkbox.checked = !(checkbox.checked);
	
	// the following "if" statement is necessary to fix radio buttons.
	if(checkbox.attributes.getNamedItem("type").value=='radio' && !checkbox.checked)
	{
		checkbox.checked = !(checkbox.checked);
	}
}

