CategorySearch = {
	init: function() {
		var pars = 'category_id=0';
		var opt  = {
			method:'post',
			postBody: pars,
			evalScripts: true,
			onSuccess: function(xml) {
				comboObj = $('combo2');
				while(comboObj.length>1) {
					comboObj.options[1] = null;
				}
				/*comboObj = $('combo3');
				while(comboObj.length>1) {
					comboObj.options[1] = null;
				}*/
				CategorySearch.selectBuilder(xml,'combo1');
			}
		}
		new Ajax.Request(lcg_url,opt);
	},
	selectBuilder: function(xml,combo) {
		var comboObj = $(combo);
		while(comboObj.length>0) {
			comboObj.options[0] = null;
		}
		pNode = xml.responseXML.getElementsByTagName("option");
		for(i=0; i<pNode.length; i++) {
			value = pNode[i].getAttributeNode('value').nodeValue;
			if ( pNode[i].getAttributeNode('selected') )
				selected = pNode[i].getAttributeNode('selected').nodeValue;
			text = pNode[i].firstChild.nodeValue
			comboObj.options[comboObj.length] = new Option(text,value);
		}
	},
	selectUpdate: function(combo,valor) {
		var comboObj = $(combo);
		//alert(comboObj.options[comboObj.selectedIndex]);
		for(i=0; i<comboObj.length; i++) {
			if(comboObj.options[i].value == valor) {
				comboObj.options[i].selected=true;
			}
		}
	}, 
	combobox: function(objeto, campo) {
		if ( !objeto || !campo ) {
			return false;
		}
		var selecionado = $F(objeto);
		var comboObj = null;
		switch ( campo ) {
			case 'combo1':
				comboObj = $('combo1');
				while(comboObj.length>1) {
					comboObj.options[1] = null;
				}
			case 'combo2':
				comboObj = $('combo2');
				while(comboObj.length>1) {
					comboObj.options[1] = null;
				}
			/*case 'combo3':
				comboObj = $('combo3');
				while(comboObj.length>1) {
					comboObj.options[1] = null;
				}*/
		}
		if ( selecionado == 0 ) return false;
		var pars = 'category_id='+selecionado;
		var opt  = {
			method:'post',
			postBody: pars,
			evalScripts: true,
			onSuccess: function(xml) {
				CategorySearch.selectBuilder(xml,campo);
			}
		}
		new Ajax.Request(lcg_url,opt);
	}
}

Event.observe(window,'load',CategorySearch.init);