DoubleSelect = function( selId1, selId2, url, optionParam ) {
	this.select1 = document.getElementById(selId1);
	this.select2 = document.getElementById(selId2);
	
	this.url = url;
	this.optionParam = (optionParam == null) ? null : optionParam;
	
	ajax.Event.addListener(this.select1, "change", 
		ajax.Event.bindAsListener(this.doChange, this));
};
DoubleSelect.prototype = {
	doChange: function(e) {
		if (this.select1.value != '') {
			var param = "value=" + encodeURIComponent( this.select1.value );
			if (this.optionParam != null) {
				param += this.optionParam;
			}
			var thisObj = this;
			//alert( "url : " + this.url +"\nparams: "+ param +"\n" );
			new ajax.xhr.Request(this.url, param, this.loaded, "GET", thisObj);
		} else {
			this.clearSelect2();
		}
	},
	clearSelect2: function() {
		this.select2.length = 1;
	},
	loaded: function(req) {
		if (req.readyState == 4) {
			if (req.status == 200) {
				var optionList = null;
				if ( req.responseXML ) {
					this.clearSelect2();
					oprionList = req.responseXML;					
					var select = oprionList.getElementsByTagName( "select" );	
					for( var i=0; i<select.length; i++ ) {
						node = document.createElement( "option" );
						text = document.createTextNode( select[i].getElementsByTagName( "text" )[0].childNodes[0].nodeValue );
						node.setAttribute( "value", select[i].getElementsByTagName( "value" )[0].childNodes[0].nodeValue );
						node.appendChild( text );
						var result = this.select2;
						result.appendChild( node );					
					}
					
			
				} else {
					oprionList = eval("(" + req.responseText + ")");
					this.initSelect2(optionList);
				}				
				
			} else {
				alert("error: "+req.status);
			}
		}
	},
	initSelect2: function(optionList) {
		this.clearSelect2();

		var optionArray = new Array();
		
		var option = document.createElement("option");
		option.text = "�����ϼ���";
		option.value = "";
		optionArray[optionArray.length] = option;
		
		option = document.createElement("option");
		option.text = "-----";
		option.value = "";
		optionArray[optionArray.length] = option;
		
		
		for (var i = 0 ; i < optionList.length ; i++) {
			option = document.createElement("option");
			option.text = optionList[i].text;
			option.value = optionList[i].value;
			optionArray[optionArray.length] = option;
		}
		for (var i = 0 ; i < optionArray.length ; i++) {
			try {
				this.select2.add(optionArray[i], null);
			} catch(e) {
				this.select2.add(optionArray[i], -1);
			}
		}
	}
};