function montre(id) {
var d = document.getElementById(id);
for (var i = 1; i<=5; i++) {
	if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
}
if (d) {d.style.display='block';}
}

// S'assurer des dimensions, mettre scrollbars=1 si trop de texte...
function show_help(help)
{ 
    window.open(help, "", 
    "width=460, height=300, status=0, toolbar=0, scrollbars=1, left=" + 
		((screen.width - 460)/2) + ",top=" + ((screen.height - 150)/2) ) 
} 


function set_option_value(hidden_id,value) {
	if( document.getElementById(hidden_id) ){
		document.getElementById(hidden_id).value = value;
	}
}

// Form select/option drop-downs 
//function display_child_options($thisId,$level_id,$hidden_id)  
function display_child_options()  
{
		var argv = display_child_options.arguments;
		
		var $thisId = 					argv[0];
		var $level_id = 				argv[1];
		var $hidden_id = 				argv[2];
		var $drop_down_col_relation = 			argv[3];
		var $readonly_main_div = 			argv[4]; // NEW POUR READONLY => BRAD 2008-07-09
		
		// NEW POUR READONLY => BRAD 2008-07-09
		if( document.getElementById($readonly_main_div) )  
		{
			var $theReadOnlyMainDIV = document.getElementById($readonly_main_div);
			
			if($theReadOnlyMainDIV.getElementsByTagName('div'))
			{
				var $theReadOnlyDIVs = $theReadOnlyMainDIV.getElementsByTagName('div');
				//alert($theReadOnlyDIVs.length);
			
				for (q=0; q<$theReadOnlyDIVs.length; q++) 
				{
					if($theReadOnlyDIVs[q].style.display == 'block') {
						//alert("readonly ID = "+$theReadOnlyDIVs[q].id);
						$theReadOnlyDIVs[q].style.display = 'none';
					}
					
					var $readonlyId = "readonly_"+$thisId;
					//alert($theReadOnlyDIVs[q].id+" =?= "+$readonlyId);
					if($theReadOnlyDIVs[q].id == $readonlyId && $theReadOnlyDIVs[q].innerHTML != '') {
						//alert("innerHTML = "+$theReadOnlyDIVs[q].innerHTML);
						$theReadOnlyDIVs[q].style.display = 'block';
					}
				}
			}
			
		}


		// DESELECT AND HIDE ALL ELEMENTS WITHIN FIELDSETS that are children 
		$levelplusone = $level_id+2;
		for( m=$levelplusone; m<10; m++)
		{
			$theid = "fieldset_"+m+"_"+$hidden_id;									// The ID of the <fieldset> for this level (determined by m)
			
			if( document.getElementById($theid) ) {
				
				var $fieldset = document.getElementById($theid);					// The <fieldset> on this level
				var $selectList = $fieldset.getElementsByTagName('select'); 		// A list of all <select> elements in this level fieldset 
				
				//alert($selectList.length+" and m = "+m+" and parentnode is "+$fieldset.parentNode.id);
				
				// Go through all the <select> elements in fieldset 
				for (o=0; o<$selectList.length; o++) 
				{
					var optList = $selectList[o].getElementsByTagName('option');	// List of all <option>s in this <select> element
					
					// ------------------------------------
					// DESELECT ALL OPTIONS 
					// ------------------------------------
					for (p=0; p<optList.length; p++) { 
						$selectList[o].options[p].selected = false;
					}
					
					// ------------------------------------
					// HIDE SELECT ELEMENT  
					// ------------------------------------
					$selectList[o].style.display = "none";
					//alert ("parentnode "+o+" is "+$selectList[o].parentNode.id+"\n");
				}
				//alert($theid);
			}
		}
		
		// DESELECT HIDDEN <input> value
		set_option_value($hidden_id,'');

		
		// SHOW SELECTED CHILD LIST 
		// IF there is a child, open it and DO NOT SELECT hidden input
		if(document.getElementById($thisId)) {
			//alert("hello "+document.getElementById($thisId).style.display);
			document.getElementById($thisId).style.display = "block";
			
		// If there are no children, SELECT hidden input with this value 
		} else {
			// SET input VALUE in HIDDEN FIELD// BRAD FEB 13th
			// I have to select hidden id to post form...
			set_option_value($hidden_id,$thisId);
			
			// IF THERE IS A RELATION TO THIS COLUMN, SUBMIT FORM   => MUST BE ONLY IF LAST CHILD 
			if($drop_down_col_relation == 'yes_col_relation')
			{
				// make child variable "true" so that the form is reset to show children
				document.getElementById('modifEnfant').value = "true";
				
				// Submit form
				document.forms[0].submit();
			}
				
		}
		
	//	alert("set_option_value works too - "+argv[2]+" and "+$thisId);
	
	
		
}


