var Scroller = {
	"scrollUp" : function(event) {
		var div = PythonElement.get("latest-scroll");
		if (div != null) {
			div.scrollTop = div.scrollTop - 80;
		}
		PythonEvent.stop(event);
  },
  "scrollDown" : function(event) {
   	var div = PythonElement.get("latest-scroll");
		if (div != null) {
			var newTop = div.scrollTop + 80;
			if (newTop <= (div.scrollHeight - 80)) { 
				div.scrollTop = newTop;
			}
		}
		PythonEvent.stop(event);
  }
}

var ScrollerRules = {
	"a.scroll-up" : function(element) {
		PythonEvent.observe(element, "click", Scroller.scrollUp);
	},
	"a.scroll-down" : function(element) {
		PythonEvent.observe(element, "click", Scroller.scrollDown);
	}
}

Behaviour.register(ScrollerRules);