ScheduleScroller = function()
{
	this.scroller = null;
	this.scrollbar = null;
	this.scrollTween = null;
	this.isScrolling = false;	
}

ScheduleScroller.prototype.init = function(shouldZoomToTime)
{	

    // Initialize the scrolling library
    this.scroller = new Scrolling.Scroller ($("schedule_1"), 400, 180);
    this.scrollTween = new Scrolling.ScrollTween();
    this.scrollbar = new Scrolling.Scrollbar (
                           	$("scrollbar_container"),
                            this.scroller,
                            this.scrollTween
                        );	
	this.scrollbar.onMouseDown = ScheduleGrid.handleClick;
    // Only scroll to the current time if the user is viewing the current day's schedule.
    if (shouldZoomToTime)            	
    	window.setTimeout('schedule.runtime.scroll.tweenTo(schedule.runtime.getFocusHour(), schedule.runtime.getFocusMinute(), schedule.listingHeightInPixelsPerHalfHour)', 600);
    return true;
}

ScheduleScroller.prototype.zoomToBeginning = function()
{
	this.tweenTo(0,0);
}

ScheduleScroller.prototype.tweenTo = function(hour, minute, listingHeightInPixelsPerHalfHour)
{
	if (listingHeightInPixelsPerHalfHour == null) 
		listingHeightInPixelsPerHalfHour = 0;
	this.scrollbar.stepSpeed = 60;
    this.scrollbar.tweenTo(((hour * 2) + ((minute >= 30) ? 1 : 0)) * listingHeightInPixelsPerHalfHour);
	// Return scrolling to its normal speed
	this.scrollbar.stepSpeed = 30;	
}
