// Brian Arthmire's very basic show/hide function [blarthmi@franklincountyohio.gov]
function swap( id, displayValue ) {
	var obj = document.getElementById( id );
	if( displayValue == null ) displayValue = "";
	if( obj ) {
		obj.style.display = ( obj.style.display == "none" ) ? displayValue : "none";
	}
	else {
		if( document.layers ) {
			document.id.display = ( document.id.display == "none" ) ? displayValue : "none";
		} else {
			document.all.id.style.display = ( document.all.id.style.display == "none" ) ? displayValue : "none";
		}
	}
}
// force show element
function show( id, displayValue ) {
	var obj = document.getElementById( id );
	if( obj ) {
		if( displayValue == null ) displayValue = "";
		obj.style.display = displayValue;
	}
}
// force hide element
function hide( id ) {
	var obj = document.getElementById( id );
	if( obj ) obj.style.display = "none";
}
// Brian Arthmire's unobtrusive toggle elements function [blarthmi@franklincountyohio.gov]
// requires the /_lib/scripts/main.js file
// unfortunately suffers from the flicker effect
// clickable text to trigger the toggle: <label for="elementID">Hello World</label>
// element to be toggled: <anyTagName id="elementID">Text is initially hidden if JS is enabled</anyTagName>
function toggle( ) {
	var i, nodes = document.getElementsByTagName( "label" ), returnValue = false;
	if( nodes ) {
		// iterate through every label element
		for( i = 0 ; i < nodes.length ; i++ ) {
			// if label element is marked with a for attribute...
			if( nodes[ i ].htmlFor ) {
				returnValue = true;
				// ...then hide the id element and add the toggle or swap onClick event
				document.getElementById( nodes[ i ].htmlFor ).style.display = "none";
				addListener( nodes[ i ], "click", function( e ) {
					var obj = findTarget( e );
					if( obj.htmlFor ) { swap( obj.htmlFor ); }
				} );
			}
		}
	}
	return returnValue;
}
