/* Author: David Mimms (david.mimms avantinformatica.it)
 * Desc: 
 * Date: Sept 2006
 */

function QuickList (onChange, toChange, toSave, reqURL, onResponse) {	
	drvObj = document.getElementById(onChange);
	vObj = document.getElementById(toChange);
	hValObj = document.getElementById(toSave);

	this.setSelected = function (val) {
		hValObj.value = val;
	}

	this.saveSelected = function () {
		var myindex = vObj.selectedIndex;
		hValObj.value = vObj.options[myindex].value;
	}

	this.fillSelect = function () {
		var myindex = drvObj.selectedIndex;
		if (drvObj.options[myindex].value) {
			var url = reqURL + drvObj.options[myindex].value + "&randid=" + Math.random();
			 // (url, onReady, onError, wantXML, rmethod, sendData)
			var myXHR = new XHRObject (url, this.procResponse, this.procError, true, 'GET', null);
		}
		return true;
	}

	this.procError = function (error) {
//		alert ("error" + error);
	}

	this.procResponse = function (xmldoc) {
		onResponse (xmldoc);
		hValObj.value = null;
	}
}
