window.addEvent('domready', function(){
	if ($('textup')) {
		if ($('instext')) {var scrolldiv = $('instext');};
		var txtsizeo = scrolldiv.getScrollSize();
		var divsizeo = scrolldiv.getSize();
		var divsize = divsizeo.y;
		var txtsize = txtsizeo.y;
		var step=0;
		if (txtsize>=divsize) {
			function calcwheel(event){
				event = new Event(event);						
					/* Mousewheel UP */
				if (event.wheel > 0) {
					clearInterval(periodicalmove);
					clearInterval(periodicalmove2);
					moveup();
				}
					/* Mousewheel DOWN*/
				else if (event.wheel < 0) {
					clearInterval(periodicalmove);
					clearInterval(periodicalmove2);
					movedwn();
				}
			}
			function moveup() {
				step=step-90;
				if (step<20) {step=0;}
				var myFx = new Fx.Scroll(scrolldiv).start(0, step);	
			}
			function movedwn() {
				step=step+90;
				if (step>(txtsize-divsize-20)) {step=txtsize-divsize;}
				var myFx = new Fx.Scroll(scrolldiv).start(0, step);	
			}
			var periodicalmove;
			var beginup = function() {
				periodicalmove = moveup.periodical(350);
			}
			var periodicalmove2;
			var begindwn = function() {
				periodicalmove2 = movedwn.periodical(350);
			}
			$('textup').addEvents({
				mousedown: function() {
					clearInterval(periodicalmove);
					clearInterval(periodicalmove2);
					moveup();
					beginup(); 
				},
				mouseup: function() {
					clearInterval(periodicalmove);
					clearInterval(periodicalmove2);
				}
			});
			$('textdown').addEvents({
				mousedown: function() {
					clearInterval(periodicalmove);
					clearInterval(periodicalmove2);
					movedwn();
					begindwn(); 
				},
				mouseup: function() {
					clearInterval(periodicalmove);
					clearInterval(periodicalmove2);
				}
			});
			scrolldiv.addEvent('mousewheel', calcwheel);
		}
	}
});

