/**************************************************************************************************
 *		file: quser_step1.js 
 *
 *		Part of "Databasen Kari" user interphase ( quser interphase ).
 *		Used by index.php in step 1 to select categories and difficulty levels.
 *		NB: Browsers not supporting javascript with DOM functions such as getElementById
 *		are ruthlessly and intentionally ignored! Implemented for quser version 0.1.
 *
 *		LIST OF FUNCTIONS:
 *			toggle_display(id)
 *			quser_highlight_cat( id )
 *			quser_highlight_onoff( id )
 *
 *		© 2006 Sivilingenør Pål Baggethun
 **************************************************************************************************/

//-------------------------------------------------------------------------------------------------
//	GLOBAL VARIABLES
//-------------------------------------------------------------------------------------------------
	var quser_currentCat = null; // integer - id of currently selected cat. in any radio-group

//-------------------------------------------------------------------------------------------------
//	Toggles display of category children and expand/collapse icon.
//	26.09.2006
//-------------------------------------------------------------------------------------------------
	function quser_toggle_catgroup(id) {
		var elementStyle = document.getElementById("child_of_"+id).style;
		if( elementStyle.display == 'none' ) {
			elementStyle.display = 'block';
			document.getElementById("icon_collapsable_"+id).src = 'minus.png';
		} else {
			elementStyle.display = 'none';
			document.getElementById("icon_collapsable_"+id).src = 'pluss.png';
		} 
	}

//-------------------------------------------------------------------------------------------------
//	Switch highlighting and difficulty selection on/off when selecting categories.
//	If category is in a radio group, switch previously seleted radio cat off.
//	26.09.2006
//-------------------------------------------------------------------------------------------------
	function quser_highlight_cat( id ) {
		if( document.getElementById("cat"+id).type.toLowerCase() == "radio" ) {
			if( quser_currentCat != null ) { quser_highlight_onoff(quser_currentCat); }
			quser_currentCat = id;
		}
		quser_highlight_onoff(id);
	}

//-------------------------------------------------------------------------------------------------
//	Performs the actual swtching of the elements for function quser_highlight_cat.
//	26.09.2006
//-------------------------------------------------------------------------------------------------
	function quser_highlight_onoff( id ) {
		var diffStyle = document.getElementById("diff_for_"+id).style;
		if( diffStyle.display == 'none' ) {
			diffStyle.display = 'inline';
			document.getElementById("label_for_"+id).className = 'quser_catlabel_highlight';
		} else {
			diffStyle.display = 'none';
			document.getElementById("label_for_"+id).className = 'quser_catlabel';
		} 
	}

