SCROLL = {
	// ------------------------------------------------------------
	dir : 1,
	step : 0,
	left : 0,
	delay : 2,
	toDir : 0,
	toStep : 1,
	maxStep : 50,
	maxScroll : 0,
	angleichen : 2,
	tRef : null,
	// ------------------------------------------------------------
	scroll : function() {
	// ------------------------------------------------------------
		// Richtungsaenderung?
		if (SCROLL.toDir != SCROLL.dir) {
			// Langsam?
			if (SCROLL.step <= 1) {
				SCROLL.dir = SCROLL.toDir;
				SCROLL.step = 1;
			}
			// Erst Geschwindigkeit drosseln!
			else
				SCROLL.step = Math.max(0,SCROLL.step - SCROLL.angleichen);
		}
		else {
			if (SCROLL.toStep < SCROLL.step)
				SCROLL.step = Math.max(0,SCROLL.step - SCROLL.angleichen);
			else if (SCROLL.toStep > SCROLL.step)
				SCROLL.step = Math.min(SCROLL.toStep,SCROLL.step + SCROLL.angleichen);
		}
		var newleft = Math.min(SCROLL.maxScroll,Math.max(0,SCROLL.left + SCROLL.dir * SCROLL.step));

		if (SCROLL.left != newleft) {
			document.body.scrollLeft = SCROLL.left = newleft;
			SCROLL.tRef = window.setTimeout("SCROLL.scroll()",SCROLL.delay);
		}
		else {
			SCROLL.tRef = null;
			SCROLL.step = 0;
		}
	},
	// ------------------------------------------------------------
	init : function() {
	// ------------------------------------------------------------
		SCROLL.maxScroll = document.body.scrollWidth - document.body.offsetWidth;

		window.onresize = function() {
				SCROLL.maxScroll = document.body.scrollWidth - document.body.offsetWidth;
		};
		document.onmousemove = function(event) {
			if (event) {
				x = event.pageX - document.body.scrollLeft;
				y = event.pageY - document.body.scrollTop;
			}
			else {
				event = window.event;
				x = event.clientX;
				y = event.clientY;
			}
			SCROLL.handleMovement(x,y,null);
		}
	},
	// ------------------------------------------------------------
	initFrame : function() {
	// ------------------------------------------------------------
		document.onmousemove = function(event) {
			if (event) {
				x = event.pageX;
				y = event.pageY;
			}
			else {
				event = window.event;
				x = event.clientX;
				y = event.clientY;
			}
			if (parent && parent.SCROLL)
				parent.SCROLL.handleMovement(x,y,window);
		};
	},
	// ------------------------------------------------------------
	findIFrameObject : function(frameWinRef) {
	// ------------------------------------------------------------
		var iframes = document.getElementsByTagName('IFRAME');
		for (i = 0; i < iframes.length; i++) {
			var f = iframes[i];
			if (frameWinRef.document == (f.contentDocument ? f.contentDocument : f.document))
				return f;
		}
		return null;
	},
	// ------------------------------------------------------------
	handleMovement : function(x,y,frameWinRef) {
	// ------------------------------------------------------------
			// Move-Event in IFrame? 
			if (frameWinRef) {
				// IFrame Objekt ermitteln und Position korrigieren! 
				var iframe = SCROLL.findIFrameObject(frameWinRef);
				if (iframe)
					x += iframe.offsetLeft;
				x += 40 - (document.body.scrollLeft);
			}
			d2 = document.body.offsetWidth/2;
			d4 = document.body.offsetWidth/4;
			d8 = document.body.offsetWidth/8;

			if (x > d4 && x < d2+d4)
				SCROLL.toStep = 0;
			else if (x >= 0 && x <= d4) {
				SCROLL.toDir = -1;
				SCROLL.toStep = Math.min(SCROLL.maxStep,Math.max(1,parseInt(SCROLL.maxStep-SCROLL.maxStep/d4*x)));
			}
			else {
				SCROLL.toDir = 1;
				SCROLL.toStep = Math.min(SCROLL.maxStep,Math.max(1,parseInt(SCROLL.maxStep/d4*(x-d4-d2))));
			}
			if (SCROLL.tRef == null)
				SCROLL.scroll();
	}
};

