/* menuExpand.js
 * Provides an expanding/contracting menu.
 * 
 * Parameters:
 *	obj --> the object that has/is the icon image to action on, ie. an img element or an anchor with background
 *	menu -> the id of the submenu to toggle the display property on
 *
 * Usage:
 *  When an img is the toggle
 *	<img src="images/expand.gif" height="11" width="12" onmouseover="toggleMenu(this,'famiSublist');">
 *
 *  When an anchor is the toggle
 *  <a class="expand" onclick="toggleMenu(this,'sexcSublist')">blah</a>
 *
 * Notes:
 * If using img element: Assumes that the two images used are named expand.gif and contract.gif
 * If using anchor element: Assumes the two class names 'expand' & 'contract' are using to display background image
 *
 * Author:
 * Matthew Meyer, DCT - FindLaw, 8/19/2008
 *
 * Updates:
 *  - added toggleExpandContractClass() to enable menu expansion using anchor tag with background image - MM 02/27/2009
 */


function toggleMenu(obj, menu) {
	toggleExpandContractClass(obj);
	toggle(menu);
}

function toggle(obj) {
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
}
function toggleExpandContractIcon(obj) {
	obj.src = (obj.src.search(/expand\.gif/) == -1 ? obj.src.replace(/contract\.gif/,"expand.gif") : obj.src.replace(/expand\.gif/,"contract.gif") );		
}
function toggleExpandContractClass(obj) {
	try {
		obj.className = (obj.className.search(/expand/) == -1 ? obj.className.replace(/contract/,"expand") : obj.className.replace(/expand/,"contract") );
	}
	catch (e) {
		//alert(e);
	}
}
