function LoadDataAJX(current) {
	var lang = current.options[current.selectedIndex].value;

	if (lang != "") {
	document.getElementById("result_id_localita").innerHTML = "Fetching " + lang;

	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=prov&prov=" + qs;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("result_id_localita").innerHTML =rqo.responseText;
	return false;
	}
}

function CheckUsername(current) {
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=user&user=" + qs;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("userfield").innerHTML ="<b>Username:</b>&nbsp;<input onchange=\"CheckUsername(this)\"; class=\"field\" type=\"text\" size=\"38\" name=\"username\" value=\""+ lang +"\"/>&nbsp;&nbsp;"+rqo.responseText;
	return false;
}

function ListaFileCategorie(current)
{
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=filelist&cid=" + qs ;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_file").innerHTML =rqo.responseText;
	document.getElementById("file_prods").innerHTML  = "";
	return false;	
}
function ListaFileByCat(current)
{
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=listf&id=" + qs ;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("file_prods").innerHTML =rqo.responseText;
	return false;	
}

function CancellaAssociazioneFile(idcont, idfile)
{
	var rqo = new XMLHttpRequest();
	
	var qry = "index.php?mod=data&actions=delasfp&fid=" + idfile + "&id=" + idcont;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("file_prods").innerHTML =rqo.responseText;	
}

function CheckMail(current) {
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=mail&mail=" + qs;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("mailfield").innerHTML ="<input onchange=\"CheckMail(this)\"; class=\"field\" type=\"text\" size=\"46\" name=\"email\" value=\""+ lang +"\"/>&nbsp;&nbsp;"+rqo.responseText;
	return false;
}

function CheckPIVA(current) {
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=piva&piva=" + qs;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("pivafield").innerHTML ="<input onChange=\"CheckPIVA(this);\" class=\"field\" type=\"text\" size=\"40\" name=\"partita_iva\" value=\""+ lang +"\"/>&nbsp;&nbsp;"+rqo.responseText;
	return false;
}

function CheckCodiceProdotto(current) {
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=ckcodpro&id=" + qs;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("codprofield").innerHTML ="<input onChange=\"CheckCodiceProdotto(this);\" class=\"field\" type=\"text\" size=\"80\" name=\"codice_prodotto\" value=\""+ lang +"\"/>&nbsp;&nbsp;"+rqo.responseText;
	return false;
}

function ListaImmagini(current) {
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=listimg&id=" + qs;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("box_lista_immagini").innerHTML =rqo.responseText;
	return false;
}

function ListaCategorie(current) {
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=catlist&man=" + qs;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("select_cat_list").innerHTML =rqo.responseText;
	return false;
}

function EliminaImmagine(current) {
	var rqo = new XMLHttpRequest();
	var qry = "index.php?mod=data&actions=delimg&id=" + current;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("box_lista_immagini").innerHTML =rqo.responseText;
	return false;
}

function EliminaAssociazioneImmagine(idprodo,idimg) {
	var rqo = new XMLHttpRequest();
	var qry = "index.php?mod=data&actions=imgdelas&id=" + idprodo + "&img=" + idimg;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("box_lista_immagini").innerHTML =rqo.responseText;
	return false;
}

function ListaProdotti(current,man) {
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var mlang = encodeURIComponent(man);
	var qry = "index.php?mod=data&actions=prodlist&cid=" + qs + "&man=" + mlang;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_prodotti_box").innerHTML =rqo.responseText;
	return false;
}

function ListaProdotti3(current,man) {
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var mlang = encodeURIComponent(man);
	var qry = "index.php?mod=data&actions=prodlist&cid=" + qs + "&man=" + mlang;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_prodotti_box").innerHTML =rqo.responseText;
	return false;
}

function ListaProdotti2(current,man) {
	
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(current);
	var mlang = encodeURIComponent(man);
	var qry = "index.php?mod=data&actions=prodlist2&cid=" + qs + "&man=" + mlang;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_prodotti_box").innerHTML =rqo.responseText;
	return false;
}

function ListaProdoByCatAndManInImages(category,man) {
	var cat;
	var man2;
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);
	var qry = "index.php?mod=data&actions=lppimg&cid=" + qs + "&man=" + mlang;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_prodotti_box").innerHTML =rqo.responseText;
	return false;
}

function ListaProdoByCatAndManInImagesCheckBox(category,man) {
	var cat;
	var man2;
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);
	var qry = "index.php?mod=data&actions=lppimgch&cid=" + qs + "&man=" + mlang;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_prodotti_check").innerHTML =rqo.responseText;
	return false;
}

function ListaFamiglie(current) {
	
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var qry = "index.php?mod=data&actions=famlist&man=" + qs 
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_famiglie").innerHTML =rqo.responseText;
	return false;
}

function AggiornaPrioritaCategoria(current,cat) {	
	var lang = current.value;
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(lang);
	var cid = encodeURIComponent(cat);
	var qry = "index.php?mod=data&actions=updpriorita&value=" + qs 	+ "&cid=" + cid;
	rqo.open('GET',qry,false);
	rqo.send(null);	
	document.getElementById("catresult").innerHTML = rqo.responseText;
	return false;
}

function IncrementOrderProdo(category,manifacture,product) {
	var rqo = new XMLHttpRequest();
	var cat = encodeURIComponent(category);
	var man = encodeURIComponent(manifacture);
	var id = encodeURIComponent(product);
	var qry = "index.php?mod=data&actions=incprodord&cid=" + cat + "&man=" + man + "&id=" + id;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_prodotti_box").innerHTML =rqo.responseText;
	return false;
}

function DecrementOrderProdo(category,manifacture,product) {
	var rqo = new XMLHttpRequest();
	var cat = encodeURIComponent(category);
	var man = encodeURIComponent(manifacture);
	var id = encodeURIComponent(product);
	var qry = "index.php?mod=data&actions=decprodord&cid=" + cat + "&man=" + man + "&id=" + id;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_prodotti_box").innerHTML =rqo.responseText;
	return false;
}

function ListaFileFilter(category,man) {
	var cat;
	var man2;
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);
	var qry = "index.php?mod=data&actions=listfiles&cid=" + qs + "&man=" + mlang;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_files").innerHTML =rqo.responseText;
	return false;
}



function ListaFileFilterAs(category,man) {
	var cat;
	var man2;
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);
	var qry = "index.php?mod=data&actions=asscf&cid=" + qs + "&man=" + mlang;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_files").innerHTML =rqo.responseText;
	return false;
}

function ListaCategorieProduttore(man,category) {
	var cat;
	var man2;
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);
	var qry = "index.php?mod=data&actions=lcpfile&cid=" + qs + "&man=" + mlang;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("list_cat_prodo").innerHTML =rqo.responseText;
	return false;
}


function ListaProdottiByCategorieAndFile(category, man) {
	
	var cat;
	var man2;
	if(category != null)
		cat = category.value;
	else cat = 0;	
	if( man != null)
		man2 = man.value;
	else man2=0;
	
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);
	
	var qry = "index.php?mod=data&actions=lpfcat&cid=" + qs +"&man=" + mlang;
	
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_prodotti").innerHTML =rqo.responseText;
	return false;
}

function CancellaFile(codicefile,category,man)
{
	var cat;
	var man2;
	
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var qs2 = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);	
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(codicefile);
	var qry = "index.php?mod=data&actions=delfile&id=" + qs + "&man="+mlang + "&cid=" +qs2;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_files").innerHTML =rqo.responseText;
	return false;
}

function AbilitaFile(codicefile,category,man)
{
	var cat;
	var man2;
	
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var qs2 = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);	
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(codicefile);
	var qry = "index.php?mod=data&actions=enafile&id=" + qs + "&man="+mlang + "&cid=" +qs2;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_files").innerHTML =rqo.responseText;
	return false;
}

function DisabilitaFile(codicefile,category,man)
{
	var cat;
	var man2;
	
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var qs2 = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);	
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(codicefile);
	var qry = "index.php?mod=data&actions=disfile&id=" + qs + "&man="+mlang + "&cid=" +qs2;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_files").innerHTML =rqo.responseText;
	return false;
}

function AuthFile(codicefile,category,man)
{
	var cat;
	var man2;
	
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var qs2 = encodeURIComponent(cat);
	var mlang = encodeURIComponent(man2);	
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(codicefile);
	var qry = "index.php?mod=data&actions=authfile&id=" + qs + "&man="+mlang + "&cid=" +qs2;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_files").innerHTML =rqo.responseText;
	return false;
}

function CatFile(codicefile,newcat,category,man)
{
	var cat;
	var man2;
	var catn;
	
	
	catn = newcat.value;
		
	if(category != null)
		cat = category.value;
		
	if( man != null)
		man2 = man.value;
		
	var qs2 = encodeURIComponent(cat);
	var qs3 = encodeURIComponent(catn);
	var mlang = encodeURIComponent(man2);	
	
	var rqo = new XMLHttpRequest();
	var qs = encodeURIComponent(codicefile);
	var qry = "index.php?mod=data&actions=catfile&id=" + qs + "&cid=" + cat + "&id2=" + catn + "&man=" + mlang;
	rqo.open('GET',qry,false);
	rqo.send(null);
	document.getElementById("lista_files").innerHTML =rqo.responseText;
	return false;
}
