/**
 * ui.js -> http://diphtong.com
 * Base document for JavaScript user interactions
 */







/**
 * Show or hide the element defined by the given id
 *
 * @param String	the element ID, or a list of element id
 * @param String	[ the display style : block (default), inline, etc… ]
 * @param boolean	[ force the element to stay in the given style (false by default)  ]
 *
 * @return String	the current element ID display style (only for a single ID)
 */
function display( id, style, fix ) {

	var i,elem;

	if ( !style ) style = "block";
	if ( !fix ) fix = false;
	if ( typeof(id)=="string" ) id = [id];
	
	for( i in id  ) {
		elem = document.getElementById( id[i] );
		elem.style.display = elem.style.display== style && !fix ? 'none' : style;
	}
	
	// return style
	if ( i==0 ) return elem.style.display;
}



/**
 * Show the specified panel ID, hide other.
 * @param String	the panel ID to be displayed
 */
function displayPanel( id ) {
	
	var tobehide = new Array();
	var panels = document.getElementById('text').getElementsByTagName('div');
	
	// scan elements and append to hide list
	for( var i=0; i<panels.length; i++ ) {
		if ( panels[i].id.indexOf("panel")!=-1 ) {
			if ( panels[i].id!=id ) tobehide[tobehide.length] = panels[i].id;
		}
	}
	
	// hide other panels
	// show required panel
	display( tobehide, 'none', true );
	display( id, 'block', true );
}

