// 04.09.2006
// onScroll im Content sorgt nun dafŸr, dass auch die Scrollbalken upgedatet werden.

// 02.09.2006
// Konfigurationsfunktionen sind nun integriert

// 26.08.2006
// Die Scrollgeschwindigkeit des Contents ist nun abhŠngig von der Contentmenge. Ein komletter Scrolldurchlauf dauert nun unabhŠngig von der Contentmenge imme rgleich lang
// Die globale Variable s_b_html hŠngt nun an der ScrollBar-Konstruktor-Funktion

// 25.08.2006
// Die Scrollbuttons funktionieren nun korrekt.

// 21.05.2006 Anfasser ist Safari kompatibel
// Opera stellt Elemente mit overflow=hidden immer mit scrollTop, scrollLeft = 0 dar, selbst, wenn sie vorher auf einen anderen Wert positioniert worden sind.

// ToDos
// Klick in den Scrollbar selbst soll Anspringen des entsprechenden Contentbereichs ermšglichen
// Verschiedene Funktionen sind Methoden von "window"
	// Mšglichst Verlagerung der Methoden in das Scrollbarobjekt
// Evtl. proportionalen Scrollbalken (optional) mit anbieten
// Wertebereich mit Math.min() und Math.max() eingrenzen, wenn sinnvoll
// Evtl. Version bauen, die nicht auf die Scroll-Eigenschaft der Elemente aufsetzt, da verschieden native Funktionen im Zusammenhang mit Scrollen nicht funktionieren, wenn overflow=hidden


function scrollBars(elm)
{
	try
	{

		/* globale Konfiguration START */

		this.elm = document.getElementById(elm); // auto

		this.elm.obj = this; // auto
		this.id = "sb_" + scrollBars.num++; // auto

		this.elmHeight = this.elm.offsetHeight; // auto
		this.elmWidth = this.elm.offsetWidth; // auto
		this.elmScrollHeight = this.elm.scrollHeight; // auto
		this.elmScrollWidth = this.elm.scrollWidth; // auto
		
		this.newContentElmHeight; // auto
		this.newContentElmWidth; // auto
		this.newContentElmScrollHeight; // auto
		this.newContentElmScrollWidth; // auto
		
		this.hasVBar = (this.elm.scrollHeight > this.elm.offsetHeight) ? true : false; // auto, custom
		this.hasHBar = (this.elm.scrollWidth > this.elm.offsetWidth) ? true : false; // auto, custom

		this.vBarWidth = '9px'; // default, custom
		this.hBarHeight = '9px'; // default, custom
		this.vBarScrollLength; // auto
		this.hBarScrollLength; // auto

		this.vMultiplication; // auto, Multiplikator (Scrollbarhoehe, Scrollheight des Contents)
		this.hMultiplication; // auto, Multiplikator (Scrollbarbreite, Scrollwidth des Contents)

		this.contentVMargin = '4px'; // default, custom
		this.contentHMargin = '4px'; // default, custom

		/* globale Konfiguration ENDE */

		/* Anfasser START */

		this.vEventStartYPos; // auto
		this.vBarStartYPos; // auto
		this.vBarYPos; // auto
		this.intContentVActualPos; // auto
		this.floatContentVActualPos; // auto

		this.hEventStartXPos; // auto
		this.hBarStartXPos; // auto
		this.hBarXPos; // auto
		this.intContentHActualPos; // auto
		this.floatContentHActualPos; // auto

		/* Anfasser ENDE */

		/* Mousewheel START */

		this.wheelContentVSpeed = 9; // default, custom
		this.wheelContentHSpeed = 9; // default, custom

		/* Mousewheel ENDE */

		/* Buttons START */

		this.upButtonContentSpeed = 4; //default, custom
		this.downButtonContentSpeed = 4; //default, custom
		this.leftButtonContentSpeed = 4; //default, custom
		this.rightButtonContentSpeed = 4; //default, custom

		/* Buttons ENDE */

		/* Buttons und Mousewheel START */

		this.floatVBarActualPos; // auto
		this.floatHBarActualPos; // auto

		/* Buttons und Mousewheel ENDE */

		// Eigenschaften, die zugewiesen werden muessen, Layout-Eigenschaften START
		// vertikaler Scrolbalken START
			this.vUpHeight;
			this.vUpBgColor;
			this.vUpBgImg;
			this.vDownHeight;
			this.vDownBgColor;
			this.vDownBgImg;
			this.vAnfasserHeight = '32px';
			this.vAnfasserBgColor;
			this.vAnfasserBgImg;
			this.vBarBgColor;
			this.vBarContentBgColor;
			this.vBarContentBgImg;
		// vertikaler Scrolbalken ENDE
	
		// horizontaler Scrolbalken START
			this.hLeftWidth;
			this.hLeftBgColor;
			this.hLeftBgImg;
			this.hRightWidth;
			this.hRightBgColor;
			this.hRightBgImg;
			this.hAnfasserWidth = '32px';
			this.hAnfasserBgColor;
			this.hAnfasserBgImg;
			this.hBarBgColor;
			this.hBarContentBgColor;
			this.hBarContentBgImg;
		// horizontaler Scrolbalken ENDE
		// Eigenschaften, die zugewiesen werden muessen, Layout-Eigenschaften ENDE

		//this.init();
	}
	catch(e)
	{
		try
		{
			this.elm.style.overflow = 'auto';
		}
		catch(e)
		{
			//alert('schade')
		}
	}
}
scrollBars.num = 0;
scrollBars.s_b_html = document.getElementsByTagName('html')[0];
scrollBars.prototype.onSetup = new Function();
scrollBars.prototype.init = s_b_init;
scrollBars.prototype.embedElm = s_b_embedElm;
scrollBars.prototype.createVScrollbar = s_b_createVScrollbar;
scrollBars.prototype.createHScrollbar = s_b_createHScrollbar;
scrollBars.prototype.calculateVBar = s_b_calculateVBar;
scrollBars.prototype.calculateHBar = s_b_calculateHBar;

scrollBars.prototype.registerButton = s_b_registerButton;
scrollBars.prototype.vScroll = s_b_vScroll;
scrollBars.prototype.hScroll = s_b_hScroll;
scrollBars.prototype.stopButtonScroll = s_b_stopButtonScroll;

scrollBars.prototype.setBars = s_b_setBars;
scrollBars.prototype.setContentMargins = s_b_setContentMargins;
scrollBars.prototype.setBarWidth = s_b_setBarWidth;
scrollBars.prototype.setButtonSize = s_b_setButtonSize;
scrollBars.prototype.setButtonBGColor = s_b_setButtonBGColor;
scrollBars.prototype.setButtonBGImg = s_b_setButtonBGImg;
scrollBars.prototype.setAnfasserLength = s_b_setAnfasserLength;
scrollBars.prototype.setAnfasserBgColor = s_b_setAnfasserBgColor;
scrollBars.prototype.setAnfasserBgImg = s_b_setAnfasserBgImg;

scrollBars.prototype.setBarBgColor = s_b_setBarBgColor;

scrollBars.prototype.setBarContentBgColor = s_b_setBarContentBgColor;
scrollBars.prototype.setBarContentBgImg = s_b_setBarContentBgImg;
scrollBars.prototype.setButtonContentSpeed = s_b_setButtonContentSpeed;
scrollBars.prototype.setWheelContentSpeed = s_b_setWheelContentSpeed;

scrollBars.prototype.updateScrollbars = s_b_updateScrollbars;

function s_b_init()
{
	this.onSetup();
	if (this.hasVBar || this.hasHBar)
	{
		this.embedElm();
	}
	if (this.hasVBar)
	{
		this.createVScrollbar();
		this.calculateVBar();
	}
	if (this.hasHBar)
	{
		this.createHScrollbar();
		this.calculateHBar();
	}
}

function s_b_updateScrollbars()
{
	this.obj.floatVBarActualPos = this.obj.vBarScrollLength - this.obj.newContentElm.scrollTop / this.obj.vMultiplication;
	this.obj.vBar.scrollTop = this.obj.floatVBarActualPos;
	//this.obj.floatHBarActualPos = this.obj.hBarScrollLength - this.obj.newContentElm.scrollLeft / this.obj.hMultiplication;
	//this.obj.hBar.scrollLeft = this.obj.floatHBarActualPos;
	//document.getElementById('divAusgabe').innerHTML = this.scrollTop + "<br>" + this.scrollLeft;
}

function s_b_embedElm()
{
	this.newContentElm = document.createElement('div');
	this.newContentElm.id = this.id + '_autogenerated';
	
	this.newContentElm.style.position = 'absolute'; // static
	this.newContentElm.style.overflow = 'hidden'; // static
	this.newContentElm.style.margin = '0px'; // static
	this.newContentElm.style.padding = '0px'; // static
	this.newContentElm.style.border = 'none'; // static
	ec.registerEvent(this.newContentElm,'scroll',this.updateScrollbars);

	this.elm.style.position = 'relative'; // static, bug beim Scrollen im Safari, wenn Positionierung angegeben
	this.elm.style.left = '0px';
	this.elm.style.top = '0px';
	this.elm.style.overflow = 'auto'; // static

	this.newContentElm.style.width = (this.hasVBar) ? (this.elmWidth - parseInt(this.vBarWidth) - parseInt(this.contentVMargin)) + 'px' : '100%'
	this.newContentElm.style.height = (this.hasHBar) ? (this.elmHeight - parseInt(this.hBarHeight) - parseInt(this.contentHMargin)) + 'px' : this.elmHeight + 'px'
	try //DOM-kompatible Browser mit Range-Implementatoin (document.implementation.hasFeature('Range','2.0')
	{
		this.range = document.createRange();
		this.range.selectNodeContents(this.elm);
		this.range.surroundContents(this.newContentElm);
	}
	catch(e) // IE
	{
		var cn = this.elm.childNodes.length
		for (var i=0; i < cn; i++)
		{
			this.newContentElm.appendChild(this.elm.childNodes[0]);
		}
		this.elm.appendChild(this.newContentElm);
	}
	this.newContentElmHeight = this.newContentElm.offsetHeight; // auto
	this.newContentElmWidth = this.newContentElm.offsetWidth; // auto
	this.newContentElmScrollHeight = this.newContentElm.scrollHeight;
	this.newContentElmScrollWidth = this.newContentElm.scrollWidth;
	this.newContentElm.obj = this;
}

function s_b_createVScrollbar()
{
	/*Scrollbar zusammensetzten START*/
	this.vBarArea = document.createElement('div');
		this.vUp = document.createElement('div');
		this.vDown = document.createElement('div');
		this.vBar = document.createElement('div');
			this.vBarContent = document.createElement('div');
				this.vAnfasser = document.createElement('div');
	
	this.vUp.obj = this;
	this.vUp.setAttribute('id',this.id + "_up");
	this.vDown.obj = this;
	this.vDown.setAttribute('id',this.id + "_down");
	
	this.vAnfasser.obj = this;
	this.vBar.obj = this;

	ec.registerEvent(this.vAnfasser,'mousedown',registerVAnfasser,false);
	try
	{
		ec.registerEvent(this.vBar,'mousewheel',registerVWheel,false);
		ec.registerEvent(this.newContentElm,'mousewheel',registerVWheel,false);
	}
	catch(e){}
	
	ec.registerEvent(this.vUp,'mousedown',this.registerButton,false);
	ec.registerEvent(this.vDown,'mousedown',this.registerButton,false);
	
	this.vBarContent.appendChild(this.vAnfasser);
	this.vBar.appendChild(this.vBarContent);
	this.vBarArea.appendChild(this.vUp);
	this.vBarArea.appendChild(this.vBar);
	this.vBarArea.appendChild(this.vDown);

	this.vBarArea.style.position = 'absolute'; // static
	this.vBarArea.style.width = this.vBarWidth; // auto
	this.vBarArea.style.right = '0px'; // static
	this.vBarArea.style.top = '0px'; // static
	this.vBarArea.style.height = (this.hasHBar) ? this.newContentElm.offsetHeight + parseInt(this.contentVMargin) + 'px' : this.newContentElm.offsetHeight + 'px'; // auto

	this.vUp.style.width = '100%'; // static
	this.vUp.style.overflow = 'hidden'; // static
	this.vUp.style.height = this.vUpHeight; // custom
	if (this.vUpBgColor) this.vUp.style.backgroundColor = this.vUpBgColor; // custom
	if (this.vUpBgImg) this.vUp.style.backgroundImage = this.vUpBgImg; // custom
	
	this.vDown.style.width = '100%'; // static
	this.vDown.style.overflow = 'hidden'; // static
	this.vDown.style.height = this.vDownHeight; // custom
	if (this.vDownBgColor) this.vDown.style.backgroundColor = this.vDownBgColor; // custom
	if (this.vDownBgImg) this.vDown.style.backgroundImage = this.vDownBgImg; // custom

	this.vAnfasser.style.width = '100%'; // static
	this.vAnfasser.style.overflow = 'hidden'; // static
	this.vAnfasser.style.position = 'relative'; // static
	this.vAnfasser.style.height = this.vAnfasserHeight; // custom
	if (this.vAnfasserBgColor) this.vAnfasser.style.backgroundColor = this.vAnfasserBgColor; // custom
	if (this.vAnfasserBgImg) this.vAnfasser.style.backgroundImage = this.vAnfasserBgImg; // custom

	this.vBar.style.width = '100%'; // static
	this.vBar.style.overflow = 'hidden'; // static
	this.vBar.style.position = 'relative'; // static, muss relative sein, um im Explorer den Content beim scrollTop mitzunehmen
	this.vBar.style.height = (parseInt(this.vBarArea.style.height) - parseInt(this.vUp.style.height) - parseInt(this.vDown.style.height)) + 'px'; // auto, custom
	if (this.vBarBgColor) this.vBar.style.backgroundColor = this.vBarBgColor; // custom
	
	//Default-Status des Scrollbalkens START
	this.vAnfasser.style.top = parseInt(this.vBar.style.height) - parseInt(this.vAnfasser.style.height) + 'px'; // auto
	this.vBarContent.style.height = parseInt(this.vBar.style.height)*2 - parseInt(this.vAnfasser.style.height) + 'px'; // auto
	this.vBarContent.style.width = '100%'; // static
	if (this.vBarContentBgColor) this.vBarContent.style.backgroundColor = this.vBarContentBgColor; // custom
	if (this.vBarContentBgImg) this.vBarContent.style.backgroundImage = this.vBarContentBgImg; // custom
	
	this.elm.appendChild(this.vBarArea)
	this.vBarScrollLength = (this.vBarContent.offsetHeight - this.vAnfasser.offsetHeight) / 2;
	this.vBar.scrollTop = this.vBarScrollLength;
	//Default-Status des Scrollbalkens ENDE
	/*Scrollbar zusammensetzten ENDE*/
}

function s_b_createHScrollbar()
{
	/*Scrollbar zusammensetzten START*/
	this.hBarArea = document.createElement('div');
		this.hLeft = document.createElement('div');
		this.hRight = document.createElement('div');
		this.hBar = document.createElement('div');
			this.hBarContent = document.createElement('div');
				this.hAnfasser = document.createElement('div');
	
	this.hLeft.obj = this;
	this.hLeft.setAttribute('id',this.id + "_left");
	this.hRight.obj = this;
	this.hRight.setAttribute('id',this.id + "_right");

	this.hAnfasser.obj = this;
	this.hBar.obj = this;

	ec.registerEvent(this.hAnfasser,'mousedown',registerHAnfasser,false);
	try
	{
		ec.registerEvent(this.hBar,'mousewheel',registerHWheel,false);
		if (!this.hasVBar) ec.registerEvent(this.newContentElm,'mousewheel',registerHWheel,false);
	}
	catch(e){}
	
	ec.registerEvent(this.hLeft,'mousedown',this.registerButton,false);
	ec.registerEvent(this.hRight,'mousedown',this.registerButton,false);

	this.hBarContent.appendChild(this.hAnfasser);
	this.hBar.appendChild(this.hBarContent);
	this.hBarArea.appendChild(this.hLeft);
	this.hBarArea.appendChild(this.hBar);
	this.hBarArea.appendChild(this.hRight);

	this.hBarArea.style.position = 'absolute'; // static
	this.hBarArea.style.height = this.hBarHeight; // auto
	this.hBarArea.style.bottom = '0px'; // static
	this.hBarArea.style.left = '0px'; // static
	this.hBarArea.style.width = (this.hasVBar) ? this.newContentElm.offsetWidth + parseInt(this.contentHMargin) + 'px' : this.newContentElm.offsetWidth + 'px'; // auto

	this.hLeft.style.height = '100%'; // static
	this.hLeft.style.overflow = 'hidden'; // static
	this.hLeft.style.width = this.hLeftWidth; // custom
	if (this.hLeftBgColor) this.hLeft.style.backgroundColor = this.hLeftBgColor; // custom
	if (this.hLeftBgImg) this.hLeft.style.backgroundImage = this.hLeftBgImg; // custom
	
	this.hRight.style.height = '100%'; // static
	this.hRight.style.overflow = 'hidden'; // static
		this.hRight.style.position = 'absolute'; // static, special for horizontal
		this.hRight.style.top = '0px'; // static, special for horizontal
		this.hRight.style.right = '0px'; // static, special for horizontal
	this.hRight.style.width = this.hRightWidth; // custom
	if (this.hRightBgColor) this.hRight.style.backgroundColor = this.hRightBgColor; // custom
	if (this.hRightBgImg) this.hRight.style.backgroundImage = this.hRightBgImg; // custom

	this.hAnfasser.style.height = '100%'; // static
	this.hAnfasser.style.overflow = 'hidden'; // static
	this.hAnfasser.style.position = 'relative'; // static
	this.hAnfasser.style.width = this.hAnfasserWidth; // custom
	if (this.hAnfasserBgColor) this.hAnfasser.style.backgroundColor = this.hAnfasserBgColor; // custom
	if (this.hAnfasserBgImg) this.hAnfasser.style.backgroundImage = this.hAnfasserBgImg; // custom

	this.hBar.style.height = '100%'; // static
	this.hBar.style.overflow = 'hidden'; // static
		this.hBar.style.position = 'absolute'; // static, special for horizontal
		this.hBar.style.top = '0px'; // static, special for horizontal
		this.hBar.style.left = this.hLeftWidth // static, special for horizontal, custom
	this.hBar.style.width = (parseInt(this.hBarArea.style.width) - parseInt(this.hLeft.style.width) - parseInt(this.hRight.style.width)) + 'px'; // auto, custom
	if (this.hBarBgColor) this.hBar.style.backgroundColor = this.hBarBgColor; // custom
	
	//Default-Status des Scrollbalkens START
	this.hAnfasser.style.left = parseInt(this.hBar.style.width) - parseInt(this.hAnfasser.style.width) + 'px'; // auto, muss am Ende 100% sein
	this.hBarContent.style.width = parseInt(this.hBar.style.width)*2 - parseInt(this.hAnfasser.style.width) + 'px'; // auto
	this.hBarContent.style.height = '100%'; // static
	if (this.hBarContentBgColor) this.hBarContent.style.backgroundColor = this.hBarContentBgColor; // custom
	if (this.hBarContentBgImg) this.hBarContent.style.backgroundImage = this.hBarContentBgImg; // custom
	
	this.elm.appendChild(this.hBarArea);
	this.hBarScrollLength = (this.hBarContent.offsetWidth - this.hAnfasser.offsetWidth) / 2; // auto
	this.hBar.scrollLeft = this.hBarScrollLength;
	//Default-Status des Scrollbalkens ENDE
	/*Scrollbar zusammensetzten ENDE*/
}

function s_b_calculateVBar()
{
	this.vMultiplication = (this.newContentElmScrollHeight - this.newContentElmHeight) / this.vBarScrollLength;
}

function s_b_calculateHBar()
{
	this.hMultiplication = (this.newContentElmScrollWidth - this.newContentElmWidth) / this.hBarScrollLength;
}

/******** ******** ******** ******** ******** ******** ******** ********/
/******Fogende Funktionen sind nicht Methoden des Scollbar-Objektes*****/
/******** ******** ******** ******** ******** ******** ******** ********/

/* ANFASSER START */

function registerVAnfasser(e)
{
	e = ec.convertEvent(e);
	e.preventDefault();
	e.stopPropagation();
	this.obj.vBarStartYPos = this.obj.vBarYPos = this.obj.vBar.scrollTop;
	this.obj.intContentVActualPos = this.obj.newContentElm.scrollTop;
	this.obj.vEventStartYPos = e.pageY;
	scrollBars.s_b_html.obj = this.obj;
	
	ec.registerEvent(scrollBars.s_b_html,'mousemove',moveVAnfasser,true);
	ec.registerEvent(scrollBars.s_b_html,'mouseup',unregisterVAnfasser,true);
	ec.removeEvent(this.obj.newContentElm,'scroll',this.obj.updateScrollbars);

}

function moveVAnfasser(e)
{
	e = ec.convertEvent(e);
	e.preventDefault();
	
	var pos = e.pageY - this.obj.vEventStartYPos;
	this.obj.vBarYPos = this.obj.vBarStartYPos - pos;
	//Safari wendet hier die Vorrangregeln durch Klammern nicht korrekt an, deshalb zunaechst d berechnen
	var d = this.obj.vBarStartYPos - pos;
	var invertedVBarYPos = this.obj.vBarScrollLength - d; //von der Ausgangsposition gescrollte Pixel des Scrollbalkens
	this.obj.floatContentVActualPos = invertedVBarYPos * this.obj.vMultiplication; //mit Multiplikator fŸr den Content
	this.obj.vBar.scrollTop = this.obj.vBarStartYPos - pos;
	scrollContentV(this.obj.floatContentVActualPos);
	//document.getElementById('ausgabe').innerHTML = "vBarScrollLength: " + this.obj.vBarScrollLength + "<br>this.obj.vBarStartYPos: " + this.obj.vBarStartYPos + "<br>pos: " + pos + "<br>vBarYPos: " + this.obj.vBarYPos + "<br>invertedVBarYPos: " + invertedVBarYPos + "<br>floatContentVActualPos: " + this.obj.floatContentVActualPos + "<br>newContentElm.scrollTop: " + this.obj.newContentElm.scrollTop + "<br>newContentElm.scrollHeight: " + this.obj.newContentElm.scrollHeight + "<br>newContentElm.offsetHeight: " + this.obj.newContentElm.offsetHeight; // debug
}

function unregisterVAnfasser(e)
{
	ec.removeEvent(scrollBars.s_b_html,'mousemove',moveVAnfasser,true);
	ec.removeEvent(scrollBars.s_b_html,'mouseup',unregisterVAnfasser,true);
	ec.registerEvent(scrollBars.s_b_html.obj.newContentElm,'scroll',this.obj.updateScrollbars);

	scrollBars.s_b_html.obj = null;
}



function registerHAnfasser(e)
{
	e = ec.convertEvent(e);
	e.preventDefault();
	e.stopPropagation();
	this.obj.hBarStartXPos = this.obj.hBarXPos = this.obj.hBar.scrollLeft;
	this.obj.intContentHActualPos = this.obj.newContentElm.scrollLeft;
	this.obj.hEventStartXPos = e.pageX;
	
	scrollBars.s_b_html.obj = this.obj;
	
	ec.registerEvent(scrollBars.s_b_html,'mousemove',moveHAnfasser,true);
	ec.registerEvent(scrollBars.s_b_html,'mouseup',unregisterHAnfasser,true);
}

function moveHAnfasser(e)
{
	e = ec.convertEvent(e);
	e.preventDefault();
	
	var pos = e.pageX - this.obj.hEventStartXPos;
	this.obj.hBarXPos = this.obj.hBarStartXPos - pos;
	//Safari wendet hier die Vorrangregeln durch Klammern nicht korrekt an, deshalb zunaechst d berechnen
	var d = this.obj.hBarStartXPos - pos;
	var invertedHBarXPos = this.obj.hBarScrollLength - d; //von der Ausgangsposition gescrollte Pixel des Scrollbalkens
	this.obj.floatContentHActualPos = invertedHBarXPos * this.obj.hMultiplication; //mit Multiplikator fŸr den Content
	
	this.obj.hBar.scrollLeft = this.obj.hBarStartXPos - pos;
	scrollContentH(this.obj.floatContentHActualPos);
	//document.getElementById('ausgabe').innerHTML = "this.obj.vBarStartYPos: " + this.obj.vBarStartYPos + "<br>pos: " + pos + "<br>vBarYPos: " + this.obj.vBarYPos + "<br>invertedVBarYPos: " + invertedVBarYPos + "<br>floatContentActualPos: " + this.obj.floatContentActualPos + "<br>newContentElm.scrollTop: " + this.obj.newContentElm.scrollTop + "<br>newContentElm.scrollHeight: " + this.obj.newContentElm.scrollHeight + "<br>newContentElm.offsetHeight: " + this.obj.newContentElm.offsetHeight; // debug
}

function unregisterHAnfasser(e)
{
	//conPosition = (newConPosition < 0) ? 0 : (newConPosition > conScrollLength) ? conScrollLength : newConPosition;
	ec.removeEvent(scrollBars.s_b_html,'mousemove',moveHAnfasser,true)
	ec.removeEvent(scrollBars.s_b_html,'mouseup',unregisterHAnfasser,true)
	scrollBars.s_b_html.obj = null;
}

function scrollContentV(pos)
{
	scrollBars.s_b_html.obj.newContentElm.scrollTop = pos;
}

function scrollContentH(pos)
{
	scrollBars.s_b_html.obj.newContentElm.scrollLeft = pos;
}


/* ANFASSER ENDE */

/* BUTTONS START */

function s_b_registerButton(e)
{
	e = ec.convertEvent(e);
	e.preventDefault();
	scrollBars.s_b_html.obj = this.obj;
	ec.registerEvent(scrollBars.s_b_html,'mousemove',ec.preventDefault,true);
	ec.registerEvent(scrollBars.s_b_html,'mouseup',scrollBars.s_b_html.obj.stopButtonScroll,true);
	if (e.target.id.indexOf('up') > 0)
	{
		int_scrollTimeId = setInterval("scrollBars.s_b_html.obj.vScroll(" + this.obj.upButtonContentSpeed + ")","10");
	}
	else if (e.target.id.indexOf('down') > 0)
	{
		int_scrollTimeId = setInterval("scrollBars.s_b_html.obj.vScroll(" + (-this.obj.downButtonContentSpeed) + ")","10");
	}
	else if (e.target.id.indexOf('left') > 0)
	{
		int_scrollTimeId = setInterval("scrollBars.s_b_html.obj.hScroll(" + this.obj.leftButtonContentSpeed + ")","10");
	}
	else if (e.target.id.indexOf('right') > 0)
	{
		int_scrollTimeId = setInterval("scrollBars.s_b_html.obj.hScroll(" + (-this.obj.rightButtonContentSpeed) + ")","10");
	}
}

function s_b_vScroll(wert)
{
	scrollBars.s_b_html.obj.newContentElm.scrollTop -= wert;
	//scrollBars.s_b_html.obj.floatVBarActualPos = scrollBars.s_b_html.obj.vBarScrollLength - scrollBars.s_b_html.obj.newContentElm.scrollTop / scrollBars.s_b_html.obj.vMultiplication;
	//scrollBars.s_b_html.obj.vBar.scrollTop = scrollBars.s_b_html.obj.floatVBarActualPos;
	//document.getElementById('ausgabe').innerHTML = 'vBar.scrollTop: ' + scrollBars.s_b_html.obj.vBar.scrollTop + '<br>newContentElm.scrollTop: ' + scrollBars.s_b_html.obj.newContentElm.scrollTop + '<br>scrollBars.s_b_html.obj.floatVBarActualPos: ' + scrollBars.s_b_html.obj.floatVBarActualPos;
}

function s_b_hScroll(wert)
{
	scrollBars.s_b_html.obj.newContentElm.scrollLeft -= wert;
	//scrollBars.s_b_html.obj.floatHBarActualPos = scrollBars.s_b_html.obj.hBarScrollLength - scrollBars.s_b_html.obj.newContentElm.scrollLeft / scrollBars.s_b_html.obj.hMultiplication;
	//scrollBars.s_b_html.obj.hBar.scrollLeft = scrollBars.s_b_html.obj.floatHBarActualPos;
}

function s_b_stopButtonScroll()
{
	clearInterval(int_scrollTimeId);
	ec.removeEvent(scrollBars.s_b_html,'mousemove',ec.preventDefault,true);
	ec.removeEvent(scrollBars.s_b_html,'mouseup',scrollBars.s_b_html.obj.stopButtonScroll,true);
}

/* BUTTONS ENDE */


/* MOUSEWHEEL START */

function registerVWheel(e)
{
	e = ec.convertEvent(e);
	this.obj.newContentElm.scrollTop += e.eDirection * this.obj.wheelContentVSpeed;
	//this.obj.floatVBarActualPos = this.obj.vBarScrollLength - this.obj.newContentElm.scrollTop / this.obj.vMultiplication;
	//this.obj.vBar.scrollTop = this.obj.floatVBarActualPos;
}

function registerHWheel(e)
{
	e = ec.convertEvent(e);
	this.obj.newContentElm.scrollLeft += e.eDirection * this.obj.wheelContentHSpeed;
	//this.obj.floatHBarActualPos = this.obj.hBarScrollLength - this.obj.newContentElm.scrollLeft / this.obj.hMultiplication;
	//this.obj.hBar.scrollLeft = this.obj.floatHBarActualPos;
}


/* MOUSEWHEEL ENDE */

/* JUMP START */

function jump(obj,target)
{
	window.location.href = target;
	obj.vBar.scrollTop = obj.vBarScrollLength - (obj.newContentElm.scrollTop / obj.vMultiplication);
}

/* JUMP ENDE */

/* Konfiguration START */

function s_b_setBars()
{
	if (arguments[0] == true || arguments[0] == false) this.hasVBar = arguments[0];
	if (arguments.length == 1)
	{
		if (arguments[0] == true || arguments[0] == false) this.hasHBar = arguments[0]
	}
	else
	{
		if (arguments[1] == true || arguments[1] == false) this.hasHBar = arguments[1];
	}
}

function s_b_setContentMargins()
{
	this.contentVMargin = arguments[0];
	this.contentHMargin = (arguments.length == 1) ? arguments[0] : arguments[1];
}

function s_b_setBarWidth()
{
	this.vBarWidth = arguments[0];
	this.hBarHeight = (arguments.length == 1) ? arguments[0] : arguments[1];
}

function s_b_setButtonSize()
{
	if (arguments.length == 1 || arguments.length == 2 || arguments.length == 4)
	{
		this.vUpHeight = arguments[0];
		this.vDownHeight = (arguments.length == 4) ? arguments[2] : arguments[0];
		this.hLeftWidth = (arguments.length == 1) ? arguments[0] : (arguments.length == 2) ? arguments[1] : arguments[3];
		this.hRightWidth = (arguments.length == 1) ? arguments[0] : arguments[1];
	}
}

function s_b_setButtonBGColor()
{
	if (arguments.length == 1 || arguments.length == 2 || arguments.length == 4)
	{
		this.vUpBgColor = arguments[0];
		this.vDownBgColor = (arguments.length == 4) ? arguments[2] : arguments[0];
		this.hLeftBgColor = (arguments.length == 1) ? arguments[0] : (arguments.length == 2) ? arguments[1] : arguments[3];
		this.hRightBgColor = (arguments.length == 1) ? arguments[0] : arguments[1];
	}
}

function s_b_setButtonBGImg()
{
	if (arguments.length == 1 || arguments.length == 2 || arguments.length == 4)
	{
		this.vUpBgImg = "url('" + arguments[0] + "')";
		this.vDownBgImg = (arguments.length == 4) ? "url('" + arguments[2] + "')" : "url('" + arguments[0] + "')";
		this.hLeftBgImg = (arguments.length == 1) ? "url('" + arguments[0] + "')" : (arguments.length == 2) ? "url('" + arguments[1] + "')" : "url('" + arguments[3] + "')";
		this.hRightBgImg = (arguments.length == 1) ? "url('" + arguments[0] + "')" : "url('" + arguments[1] + "')";
	}
}

function s_b_setAnfasserLength()
{
	this.vAnfasserHeight = arguments[0];
	this.hAnfasserWidth = (arguments.length == 1) ? arguments[0] : arguments[1];
}

function s_b_setAnfasserBgColor()
{
	this.vAnfasserBgColor = arguments[0];
	this.hAnfasserBgColor = (arguments.length == 1) ? arguments[0] : arguments[1];
}

function s_b_setAnfasserBgImg()
{
	this.vAnfasserBgImg = "url('" + arguments[0] + "')";
	this.hAnfasserBgImg = (arguments.length == 1) ? "url('" + arguments[0] + "')" : "url('" + arguments[1] + "')";
}

function s_b_setBarBgColor()
{
	this.vBarBgColor = arguments[0];
	this.hBarBgColor = (arguments.length == 1) ? arguments[0] : arguments[1];
}

function s_b_setBarContentBgColor()
{
	this.vBarContentBgColor = arguments[0];
	this.hBarContentBgColor = (arguments.length == 1) ? arguments[0] : arguments[1];
}

function s_b_setBarContentBgImg()
{
	this.vBarContentBgImg = "url('" + arguments[0] + "')";
	this.hBarContentBgImg = (arguments.length == 1) ? "url('" + arguments[0] + "')" : "url('" + arguments[1] + "')";
}

function s_b_setButtonContentSpeed()
{
	if (arguments.length == 1 || arguments.length == 2 || arguments.length == 4)
	{
		this.upButtonContentSpeed = arguments[0];
		this.downButtonContentSpeed = (arguments.length == 4) ? arguments[2] : arguments[0];
		this.leftButtonContentSpeed = (arguments.length == 1) ? arguments[0] : (arguments.length == 2) ? arguments[1] : arguments[3];
		this.rightButtonContentSpeed = (arguments.length == 1) ? arguments[0] : arguments[1];
	}
}

function s_b_setWheelContentSpeed()
{
	this.wheelContentVSpeed = arguments[0];
	this.wheelContentHSpeed = (arguments.length == 1) ? arguments[0] : arguments[1];
}
/* Konfiguration ENDE */


// Konfigurierbare Eigenschaften


	// vertikaler Scrolbalken START
		//this.hasVBar = false;
		//this.contentVMargin = '32px';
		//this.vBarWidth = '9px';
		//this.vUpHeight = '7px';
		//this.vUpBgColor = '#cccccc';
		//this.vUpBgImg = "url('res/pfeil_up.gif')";
		//this.vDownHeight = '7px';
		//this.vDownBgColor = '#cccccc';
		//this.vDownBgImg = "url('res/pfeil_down.gif')";
		//this.vAnfasserHeight = '32px';
		//this.vAnfasserBgColor = '#ffcccc';
		//this.vAnfasserBgImg = "url('res/anfasser.gif')";
		//this.vBarBgColor = '#dddddd';
		//this.vBarContentBgColor = '#cceeee';
		//this.vBarContentBgImg = "url('res/linie.gif')";
		//this.upButtonContentSpeed = 4; //default, custom
		//this.downButtonContentSpeed = 4; //default, custom
		//this.wheelContentVSpeed = 9;
	// vertikaler Scrolbalken ENDE

	// horizontaler Scrolbalken START
		//this.hasHBar = false;
		//this.contentHMargin = '32px';
		//this.hBarHeight = '9px';
		//this.hLeftWidth = '7px';
		//this.hLeftBgColor = '#cccccc';
		//this.hLeftBgImg = "url('res/pfeil_left.gif')";
		//this.hRightWidth = '7px';
		//this.hRightBgColor = '#cccccc';
		//this.hRightBgImg = "url('res/pfeil_right.gif')";
		//this.hAnfasserWidth = '32px';
		//this.hAnfasserBgColor = '#ffcccc';
		//this.hAnfasserBgImg = "url('res/h_anfasser.gif')";
		//this.hBarBgColor = '#dddddd';
		//this.hBarContentBgColor = '#cceeee';
		//this.hBarContentBgImg = "url('res/h_linie.gif')";
		//this.leftButtonContentSpeed = 4; //default, custom
		//this.rightButtonContentSpeed = 4; //default, custom
		//this.wheelContentHSpeed = 9;
	// horizontaler Scrolbalken ENDE

