var updateSelect = function(updateId, selectId, url, allOption, clearSelects) {
	this.init(updateId, selectId, url, allOption, clearSelects);
}

updateSelect.prototype = {
	updateEl: null,
	init: function(updateId, selectId, url, allOption, clearSelects) {
		this.updateEl = document.getElementById(updateId);
		var selectEl = document.getElementById(selectId);
		var selectValue = selectEl.value;
		while (this.updateEl.firstChild) {
			this.updateEl.removeChild(this.updateEl.firstChild);
		}
		if ((typeof(clearSelects) == 'object')&&(clearSelects instanceof Array)) {
			for (var i = 0; i < clearSelects.length; i++) {
				var clearEl = document.getElementById(clearSelects[i].item);
				while(clearEl.firstChild) {
					clearEl.removeChild(clearEl.firstChild);
				}
				if (clearSelects[i].allOption) {
					var option = document.createElement('option');
					option.value = 0;
					var textNode = document.createTextNode(clearSelects[i].allOption);
					option.appendChild(textNode);
					clearEl.appendChild(option);
				}
			}
		}
		if (allOption) {
			var option = document.createElement('option');
			option.value = 0;
			var textNode = document.createTextNode(allOption);
			option.appendChild(textNode);
			this.updateEl.appendChild(option);
		}

		var callback = {
			success: this.updateSuccess,
			failure: this.updateFailure,
			scope: this
		}
		YAHOO.util.Connect.asyncRequest('POST', url, callback, "id=" + selectValue);
	},
	updateSuccess: function(o) {
		var responseXML = o.responseXML;
		var items = responseXML.getElementsByTagName('item');
		for (var i = 0; i < items.length; i++) {
			var option = document.createElement('option');
			option.value = items[i].getAttribute('value');
			var textNode = document.createTextNode(items[i].firstChild.nodeValue);
			option.appendChild(textNode);
			this.updateEl.appendChild(option);
		}

	},
	updateFailure: function(o) {
		alert('Ajax Failure');
	}
}
