function _startLoadCat(idc,idlingua,typ,afterSubmit) {
	
	var rand_no = Math.random();
	
	//typ=idcats_merce oppure idcats_marca
	sSrc = "/include/mod/layout1/comp/shopping/LoadCatShop_ajax.jsp?"+typ+"="+idc+"&lang="+idlingua+"&rnd="+rand_no;
	//alert(sSrc)

	var xmlHttp = XmlHttp.create();
	xmlHttp.open("GET", sSrc, true);	// async
	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState == 4) {
			//alert(idc+"\n\n"+xmlHttp.responseText)
			_catLoaded(xmlHttp.responseXML,typ,idc);// NOTA responseXML
			
			if(afterSubmit)//dopo il submit devo ri-selezionare nelle select le idcats_marce e idcats_merce passate dal form 
				reSelectedAfterSubmit()
		}
	};
	// call in new thread to allow ui to update
	window.setTimeout(function () {
		xmlHttp.send(null);
	}, 10);

}

function _catLoaded(oXmlDoc,typ,idc) 
{
	//alert(idc+"\n\n"+oXmlDoc)
	if(oXmlDoc)
		buildSelectBox(oXmlDoc,typ);
}

function buildSelectBox(oXmlDoc,typ,idc) 
{  	
	//se passo una idcats_merce devo aggiornare la lista marche e viceversa
	f= document.forms['formshop']
	if(typ=='idcats_merce')
	{
		container_select='select_ajax_marca'
		sbox = document.getElementById('idcats_marca')
		sbox.name = 'idcats_marca'; 
		//alert("marca:"+f.idcats_marca.value)
		last_selected_val=f.idcats_marca.value;
		if(idc!=0)
			loadingSelect(f.idcats_marca);
		else
			loadingSelect(f.idcats_merce);
	}
	else
	{
		container_select='select_ajax_merce'
		sbox = document.getElementById('idcats_merce');
		sbox.name = 'idcats_merce'; 
		//alert("merce:"+f.idcats_merce.value)
		last_selected_val=f.idcats_merce.value;
		if(idc!=0)
			loadingSelect(f.idcats_merce);
		else
			loadingSelect(f.idcats_marca);
	}
	
	sbox.className='field' 

	var opts = oXmlDoc.getElementsByTagName('option'); 

	sbox.options.length = 0;  //svuoto select
	for (var i = 0; i < opts.length; i++) 
	{    
		var op = new Option(unescape(opts[i].getElementsByTagName('label').item(0).firstChild.data), unescape(opts[i].getElementsByTagName('value').item(0).firstChild.data),false, false);
		sbox.options[sbox.length] = op;   
	}   
	
	//if(opts.length>1)
	document.getElementById(container_select).appendChild(sbox); 
	
	//Se NON faccio submit e ripo devo ri-selezionare nelle select le idcats_marce e idcats_merce passate dal form 
	//alert(last_selected_val)
	for (var i = 0; i < sbox.length; i++) 
	{
		if(sbox.options[i].value==last_selected_val)
			sbox.options[i].selected = true; 
	}
	
}

