var delay = 4500; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)
var fwidth='180px'; //set scroller width
var fheight='180px'; //set scroller height
var fadelinks=1;  //should links inside scroller content also fade like text? 0 for no, 1 for yes.
var faderdelay=0;
var index=0;

var sw_news=0;

var num_div=0;

var timer;

function switch_news() {
  imago=document.getElementById('IDMGPP');
  a=index;
  if(sw_news==0) {
    if(a==0) {
      a=num_div;
    }
    clear_ini(a-1);
    sw_news=1;
    imago.src='imago/play.gif';
  } else {
    changecontent();
    sw_news=0;
    imago.src='imago/pause.gif';
  }
}

//lancia changecontent
function ini_content() {
  num_div=0;
  while((obj_div_pre=document.getElementById('id'+num_div))!=null) {
    num_div++;
  }
  
  linkcolorchange();
  changecontent();
}

//se stoppa il timer sulla pagina selezionata
function clear_ini(j) {
  clearTimeout(timer);
  
  i=0;
  while((obj_div_pre=document.getElementById('id'+i))!=null) {
    obj_div_pre.style.display='none';    

    obj_num_pre=document.getElementById('IDNUM_'+i);
    obj_num_pre.style.fontSize='12px';
    obj_num_pre.style.fontWeight='normal';
    obj_num_pre.style.color='#000000';
    i++;
  }
  obj_div_sing=document.getElementById('id'+j);
  obj_div_sing.style.display='block';
    
  obj_num_sing=document.getElementById('IDNUM_'+j);
  obj_num_sing.style.fontSize='18px';
  obj_num_sing.style.fontWeight='bold';
  obj_num_sing.style.color='#0082C3';

  //fade(j);
  imago=document.getElementById('IDMGPP');
  imago.src='imago/play.gif';
  sw_news=1;
  
  index=j;
}

hex=255;
function fade(index) {
  if(hex>0) { //If color is not black yet
    hex-=8; // increase color darkness
    document.getElementById("id"+index).style.color="rgb("+hex+", "+hex+", "+hex+")";
		
    setTimeout("fade("+index+")",25); 
  }
  else {
    hex=255; //reset hex value
  }
}

//function cambia contenuto
function changecontent() {
  i=0;
  while((obj_div_pre=document.getElementById('id'+i))!=null) {
    obj_div_pre.style.display='none';
    
    obj_num_pre=document.getElementById('IDNUM_'+i);
    obj_num_pre.style.fontSize='12px';
    obj_num_pre.style.fontWeight='normal';
    obj_num_pre.style.color='#000000';
    
    i++;
  }
  
  obj_div_sing=document.getElementById('id'+index);
  obj_div_sing.style.display='block';
  
  obj_num_sing=document.getElementById('IDNUM_'+index);
  obj_num_sing.style.fontSize='18px';
  obj_num_sing.style.fontWeight='bold';
  obj_num_sing.style.color='#0082C3';
  
  fade(index);
  
  index++;
  if(index==i) {
    index=0;
  }
  
  timer=setTimeout("changecontent()",delay);
}

//cambia colore ai link
function linkcolorchange(){
  var obj=document.getElementById("fscroller").getElementsByTagName("A");
  if (obj.length>0){
    for (i=0;i<obj.length;i++)
      obj[i].style.color='black';
  }
}

var fadecounter;
/*
window.onload=function() {
  MM_preloadImages('bottoni/home.gif','bottoni/chisiamo_a.gif','bottoni/dove_a.gif','bottoni/portfolio_a.gif','bottoni/case_a.gif','bottoni/servizi_a.gif','bottoni/competenze_a.gif','bottoni/serviz_ai.gif','bottoni/serviz_a.gif');
  ini_content();
}
*/