// Function.js

var timerid;

var comuneistat = "0";

/*

function startCicloRefresh() {
   timerid = setInterval("aggiornaPagina()",10000);
}

function stopCicloRefresh() {
   clearTimeout(timerid);
}

function aggiornaPagina() {
  if (window.parent.frames["menu"].SceltaAffluenza) {
    window.parent.frames['content'].location.href = "aff_" + comuneistat + ".htm";
  }
  else if (window.parent.frames["menu"].SceltaListe) {
   window.parent.frames['content'].location.href = "liste_" + comuneistat + ".htm";
  }
  else {
    window.parent.frames['content'].location.href = "cand_" + comuneistat + ".htm";
  }
}  
*/



/* Funzioni per mostrare, a seconda del tasto premuto, i risultati di affluenza / liste / candidati */
function mostraAffluenza() {
   // Imposta il pulsante attivo
   document.getElementById('affbutton').className = "menuattivo";
   document.getElementById('listebutton').className = "menu";
   document.getElementById('candbutton').className = "menu";
   
   //startCicloRefresh();
   window.parent.frames["scelta"].location.href = "about:blank";
   
   window.parent.frames["menu"].SceltaAffluenza = true;
   window.parent.frames["menu"].SceltaListe = false;
   window.parent.frames["menu"].SceltaCand = false;
   mostraComune();
}

function mostraListe() {
   // Imposta il pulsante attivo
   document.getElementById('affbutton').className = "menu";
   document.getElementById('listebutton').className = "menuattivo";
   document.getElementById('candbutton').className = "menu";
   
   //startCicloRefresh();
   
   window.parent.frames["scelta"].location.href = "sceltaliste.htm";
   
   window.parent.frames["menu"].SceltaAffluenza = false;
   window.parent.frames["menu"].SceltaListe = true;
   window.parent.frames["menu"].SceltaCand = false;
   mostraComune();
}

function mostraCand() {
   // Imposta il pulsante attivo
   document.getElementById('affbutton').className = "menu";
   document.getElementById('listebutton').className = "menu";
   document.getElementById('candbutton').className = "menuattivo";
   
   //startCicloRefresh();
 
   window.parent.frames["scelta"].location.href="sceltacand.htm";
   
   window.parent.frames["menu"].SceltaAffluenza = false;
   window.parent.frames["menu"].SceltaListe = false;
   window.parent.frames["menu"].SceltaCand = true;
   mostraComune();
}


/*
 * Aggiorna il frame "content" visualizzando il comune selezionato nel combo
 */
function mostraComune() {
   
  // window.parent.frames["menu"].document.links[0].href= "aff_" + "0" + ".htm";
  window.parent.frames["menu"].document.links[0].href= "../affluenze/AFFL.HTM"+"?tmptoken="+Math.floor(Math.random()*100000);
  window.parent.frames["menu"].document.links[1].href= "liste_" + "0" + ".htm"+"?tmptoken="+Math.floor(Math.random()*100000);
  window.parent.frames["menu"].document.links[2].href= "IndexCandidati.htm"+"?tmptoken="+Math.floor(Math.random()*100000);
 
  var combo;
  var comuneistat = "0"
  
  combo = document.getElementById('cod_com');
  if (combo != null)
     comuneistat = combo[combo.selectedIndex].value;  

  
  if (window.parent.frames["menu"].SceltaAffluenza) {
     //window.parent.frames['content'].location.href = "aff_" + comuneistat + ".htm"+"?tmptoken="+Math.floor(Math.random()*100000);
     window.parent.frames['content'].location.href = "../../affluenze/AFFL.HTM"+"?tmptoken="+Math.floor(Math.random()*100000);
  }
  else if (window.parent.frames["menu"].SceltaListe) {
     window.parent.frames['content'].location.href = "liste_" + comuneistat + ".htm"+"?tmptoken="+Math.floor(Math.random()*100000);
  }
  else {
     window.parent.frames['content'].location.href = "IndexCandidati.htm?comuistat=" + comuneistat + "&tmptoken="+Math.floor(Math.random()*100000);
  }
 
}