function ctrl_occurency(idnumero,listaid){
	
	var array = new Array();
	
	array=listaid.split(",");

	for(i=0;i<array.length;i++){
		 
		 if (array[i]==idnumero){return true;}
		 }
	return false;
	}
	
function addText(){
	    
		/*Se il numero non è contenuto nella lista*/
		var cic = document.getElementById('autore').value;
		tmp3=cic.split("#");
		//alert(tmp3);
		if(ctrl_occurency(tmp3[0],document.getElementById('listaID').value)==false){
	//alert(cic);
		/*se il campo degli autori non è vuoto concatena la virgola*/
		if (document.getElementById('lista').value != '') 
	    {
	    document.getElementById('lista').value += ",";
	    document.getElementById('listaID').value += ",";
	    }
	    tmp = document.getElementById('autore').value;
	    //alert(tmp);
	    tmp2 = tmp.split("#");

	    document.getElementById('lista').value += tmp2[1]; 
	    document.getElementById('listaID').value += tmp2[0];} 

   }
function removeText(){
		/*se il campo degli autori non è vuoto allora lo elimino*/
		if(document.getElementById('lista').value != ''){
			
			var s= document.getElementById('lista').value;
			var nomi = new Array();
			nomi = s.split(",");
			nomi.length=nomi.length-1;
			document.getElementById('lista').value=nomi.join(',');
			
			var s1= document.getElementById('listaID').value;
			var id = new Array();
			id = s1.split(",");
			id.length=id.length-1;
			document.getElementById('listaID').value=id.join(',');
		}
}
function openGallery(url)
{window.open(url,'' , 'width=600,height=600,scrollbars=yes');}

function feedback(testo) {
	return(window.confirm(testo));
}
