BehaviourRules = {
	'select.combobox' : function (comboselectbox) {
		var textname = comboselectbox.name.substring(0,comboselectbox.name.length-8)+"[text]";
		var combotextbox = comboselectbox.form.elements[textname];
		comboselectbox.textbox = combotextbox; // reference
		combotextbox.selectbox = comboselectbox; // reference
		var combotext = $F(combotextbox);
		var comboselect = comboselectbox.options[comboselectbox.selectedIndex].value;
		if (comboselect == "_NEW"){
			combotextbox.enable();
			Element.removeClassName(combotextbox,"disabled");
		} else {
			combotextbox.disable();
			Element.addClassName(combotextbox,"disabled");
		}
		// select box should be exactly like a regular select box until/unless "_NEW" is selected
		// then the text box should show up. the select box will be shortened to fit the text box.
		Event.observe(comboselectbox,"change", function(selectbox){
			if (this.options[this.selectedIndex].value=="_NEW"){
				this.textbox.enable();
				Element.removeClassName(this.textbox,"disabled");
			} else {
				this.textbox.value="";
				this.textbox.disable();
				Element.addClassName(this.textbox,"disabled");
			}
			Form.Element.validate.apply(selectbox); // bind() didn't work so apply is used directly
			// contact the server with ajax?
			Event.stop(selectbox);			
		}.bind(comboselectbox));
		Event.observe(combotextbox,"change", function(textbox){
/*
			if (this.selectbox.options[this.selectbox.selectedIndex].value!="_NEW"){
				this.value="";
				this.disable();
				Element.addClassName(this,"disabled");
			}
			else
				Element.removeClassName(this.textbox,"disabled");
*/
			Form.Element.validate.apply(textbox); // bind() didn't work so apply is used directly
			// contact the server with ajax?
			Event.stop(textbox);
		}.bind(combotextbox));
	}
};
Behaviour.load(BehaviourRules);