/*
 * Requires commondom.js, httpRequest.js
 */

/*
 * updateTarget element
 */
var updateTarget;

/*
 * Update the options of a select field from the selection of another
 *
 * @param element src Source element of change
 * @param string dest Destination element name
 * @param string url URI of web service providing result
 */
function updateInnerHtml(src, dest, url) {

	var selected = src.value;

	updateTarget = gel(document, dest);

	if (updateTarget) {
		request = httpRequest(url, 'POST', 'callBack', 'value='+selected);
	}
}

/*
 * XmlHttprequest respose handler
 * Empties Options of target select element, and adds new child options
 *
 * @param XmlHttpRequest o Request object
 */
function callBack(o) {
	if (o) {
		updateTarget.innerHTML = o.responseText;
	}
}