function chainLoad(s,v) {

	cleanOptions(s);
	setLoading(s);
	url = arguments[2];
	if (url.length > 0) {
		
		request = Ext.Ajax.request({
				url: url,
				target: s,
				success: function(t,jsonx) {
					var json = false;
					if (!json) {
						if (t.responseText) json = Ext.util.JSON.decode(t.responseText);
					}

					
					
					if (!json) {
						cleanOptions(s);
						setError(s);
						return false;
					}
					
					if (!json.results) {
						cleanOptions(s);
						setError(s);
						return false;						
					}

					cleanOptions(s);
					opt = document.createElement('OPTION');
                                        opt.appendChild(document.createTextNode("Choose"));
                                        opt.setAttribute('value',"");
                                        s.appendChild(opt);

					for (var i = 0; i < json.results.length; i++) {
						
						o = json.results[i];
						opt = document.createElement('OPTION');
						opt.appendChild(document.createTextNode(o.name));
						opt.setAttribute('value',o.value);
						s.appendChild(opt);
						
					}
					
				},
				failure: function() {
						cleanOptions(s);
						setError(s);
						return false;
					
				}
		});
		
	}

};

function cleanOptions(el) {

	while(el.firstChild) {
	
		el.removeChild(el.firstChild);
	
	}

};

function setLoading(el) {
	opt = document.createElement('OPTION');
	opt.appendChild(document.createTextNode("Loading..."));
	opt.setAttribute('selected','selected');
	el.appendChild(opt);
	
};

function setError(el) {
	opt = document.createElement('OPTION');
	opt.appendChild(document.createTextNode("Error..."));
	opt.setAttribute('selected','selected');
	el.appendChild(opt);
	
};

