function getFromAJAX(into,req){
	//alert(req);
	var
    // assegnazione oggetto XMLHttpRequest
    ajax = getXMLHttpRequest();
  
  // se l'oggetto XMLHttpRequest non è nullo
  if(ajax) {	  
    // impostazione richiesta asincrona in GET
    // del file specificato
    ajax.open("post", req, true);

    // rimozione dell'header "connection" come "keep alive"
    ajax.setRequestHeader("connection", "close");

    // impostazione controllo e stato della richiesta
    ajax.onreadystatechange = function() {
      
      // verifica dello stato
      if(ajax.readyState === readyState.COMPLETATO) {
        // verifica della risposta da parte del server
        if(statusText[ajax.status] === "OK"){
          // operazione avvenuta con successo
          into.innerHTML = ajax.responseText;
		  
		}
		  
        else {
          // errore di caricamento
          into.innerHTML = "Impossibile effettuare l'operazione richiesta.<br />";
          into.innerHTML += "Errore riscontrato: " + statusText[ajax.status];
        }
      } 
    }
    // invio richiesta
    ajax.send(null);
  } 	
	
}

function addToCart(name_form){
	
	var formAddItem = document.getElementById(name_form);
	var qta = prompt('Quantita\' di prodotto', '1');
	if(qta && qta != '0'){
		formAddItem.item_times.value = qta
		formAddItem.submit();
	}

}


function getData(id){
	var
	req = "modules/cart/getUser.php?id="+id,
	elemento = prendiElementoDaId("dati_spedizione");	
	getFromAJAX(elemento,req);	
}

function openDescrMorePrjs(id){
	var
	req = "modules/project/printDescrMore.php?id="+id+"&open=true",
	elemento = prendiElementoDaId("project_descr_more");	
	getFromAJAX(elemento,req);	
}
function closeDescrMorePrjs(id){
	var
	req = "modules/project/printDescrMore.php?id="+id+"&open=false",
	elemento = prendiElementoDaId("project_descr_more");	
	getFromAJAX(elemento,req);	
}
function openMorePrj(id){
	var
	req = "modules/project/printMore.php?id="+id+"&open=true",
	elemento = prendiElementoDaId("project_more");	
	getFromAJAX(elemento,req);	
}

function closeMorePrj(id){
	var
	req = "modules/project/printMore.php?id="+id+"&open=false",
	elemento = prendiElementoDaId("project_more");	
	getFromAJAX(elemento,req);	
}


function openMorePrds(id){
	var
	req = "modules/producer/printMore.php?id="+id+"&open=true",
	elemento = prendiElementoDaId("producer_moreproduct");	
	getFromAJAX(elemento,req);	
}

function closeMorePrds(id){
	var
	req = "modules/producer/printMore.php?id="+id+"&open=false",
	elemento = prendiElementoDaId("producer_moreproduct");	
	getFromAJAX(elemento,req);	
}

function openProjectPrds(id){
	var
	req = "modules/producer/printProject.php?id="+id+"&open=true",
	elemento = prendiElementoDaId("producer_project");	
	getFromAJAX(elemento,req);	
}

function closeProjectPrds(id){
	var
	req = "modules/producer/printProject.php?id="+id+"&open=false",
	elemento = prendiElementoDaId("producer_project");	
	getFromAJAX(elemento,req);	
}

function openVineyardPrds(id){
	var
	req = "modules/producer/printVineyard.php?id="+id+"&open=true",
	elemento = prendiElementoDaId("producer_vineyard");	
	getFromAJAX(elemento,req);	
}

function closeVineyardPrds(id){
	var
	req = "modules/producer/printVineyard.php?id="+id+"&open=false",
	elemento = prendiElementoDaId("producer_vineyard");	
	getFromAJAX(elemento,req);	
}


function openWcellarPrds(id){
	var
	req = "modules/producer/printWcellar.php?id="+id+"&open=true",
	elemento = prendiElementoDaId("producer_wcellar");	
	getFromAJAX(elemento,req);	
}

function closeWcellarPrds(id){
	var
	req = "modules/producer/printWcellar.php?id="+id+"&open=false",
	elemento = prendiElementoDaId("producer_wcellar");	
	getFromAJAX(elemento,req);	
}


function openDescrMore(id){
	var
	req = "modules/producer/printDescrMore.php?id="+id+"&open=true",
	elemento = prendiElementoDaId("producer_more");	
	getFromAJAX(elemento,req);	
}

function closeDescrMore(id){
	var
	req = "modules/producer/printDescrMore.php?id="+id+"&open=false",
	elemento = prendiElementoDaId("producer_more");	
	getFromAJAX(elemento,req);	
}

function openProducers(id){
	var
	req = "modules/producer/printProducers.php?id="+id,
	elemento = prendiElementoDaId("print_producers");	
	getFromAJAX(elemento,req);	
}
function closeProducers(id){
	var
	req = "modules/producer/printProducers.php?close=true&id="+id,
	elemento = prendiElementoDaId("print_producers");
	getFromAJAX(elemento,req);	
}

function openVineyards(id){
	var
	req = "modules/vineyard/printVineyard.php?id="+id,
	elemento = prendiElementoDaId("print_vineyards");
	getFromAJAX(elemento,req);	
}
function closeVineyards(id){
	var
	req = "modules/vineyard/printVineyard.php?close=true&id="+id,
	elemento = prendiElementoDaId("print_vineyards");
	getFromAJAX(elemento,req);	
}

function openWcellars(id){
	var
	req = "modules/wcellar/printWcellar.php?id="+id,
	elemento = prendiElementoDaId("print_wcellars");
	getFromAJAX(elemento,req);	
}
function closeWcellars(id){
	var
	req = "modules/wcellar/printWcellar.php?close=true&id="+id,
	elemento = prendiElementoDaId("print_wcellars");
	getFromAJAX(elemento,req);	
}

function openProjects(id){
	var
	req = "modules/project/printProjects.php?id="+id,
	elemento = prendiElementoDaId("print_projects");
	getFromAJAX(elemento,req);	
}
function closeProjects(id){
	var
	req = "modules/project/printProjects.php?close=true&id="+id,
	elemento = prendiElementoDaId("print_projects");
	getFromAJAX(elemento,req);	
}

function openMore(id){
	var
	req = "modules/product/printMore.php?id="+id,
	elemento = prendiElementoDaId("print_more");
	getFromAJAX(elemento,req);	
}
function closeMore(id){
	var
	req = "modules/product/printMore.php?close=true&id="+id,
	elemento = prendiElementoDaId("print_more");
	getFromAJAX(elemento,req);	
}
function updateCat(cat){
	var
	//req = "modules/search/getReg.php?nat="+nat,
	elemento 	= prendiElementoDaId("hiddenfld2"),
	sel_cat 	= prendiElementoDaId("search_categoria"),	
	step 		= prendiElementoDaId("step"),	
	formSearch = prendiElementoDaId("form_update");	
	step.value 	= 3;
	elemento.value = sel_cat.value;
				
	formSearch.submit();
	//getFromAJAX(elemento,req);	
}
function updateNation(nat){
	var
	//req = "modules/search/getReg.php?nat="+nat,
	elemento 	= prendiElementoDaId("hiddenfld0"),
	sel_naz 	= prendiElementoDaId("search_nazione"),	
	step 		= prendiElementoDaId("step"),	
	formSearch = prendiElementoDaId("form_update");
		
	step.value 	= 1;
	elemento.value = sel_naz.value;

	formSearch.submit();
	
	//getFromAJAX(elemento,req);	
}
function updateRegion(reg){
	var
	//req = "modules/search/getCat.php?reg="+reg,
	elemento 	= prendiElementoDaId("hiddenfld1"),
	sel_reg 	= prendiElementoDaId("search_regione"),	
	step 		= prendiElementoDaId("step"),	
	formSearch = prendiElementoDaId("form_update");	
	step.value 	= 2;
	elemento.value = sel_reg.value;
				
	formSearch.submit();
	
	//getFromAJAX(elemento,req);	
}
function updateType(typ){
	var
//	req = "modules/search/getType.php?type="+typ,
	elemento 	= prendiElementoDaId("hiddenfld3"),
	sel_typ 	= prendiElementoDaId("search_type"),	
	step 		= prendiElementoDaId("step"),	
	formSearch = prendiElementoDaId("form_update");	
	step.value 	= 4;
	elemento.value = sel_typ.value;
	
				
	formSearch.submit();
	
//	getFromAJAX(elemento,req);	
}
var pupProduct=0;
function printProduct(id){
	if(pupProduct)
	  {
		if(!pupProduct.closed) pupProduct.close();
	  }
	  pupProduct = open('modules/product/printable.php?id='+id, 'pupProduct', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+550+',height='+600+',left='+100+', top='+100+',screenX='+100+',screenY='+100+'');
}
function printProducer(id){
	if(pupProduct)
	  {
		if(!pupProduct.closed) pupProduct.close();
	  }
	  pupProduct = open('modules/producer/printable.php?id='+id, 'pupProducer', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+550+',height='+600+',left='+100+', top='+100+',screenX='+100+',screenY='+100+'');
}

var pupPDF=0;
function getPDFAgenti(){
	if(pupPDF)
	  {
		if(!pupPDF.closed) pupPDF.close();
	  }
	  pupPDF = open('modules/user/printablepdf.php', 'pupPDF', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+550+',height='+600+',left='+100+', top='+100+',screenX='+100+',screenY='+100+'');

}
function pdfProduct(id){
	if(pupPDF)
	  {
		if(!pupPDF.closed) pupPDF.close();
	  }
	  pupPDF = open('modules/product/printablepdf.php?id='+id, 'pupPDF', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+550+',height='+600+',left='+100+', top='+100+',screenX='+100+',screenY='+100+'');
}
function pdfProducer(id){
	if(pupPDF)
	  {
		if(!pupPDF.closed) pupPDF.close();
	  }
	  pupPDF = open('modules/producer/printablepdf.php?id='+id, 'pupPDF', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+550+',height='+600+',left='+100+', top='+100+',screenX='+100+',screenY='+100+'');
}

var pupAdmin=0;
function openAdminEdit(id){
	if(pupAdmin)
	  {
		if(!pupAdmin.closed) pupAdmin.close();
	  }
	  pupAdmin = open('modules/admin/admin.php?fast=true&mod=product&action=edit&id='+id, 'pupAdmin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+750+',height='+600+',left='+100+', top='+100+',screenX='+100+',screenY='+100+'');
}
function openAdminEditProd(id){
	if(pupAdmin)
	  {
		if(!pupAdmin.closed) pupAdmin.close();
	  }
	  pupAdmin = open('modules/admin/admin.php?fast=true&mod=producer&action=edit&id='+id, 'pupAdmin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+750+',height='+600+',left='+100+', top='+100+',screenX='+100+',screenY='+100+'');
}
function openAdmin(){
	if(pupAdmin)
	  {
		if(!pupAdmin.closed) pupAdmin.close();
	  }
	  pupAdmin = open('modules/admin/admin.php?mod=product&action=show', 'pupAdmin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+750+',height='+600+',left='+100+', top='+100+',screenX='+100+',screenY='+100+'');
}