var w3gScrollBarLoaded=true;

//We wrap all the code in an object so that it doesn't interfere with any other code
var scroller = {
  init:   function(helpBalloonId, scrollerHeight, scrollAreaHeight) {
  
    //what is the effective scroll distance once the scoller's height has been taken into account
    var scrollerElem = document.getElementById("scroller"+helpBalloonId);
    // altezza degli elementi w3g_tooltip_content (scroller.docH), 

    scroller.contH =  scroller.scrollAreaH = scrollAreaHeight;
    //collect the variables
    
    scroller.docH = document.getElementById("w3g_tooltip_content"+helpBalloonId).scrollHeight;

    //calculate height of scroller and resize the scroller div
    //(however, we make sure that it isn't to small for long pages)
    scroller.scrollH = (scroller.contH * scroller.scrollAreaH) / scroller.docH;
   
	scroller.scrollDist = Math.round(scroller.scrollAreaH-scrollerHeight);
    //scroller.scrollDist = Math.round(scroller.scrollAreaH-scroller.scrollH);
    
    //make the scroller div draggable
    Drag.init(scrollerElem,null,0,0,-1,scroller.scrollDist);
    
    //add ondrag function
    scrollerElem.onDrag = function (x,y) {
      var scrollY = parseInt(scrollerElem.style.top);
      var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
      document.getElementById("w3g_tooltip_content"+helpBalloonId).style.top = docY + "px";
    }
	 
  }
}