/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Mr J | http://www.huntingground.net/ */

//facciamo un include in php che va a scrivere nel javascript il numero di link inseriti, così si determina la larghezza dinamicamente

function countElementsByClass(){
    var count = 0;
    var o = document.getElementById("slide").getElementsByTagName("div");
    for(var i=0;i<o.length;i++){
      if(o[i].className == "link"){
        count ++;
      }
    }
    //alert(count);
    var link_width = 128;
    document.getElementById('slide').style.width = (link_width*count) + "px";
}

/*function set_width(slide){
    var link_width = 77;
    var num_link = 8;
    document.getElementById('slide').style.width = (link_width*num_link) + "px";
}*/

scrollStep=1

timerLeft=""
timerRight=""

function toLeft(id){
  document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id){
  clearTimeout(timerRight) 
  document.getElementById(id).scrollLeft+=scrollStep
  timerRight=setTimeout("scrollDivLeft('"+id+"')",6)
}

function scrollDivRight(id){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
  timerLeft=setTimeout("scrollDivRight('"+id+"')",6)
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth;
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
}


