  /*
	come usare questo script:
	per fare scorrere in basso un div richiamare la funzione start_down('NomeDivDaMuovere');
	per fare scorrere verso l'altro un div richiamare la funzione start_up('NomeDivDaMuovere');    
  */
  ScrollDiv=new Array(10);
  position=new Array(10);
  position[0]=0;
  position[1]=0;
  position[2]=0;
  position[3]=0;
  position[4]=0;
  position[5]=0;
  position[6]=0;
  position[7]=0;
  position[8]=0;
  position[9]=0;
  position[10]=0;
  id=0;
  index=0;
  conta=0;
  
  function move_up() {

     var div = document.getElementById(ScrollDiv[index]);
     if(position[index]>0)
     {
     position[index]=position[index]-2;
    div.scrollTop= position[index];
    }
  }
  
  
function start_up(DivToScroll)
  {
  if(conta==0)
  {
   index=conta;
   ScrollDiv[conta]=DivToScroll;
   conta++;
  } 
  else
  {
  var newpos;
   flag=-1;
   for(i=0;i<conta;i++)
    {
    
    if(DivToScroll==ScrollDiv[i])
     {
      newpos=i;
      flag=1;
     }    
    
    }
    if(flag==-1)
    {
    newpos=conta+1;
    }
    index=newpos;
    ScrollDiv[index]=DivToScroll;
  }
 id=setInterval ( "move_up()", 1 );
  }

  
  
  function stop_up()
  {
  clearInterval(id);
  }
  

  
   function move_down() {

   
    var div = document.getElementById(ScrollDiv[index]);
    var divmuovi= document.getElementById('muovi_giu');   
   if(position[index]<div.scrollHeight)
   {  
    position[index]+=2;
    div.scrollTop= position[index];
    }   
 }
 
 
  function start_down(DivToScroll)
  {
 
    if(conta==0)
  {
   index=conta;
   ScrollDiv[conta]=DivToScroll;
   conta++;
  } 
  else
  {
   flag=-1;
   for(i=0;i<conta;i++)
    {        
    if(DivToScroll==ScrollDiv[i])
     {
      newpos=i;
      flag=1;
     }                
    }
    
    if(flag==-1)
    {
    newpos=conta+1;
    }
    index=newpos;
            
    ScrollDiv[index]=DivToScroll;        
  }
 
 
 id=setInterval ( "move_down()", 1 );
  }
  
  
  
  function stop_down()
  {
  clearInterval(id);
  }  
  
  function enable_arrow(Up,Down,DivToScroll,Containers)
  {
        var ContentDiv = document.getElementById(DivToScroll);
        var ContainerDiv = document.getElementById(Containers);

        if (!ContentDiv || !ContainerDiv) {
            return;
        }
        if ((ContainerDiv.scrollHeight) >= (ContentDiv.scrollHeight)) {
            var DivUp = document.getElementById(Up);
            var DivDown = document.getElementById(Down);
            //DivUp.style.backgroundImage ="";
            DivUp.className = 'ScrollUp Off';
            //DivDown.style.backgroundImage ="";
            DivDown.className = 'ScrollDown Off';
        } else {
            var DivUp = document.getElementById(Up);
            var DivDown = document.getElementById(Down);
            //DivUp.style.backgroundImage ="";
            DivUp.className = 'ScrollUp On';
            //DivDown.style.backgroundImage ="";
            DivDown.className = 'ScrollDown On';
        }
    }

    function enable_arrowAlert2(Up, Down, DivToScroll, Containers) {
        var ContentDiv = document.getElementById(DivToScroll);
        var ContainerDiv = document.getElementById(Containers);
        alert("MHMMM2");
        alert("ContainerDiv: " + (ContainerDiv.scrollHeight));
        alert("ContentDiv: " + (ContentDiv.scrollHeight));

        if ((ContainerDiv.scrollHeight) >= (ContentDiv.scrollHeight)) {
            alert("dentro spento"); 
            var DivUp = document.getElementById(Up);
            var DivDown = document.getElementById(Down);
            //DivUp.style.backgroundImage ="";
            DivUp.className = 'ScrollUp Off';
            //DivDown.style.backgroundImage ="";
            DivDown.className = 'ScrollDown Off';
        } else {
            alert("dentro acceso");
            var DivUp = document.getElementById(Up);
            var DivDown = document.getElementById(Down);
            //DivUp.style.backgroundImage ="";
            DivUp.className = 'ScrollUp On';
            //DivDown.style.backgroundImage ="";
            DivDown.className = 'ScrollDown On';
        }
    }