TMScrollLeiste = function() {
	if (isDOM) {
		var a = arguments;
		this.objekt = a[0] + 'objekt';
		eval(this.objekt + '= this');
		this.gesamtBox = TMSucheElem(a[0]);
		this.inhalt = TMSucheElem(a[1]);
		this.leistenBox = TMSucheElem(a[2]);
		this.leiste = TMSucheElem(a[3]);
		this.greifer = TMSucheElem(a[4]);
		//this.pfeil01 = TMSucheElem(a[5]);
		//this.pfeil02 = TMSucheElem(a[6]);
		//this.springPfeil = TMSucheElem(a[7]);
		this.scrollVertikal = (a[8] == 'vertikal') ? true : false;
		this.scrollTimeout = a[9];
		this.scrollSpeed = a[10];
		this.mausradSpeed = a[11];
		if (a.length == 20) {
			this.bildwechsel = true;
			this.greiferBild_n = a[12];
			this.greiferBild_o = a[13];
			//this.pfeil01Bild_n = a[14];
			//this.pfeil01Bild_o = a[15];
			//this.pfeil02Bild_n = a[16];
			//this.pfeil02Bild_o = a[17];
			//this.springPfeilBild_n = a[18];
			//this.springPfeilBild_o = a[19];
		} else {
			this.bildwechsel = false;
		}
		this.scrollSchleife = null;
		this.inhaltMaxPos = 0;
		this.greiferMinPos = 0;
		if (this.scrollVertikal) {
			this.inhaltPos = parseInt(this.inhalt.style.top) ? parseInt(this.inhalt.style.top) : 0;
			this.greiferPos = parseInt(this.greifer.style.top) ? parseInt(this.greifer.style.top) : 0;
			this.inhaltHoehe = this.inhalt.offsetHeight;
			this.gesamtBoxHoehe = this.gesamtBox.offsetHeight;
			this.inhaltMinPos = -this.inhaltHoehe + this.gesamtBoxHoehe;
			this.leistenHoehe = this.leiste.offsetHeight;
			this.greiferHoehe = this.greifer.offsetHeight;
			this.greiferMaxPos = this.leistenHoehe - this.greiferHoehe;
			this.scrollBereich = this.greiferMaxPos / (this.inhaltHoehe - this.gesamtBoxHoehe);
			if (this.inhaltHoehe > this.gesamtBoxHoehe) {
				this.leistenBox.style.visibility = 'visible';
			}
		} else {
			this.inhaltPos = parseInt(this.inhalt.style.left) ? parseInt(this.inhalt.style.left) : 0;
			this.greiferPos = parseInt(this.greifer.style.left) ? parseInt(this.greifer.style.left) : 0;
			this.inhaltBreite = this.inhalt.offsetWidth;
			this.gesamtBoxBreite = this.gesamtBox.offsetWidth;
			this.inhaltMinPos = -this.inhaltBreite + this.gesamtBoxBreite;
			this.leistenBreite = this.leiste.offsetWidth;
			this.greiferBreite = this.greifer.offsetWidth;
			this.greiferMaxPos = this.leistenBreite - this.greiferBreite;
			this.scrollBereich = this.greiferMaxPos / (this.inhaltBreite - this.gesamtBoxBreite);
			if (this.inhaltBreite > this.gesamtBoxBreite) {
				this.leistenBox.style.visibility = 'visible';
			}
		}
		var obj = this;
		//TMErstelleEvent(this.pfeil01,'mousedown',function(e) { obj.scrollenbeginnen(obj.scrollSpeed,e); });
		//TMErstelleEvent(this.pfeil01,'mouseup',function() { obj.scrollenbeenden(); });
		//TMErstelleEvent(this.pfeil01,'mouseout',function() { obj.scrollenbeenden(); });
		//TMErstelleEvent(this.pfeil02,'mousedown',function(e) { obj.scrollenbeginnen(-obj.scrollSpeed,e); });
		//TMErstelleEvent(this.pfeil02,'mouseup',function() { obj.scrollenbeenden(); });
		//TMErstelleEvent(this.pfeil02,'mouseout',function() { obj.scrollenbeenden(); });
		TMErstelleEvent(this.greifer,'mousedown',function(e) { obj.ziehenbeginnen(e); });
		//TMErstelleEvent(this.springPfeil,'mousedown',function(e) { obj.hochspringen(e); });
		this.mausradPos = this.inhaltPos / this.mausradSpeed;
		TMErstelleEvent(this.gesamtBox,'mousewheel',function(e) { obj.mausradscrollen(e); });
		if (isGECKO) {
			TMErstelleEvent(this.gesamtBox,'DOMMouseScroll',function(e) { obj.mausradscrollen(e); },false);
		} else {
			TMErstelleEvent(this.gesamtBox,'mousewheel',function(e) { obj.mausradscrollen(e); });
		}
		if (this.bildwechsel) {
			this.bilderladen();
		}
	}
};

TMScrollLeiste.prototype = {

	positionieren : function() {
		if (this.scrollVertikal) {
			this.inhaltPosX = 0;
			this.inhaltPosY = this.inhaltPos;
			this.greiferPosX = 0;
			this.greiferPosY = this.greiferPos;
		} else {
			this.inhaltPosX = this.inhaltPos;
			this.inhaltPosY = 0;
			this.greiferPosX = this.greiferPos;
			this.greiferPosY = 0;
		}
		TMCSSPosition(this.inhalt,this.inhaltPosX,this.inhaltPosY);
		TMCSSPosition(this.greifer,this.greiferPosX,this.greiferPosY);
	},
	
	scrollenbeginnen : function(speed,e) {
		if (this.bildwechsel) {
			if (speed > 0) {
				this.pfeil = this.pfeil01;
				this.pfeilBild = this.pfeil01Bild_o
			} else {
				this.pfeil = this.pfeil02;
				this.pfeilBild = this.pfeil02Bild_o;
			}
			this.bilderwechseln(this.pfeil,this.pfeilBild);
		}
		this.scrollSchleife = window.setInterval(this.objekt + '.scrollen(' + speed + ')',this.scrollTimeout);
		TMUnterbindeStandard(e);
	},
	
	scrollen : function(speed) {
		this.inhaltPos += speed;
		if (this.inhaltPos < this.inhaltMinPos) {
			this.inhaltPos = this.inhaltMinPos;
			this.greiferPos = this.greiferMaxPos;
			window.clearInterval(this.scrollSchleife);
			this.scrollSchleife = null;
		} else if (this.inhaltPos > this.inhaltMaxPos) {
			this.inhaltPos = this.inhaltMaxPos;
			this.greiferPos = this.greiferMinPos;
			window.clearInterval(this.scrollSchleife);
			this.scrollSchleife = null;
		} else {
			this.greiferPos = Math.round(-this.inhaltPos * this.scrollBereich);
		}
		if (isIE6) {
			this.mausradPos = this.inhaltPos / this.mausradSpeed;
		}
		this.positionieren();
	},
	
	scrollenbeenden : function() {
		if (this.bildwechsel) {
			this.bilderwechseln(this.pfeil01,this.pfeil01Bild_n,this.pfeil02,this.pfeil02Bild_n);
		}
		if (this.scrollSchleife) {
			window.clearInterval(this.scrollSchleife);
			this.scrollSchleife = null;
		}
	},
	
	ziehenbeginnen : function(e) {
		if (this.bildwechsel) {
			this.bilderwechseln(this.greifer,this.greiferBild_o);
		}
		this.mausPos = this.scrollVertikal ? TMSucheMaus(e).yo : TMSucheMaus(e).xo;
		this.ziehenPos = this.mausPos - this.greiferPos;
		var obj = this;
		TMErstelleEvent(document,'mousemove',function(e) { obj.ziehen(e); });
		TMErstelleEvent(document,'mouseup',function() { obj.ziehenbeenden(); });
		TMUnterbindeStandard(e);
	},
	
	ziehen : function(e) {
		this.mausPos = this.scrollVertikal ? TMSucheMaus(e).yo : TMSucheMaus(e).xo;
		this.greiferPos = this.mausPos - this.ziehenPos;				
		if (this.greiferPos > this.greiferMaxPos) { 
			this.greiferPos = this.greiferMaxPos;
			this.inhaltPos = this.inhaltMinPos;
		} else if (this.greiferPos < this.greiferMinPos) { 
			this.greiferPos = this.greiferMinPos;
			this.inhaltPos = this.inhaltMaxPos;
		} else {
			this.inhaltPos = Math.round(-this.greiferPos * (1 / this.scrollBereich));
		}
		if (isIE6) {
			this.mausradPos = this.inhaltPos / this.mausradSpeed;
		}
		this.positionieren();
		TMUnterbindeStandard(e);
	},
	
	ziehenbeenden : function() {
		if (this.bildwechsel) {
			this.bilderwechseln(this.greifer,this.greiferBild_n);
		}
		TMEntferneEvent(document,'mousemove');
		TMEntferneEvent(document,'mouseup');
	},
	
	hochspringen : function(e) {
		if (this.bildwechsel) {
			this.bilderwechseln(this.springPfeil,this.springPfeilBild_o);
			var obj = this;
			TMErstelleEvent(this.springPfeil,'mouseup',function() { obj.bilderwechseln(obj.springPfeil,obj.springPfeilBild_n); });
			TMErstelleEvent(this.springPfeil,'mouseout',function() { obj.bilderwechseln(obj.springPfeil,obj.springPfeilBild_n); });
		}
		this.greiferPos = this.greiferMinPos;
		this.inhaltPos = this.inhaltMaxPos;
		if (isIE6) {
			this.mausradPos = this.inhaltPos / this.mausradSpeed;
		}
		this.positionieren();
		TMUnterbindeStandard(e);
	},
	
	mausradscrollen : function(e) {
		e = e ? e : window.event;
		var delta = 0;
		if (e.wheelDelta) {
			delta = e.wheelDelta / 120;
            if (window.opera) {
				delta = -delta;
			}
		} else if (e.detail) {
			delta = -e.detail/3;
		}
		if (delta) {
			this.mausradPos += delta;
			this.inhaltPos = Math.round(this.mausradPos * this.mausradSpeed);
			if (this.inhaltPos < this.inhaltMinPos) {
				this.inhaltPos = this.inhaltMinPos;
				this.greiferPos = this.greiferMaxPos;
				this.mausradPos = this.inhaltPos / this.mausradSpeed;
			} else if (this.inhaltPos > this.inhaltMaxPos) {
				this.inhaltPos = this.inhaltMaxPos;
				this.greiferPos = this.greiferMinPos;
				this.mausradPos = this.inhaltPos / this.mausradSpeed;
			} else {
				this.greiferPos = Math.round(-this.inhaltPos * this.scrollBereich);
			}
			this.positionieren();
			//TMUnterbindeStandard(e)
			e.returnValue = false;
		}
	},
	
	bilderladen : function() {
		this.bilder = new Array(this.greiferBild_o,this.pfeil01Bild_o,this.pfeil02Bild_o,this.springPfeilBild_o);
		this.bild = new Array();
		for (var i = 0; i < this.bilder.length; i++) {
			this.bild[i] = new Image();
			this.bild[i].src = this.bilder[i];
		}
	},
	
	bilderwechseln : function() {
		var a = arguments;
		for (var i = 0; i < a.length-1; i+=2) {
			a[i].setAttribute('src',a[i+1]);
		}
	}
};


TMErstelleEvent(window, 'load', function(){
	if ($("scroll_container") && ($("scroll_text").offsetHeight > $("scroll_container").offsetHeight)) {
		var scroller_main = new TMScrollLeiste('scroll_container', 'scroll_text', 'scrollbarbox', 'scrolltrack', 'scrollgreifer', 'scrollpfeiloben', 'scrollpfeilunten', 'springpfeil', 'vertikal', 15, 5, 10, '', '', '', '', '', '', '', '');
	} else if($('scrollbarbox')) {
		$('scrollbarbox').hide();
	}
	if ($("scroll_container_home_unten") && ($("scroll_text_home_unten").offsetHeight > $("scroll_container_home_unten").offsetHeight)) {
		var scroller_main_home_unten = new TMScrollLeiste('scroll_container_home_unten', 'scroll_text_home_unten', 'scrollbarbox_home_unten', 'scrolltrack_home_unten', 'scrollgreifer_home_unten', 'scrollpfeiloben', 'scrollpfeilunten', 'springpfeil', 'vertikal', 15, 5, 10, '', '', '', '', '', '', '', '');
	} else if($('scrollbarbox_home_unten')) {
		$('scrollbarbox_home_unten').hide();
	}
});