  	//hold a reference to the treeWindow...
	var treeWindow;
 	
 	//the display state of the filters section
	var filterSectionDisplayed = "false";
 	
 	//used to hold the identified name (html id attribute) of the edited component. 
 	var editedComponent;

	/********************************
	 * Functions definitions.
	*********************************/

 	/**
 	 * Sets the action to 'graph' and submit the form
 	 * wich will bring us to the graph page.
 	 *
 	 * queryWizMode is used to determine the type of qwiz
 	 * where the request was generated, in case there is 
 	 * an exception, it should be reforwarded back to the source.
 	 */
 	function getGraph(queryWizMode, cmpnt) {
 		//make sure the mandatory components are selected 
 	
		if( document.getElementById("Disease").value == "" || 
			document.getElementById("Therapy").value == "" ||
			document.getElementById("Outcome").value == "") 
		{
			alert ("You must fill all blank fields to generate a graph!");
			return(false);
			return;
		}
		
		//check to see if more than one therapies are compared
		//in wich case, the comparedTherapy field should not be null.
		if(queryWizMode != "_fromSimpleQWiz") {
			if(document.getElementById("checkCompareTherapy").checked) {
				if(document.getElementById("cbo_&Therapy").selectedIndex < 0 || document.getElementById("cbo_&Therapy").value.length <= 0) {
						alert ("You must select a compared therapy or uncheck the box to disable comparison.");			
						return(false);			
				}
			}
		}
		document.QuestionWizardForm.action.value = "graph" + queryWizMode; 	

		loading(cmpnt);
		return true;
		//document.QuestionWizardForm.submit();		
 	}
 	
	function openWin(wUrl, wName, wWidth, wHeight, wResize) {
		// Determine the coordinates to center popup window on screen.
		var availWidth = 800, availHeight = 600;
		if (document.all || document.layers) {
	   		availWidth = screen.availWidth;
		   	availHeight = screen.availHeight;
		}
		var leftPos = (availWidth - wWidth) / 2;
		var topPos = (availHeight - wHeight) / 2;
	  features = 'scrollbars=0,status=1,resizable=' + ((wResize) ? 1 : 0) + ((wWidth) ? ',width=' + wWidth : '') + ((wHeight) ? ',height=' + wHeight : '') + ", top=" + topPos + ",left=" + leftPos;
	  popWin = window.open(wUrl, wName, features);
	  if(popWin == null) {
	      alert('Please make sure to allow popups on our site!');
	  }
      if(popWin.focus) { popWin.focus(); }
      return popWin;
	}

	/**
	 * Reload the form
	 */
	function reloadForm() {
 		document.QuestionWizardForm.action.value="reload";
 		document.QuestionWizardForm.submit();		
	}
	 	
	/**
	 * goes to the full qwiz from simpleQWiz.
	 */
	function advancedSearch() {
			document.QuestionWizardForm.action.value = "edit";
			document.QuestionWizardForm.submit();
	} 	
	 	
 	/**
 	 * Resets all fields of this page.
 	 * since the page is submitted on every actions,
 	 * we just change the action to reset
 	 * The Action class will reset all components
 	 * from the form but also in the question.
 	 */
 	function resetForm() {
		document.QuestionWizardForm.action.value = "reset"; 	
		document.QuestionWizardForm.submit();
 	} 	
 	
 	/**
 	 * Resets only the filters section of the
 	 * question wizard.
 	 */
 	function resetFilters() {
		document.QuestionWizardForm.action.value = "reset_filters";
		document.QuestionWizardForm.submit();
 	} 
 	
 	/**
 	 * Calls the selectParentTherapy action in QueryWizardAction.
 	 */
 	function selectParentTherapy() {
		document.QuestionWizardForm.action.value = "parent_therapy";
		document.QuestionWizardForm.submit();
 	} 
 	
 	/**
 	 * Calls the selectParentTherapy action in QueryWizardAction.
 	 */
 	function selectParentOutcome() {
		document.QuestionWizardForm.action.value = "parent_outcome";
		document.QuestionWizardForm.submit();
 	} 

	function showHideSection(section) {
	  var s = document.getElementById(section);
	  var b = document.getElementById("b_"+section);
	  var i_1 = document.getElementById("i_"+section+"_1");
	  var i_2 = document.getElementById("i_"+section+"_2");

 	  if (s.style.display == 'none'){
        s.style.display = 'block';
        b.style.display = 'block';
	    i_1.src = "gfx/minus.gif";
	    i_2.src = "gfx/minus.gif";
	  }	
	  else if (s.style.display == 'block'){
	    s.style.display = 'none';
	    b.style.display = 'none';
	    i_1.src = "gfx/plus.gif";
	    i_2.src = "gfx/plus.gif";
	  }
	}


	