/*
	+++
	
	TMScroll Version 0.5
	DHTML-Scroller
	
	Benoetigt tmdomlib.js v0.5.3
	
	Kompatible Browser (Liste u.U. unvollstaendig):
	-	Mozilla-basierte Browser (Mozilla, Firefox/Firebird/Phoenix, Netscape 6+ etc.)
	-	Internet Explorer 5+
	-	Opera 6+
	-	Safari/KHTML
	
	Dieses Script darf fuer non-kommerzielle Zwecke frei und kostenlos verwendet werden, sofern
	-	die einzelnen Funktionen unveraendert bleiben.
	-	die einzelnen Funktions-Bezeichnungen unveraendert bleiben.
	-	diese Informationen, insbesodere auch der Hinweis auf den Urheber, unveraendert bleiben.
	
	Fuer kommerzielle Nutzung oder bei Unklarheiten bezueglich der Nutzungsbedingungen wende dich an den Urheber.
	
	Urheber:	Tobias Mueller 2004
	Internet:	www.adepto.de
	E-Mail:		mail@adepto.de
	
	+++
*/
function TMS(referenz,container,content,contentTop,contentLeft) {
	this.scrollContainer = container;
	this.scrollContent = content;
	this.scrollContentTop = contentTop;
	this.scrollContentLeft = contentLeft;
	this.ref = referenz;
	this.scrollInit = false;
}

TMS.prototype.TMScrollInit = function(startPos,bottomMarginToIgnore) {
	if (document.getElementById) {
		this.scrollRahmenEbene = document.getElementById(this.scrollContainer);
		this.scrollEbene = document.getElementById(this.scrollContent);
		this.hPosition = this.scrollContentLeft;
		this.scrollRechtsMaximum = - this.scrollEbene.offsetWidth + this.scrollRahmenEbene.offsetWidth;
		this.scrollLinksMaximum = 0;
		this.vPosition = this.scrollContentTop;
		this.scrollDownMaximum = - this.scrollEbene.offsetHeight + this.scrollRahmenEbene.offsetHeight;
		this.scrollUpMaximum = 0;
		if (startPos)
		{
			bottomMarginToIgnore = bottomMarginToIgnore || 0;
			this.vPosition -= startPos;
			if (this.vPosition > 0)
				this.vPosition = 0;
			if (this.vPosition < this.scrollDownMaximum && this.vPosition < 0)
				this.vPosition = this.scrollDownMaximum + bottomMarginToIgnore;
			this.scrollEbene.style.top = this.vPosition + 'px';
		}
		this.scrollInit = true;
	}
};

TMS.prototype.TMScrollStart = function(hSpeed,vSpeed,scrollTimer) {
	if (this.scrollInit) {
		if (this.scrollSchleife) {
			window.clearInterval(this.scrollSchleife);
		}
		if (((vSpeed < 0) && (this.vPosition > this.scrollDownMaximum)) || ((vSpeed > 0) && (this.vPosition < this.scrollUpMaximum)) || ((hSpeed < 0) && (this.hPosition > this.scrollRechtsMaximum)) || ((hSpeed > 0) && (this.hPosition < this.scrollLinksMaximum))) {
			this.hPosition += hSpeed;
			this.vPosition += vSpeed;
			this.scrollEbene.style.top = this.vPosition + 'px';
			this.scrollEbene.style.left = this.hPosition + 'px';
			this.scrollSchleife = window.setInterval(this.ref + '.TMScrollStart(' + hSpeed + ',' + vSpeed + ',' + scrollTimer + ')',scrollTimer);
		}
	} else {
		this.TMScrollInit();
		this.TMScrollStart(hSpeed,vSpeed,scrollTimer);
	}
};

TMS.prototype.TMScrollStop = function() {
	if (this.scrollSchleife) {
		window.clearInterval(this.scrollSchleife);
		this.scrollSchleife = false;
	}
};
		
