//=============== ULTITA' GENERALI
function OpenInsertComment(iddiv){
    if (document.getElementById(iddiv).style.display=="block") document.getElementById(iddiv).style.display="none";
    else document.getElementById(iddiv).style.display="block";       
}

//=============== ARCHIVIO ARTICOLI

   function FiltroFormArticoli(context){

       titolo_testo= document.getElementById('articolo_input_titolo_testo');
       if(titolo_testo.value=='') document.getElementById('titolo_testo').value='({s:'+context+',unset})';
       else document.getElementById('titolo_testo').value='({s:'+context+','+titolo_testo.value+'})';

       return true;  
   }

   function ResetArticoliFormArticoli(context){

       document.getElementById('titolo_testo').value='({s:'+context+',unset})';
      
       return true;  
   }


//============================= INSERIMENTO ARTICOLO
function impacchetta_dati_articolo(){

//============== CONTROLLO INSERIMENTO DATI
   if (document.getElementById("titolo").value=="") { alert("Registrazione interrotta: Nessun Titolo impostato!"); return false};
   var rubriche = document.getElementsByName("rubrica");
   var rubrichevuote = 0;
   for (i=0; i<rubriche.length;i++){
         if (rubriche[i].checked== true) rubrichevuote = rubrichevuote +1; 
   }
   if (rubrichevuote==0) { alert("Registrazione interrotta: Nessuna Rubrica Impostata!"); return false};

  
//============== ARRAYZZO I DATI
//============== Recupero tutti i dati dalle OTables
   
   var ARubriche= new Array ();

   for (i=0; i<rubriche.length;i++){
       if (rubriche[i].checked== true) ARubriche[i] = [rubriche[i].id];
   }
   document.getElementById('rubriche').value = $.toJSON(ARubriche);

   return true;
}

//==================== SHOW MINI ARTICOLI

 function submit_select_rubrica(context){

       rubrica_id= document.getElementById('form_select_rubrica').rubrica_id;
       select_rubrica_value= document.getElementById('select_rubrica').value;
       rubrica_id.value='({s:'+context+','+select_rubrica_value+'})';

       return true;  
   }

 function submit_select_speciale(context){

       rubrica_id= document.getElementById('form_select_speciale').rubrica_id;
       select_speciale_value= document.getElementById('select_speciale').value;
       rubrica_id.value='({s:'+context+','+select_speciale_value+'})';

       return true;  
   }

 function submit_select_territorio(context){

       territorio_id= document.getElementById('territorio_id');
       select_territorio_value= document.getElementById('select_territorio').value;
       territorio_id.value='({s:'+context+','+select_territorio_value+'})';

       return true;  
   }

function abilitahtml(obj){
   var toolbars = document.getElementsByTagName("tr");
   if (obj.checked==true){
       for (i=0;i<toolbars.length;i++) {if (toolbars[i].className=="toolbar") toolbars[i].style.display ="none";}
    }else{
           for (i=0;i<toolbars.length;i++) {if (toolbars[i].className=="toolbar") toolbars[i].style.display ="";}
       }
}
