/*
 * $Id$
 * Javascript Source File
 */
function showOptions(elem) {
	document.getElementById('showOptionsLink').style.display = 'none';
	document.getElementById('hideOptionsLink').style.display = 'inline';
	document.getElementById('optionsFieldset').style.display = 'block';
}
				
function hideOptions(elem) {
	document.getElementById('showOptionsLink').style.display = 'inline';
	document.getElementById('hideOptionsLink').style.display = 'none';
	document.getElementById('optionsFieldset').style.display = 'none';
}


/* Dynamic search result display */

/*
The following two functions require that the form being submitted adheres to the
following characteristics

	- id: combo
	- three input types in the following order:
		- input to set the parent search
		- input to set the child search 
		- input to set the 'display search' property

Example for struts form:	

<html:form action="/actionName" styleId="combo">
	<html:hidden property="chosenBranche" name="awoGWForm"/>
	<html:hidden property="chosenSubBranche" name="awoGWForm"/>
	<html:hidden property="displaySearch" name="awoGWForm"/>
	<input type="hidden" name="language" value="<%= language %>">
	<input type="hidden" name="country" value="<%= country %>">
</html:form>
*/

/**
 * This function should be called from within the parent combobox
 */
function doSubmitParent(src){
	//alert("submit for " + src.name);
	
	var srcValue = src.options[src.options.selectedIndex].value;
	var comboForm = document.forms["combo"];
	var parent = comboForm.elements[0];
	var child = comboForm.elements[1];
	
	// set parent to the given value
	parent.value = srcValue;
	// set child to 'no restriction'
	if(srcValue != "*"){
		if(child != null) {
			child.value = '*';
		}
	}
	// child.value = "*";
	comboForm.elements["action"].value="searchMarktplatz";	
	// enable 'show results'
	comboForm.elements[2].value = true;
	comboForm.submit();
}

/**
 * This function should be called from within the child combobox
 */
function doSubmitChild(src){
	//alert("submit for " + src.name);

	var srcValue = src.options[src.options.selectedIndex].value;
	//alert("setting value to " + srcValue);
	var comboForm = document.forms["combo"];
	var child = comboForm.elements[1];
	
	//comboForm.elements["action"]="searchMarktplatz";
	comboForm.elements["action"].value="searchMarktplatz";	
	// set child to the given value
	child.value = srcValue;
	// enable 'show results'
	comboForm.elements[2].value = true;
	comboForm.submit();
}

