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