//We wrap all the code in an object so that it doesn't interfere with any other code
var scroller = {
  init:   function(content,container,scrollArea,scroler,tab) {

    //collect the variables
    scroller.docH = document.getElementById(content).offsetHeight;	//540
	//alert(scroller.docH);
    scroller.contH = document.getElementById(container).offsetHeight ;//107
	
    scroller.scrollAreaH = document.getElementById(scrollArea).offsetHeight;  //107   	
    //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 );	
	//alert(scroller.scrollH);
    if(scroller.scrollH <20) scroller.scrollH = 20;
    document.getElementById(scroler).style.height = Math.round(scroller.scrollH) + "px"; 
	
    //what is the effective scroll distance once the scoller's height has been taken into account
    scroller.scrollDist = Math.round(scroller.scrollAreaH-scroller.scrollH);  
	//alert(scroller.scrollDist);
    //make the scroller div draggable
    Drag.init(document.getElementById(scroler),null,0,0,0,scroller.scrollDist,null,null,null,null,tab);
    
    //add ondrag function
    document.getElementById(scroler).onDrag = function (x,y) {
      var scrollY = parseInt(document.getElementById(scroler).style.top);
	  
      var docY = 0- (scrollY) * ((scroller.docH - scroller.contH) / scroller.scrollDist);
	  
	  //alert(docY);
      document.getElementById(content).style.top = Math.round(docY) + "px";
    }
  }
}

//onload = scroller.init("d_content","d_container","scrollArea","scroller");