function setCarrello(){
	

	$(".js_btn_add_carrello").click(function() {
		actionCarrello(this, "item.add.php", 'add');
	});
	$(".js_btn_add_carrello_view").click(function() {
		actionCarrello(this, "item.add.php", 'add_view');
	});
	
	$(".js_btn_remove_carrello").click(function() {
		actionCarrello(this, "item.remove.php",'remove');
	});
	$(".js_btn_delete_carrello").click(function() {
		actionCarrello(this, "item.delete.php",'delete');
	});
	
}
function actionCarrello(elemento, url, provenienza){
	
	
		var id_prodotto    = $(elemento).attr('id');
		var tipo_prodotto  = $(elemento).attr('tipo_prodotto');
		var descrizione    = $(elemento).attr('descrizione');
		

		
		var errore = '';
		
		if (id_prodotto == "" ) {
			errore += "id_prodotto"+'<br>';
		}
		
		if (tipo_prodotto == "") {
			errore += "tipo_prodotto"+'<br>';
		}

		
		if (descrizione == "" ) {
			errore += "decsrizione"+'<br>';
		}
		
		
		
		if(errore != ''){
			/*
			ci sono degli errori
			*/
			alert(errore);
			chiamaBlockUI("ERRORE", errore);
			return false;	
		}
		
		
		
		var dataString = 'id_prodotto='+id_prodotto;
			dataString  += '&tipo_prodotto='+tipo_prodotto;		
			dataString  += '&descrizione='+descrizione;
			
			
		chiamaBlockUILoadin("CARRELLO", "carico");	
		
		$.ajax({
			type: "POST",
			url: BASE_URL+url,
			data: dataString,
			success: function(msg) {
								
                $.unblockUI();

				if(msg != 'OK'){
					chiamaBlockUI("CARRELLO", msg);
				}else{
					if(provenienza == 'add_view' || provenienza == 'delete' || provenienza == 'remove'){
						document.location.href = document.location.href;
					}	
				}
				
				
				
			}
		});
		return false;
}
