bw=new checkBrowser()

var loop2, timer2
var loaded2;
var Merker2=false;
var firstMove2=false;
var mouse_pos2;

function makeObj2(obj,nest){		//Object constructor
	if (!nest) {nest=''}
		else {nest='document.'+nest+'.'}
	this.el=0;
	this.css=0;
	if (bw.dom) {
		this.el=document.getElementById(obj);
		this.css=document.getElementById(obj).style;
		this.scrollHeight=this.el.offsetHeight;
		this.clipHeight=this.el.offsetHeight;
		}
	if (bw.ie4) {
		this.el=document.all[obj];
		this.css=document.all[obj].style;
		this.scrollHeight=this.el.offsetHeight;
		this.clipHeight=this.el.offsetHeight;
		}
	if (bw.ns4) {
		this.el=eval(nest+'document.'+obj);
		this.css=eval(nest+'document.'+obj);
		this.scrollHeight=this.css.document.height;
		this.clipHeight=this.css.clip.height;
		}
	this.up=goUp2;this.down=goDown2;
	this.moveIt=moveIt; this.x; this.y;
    this.obj = obj+ "Object";
    eval(this.obj + "=this")
    return this
	}

function goDown2(move){	//Makes the object go up
	if(this.y>(-this.scrollHeight+oCont2.clipHeight)) {
		this.moveIt(0,this.y-move)
		step=(this.y-move)/(-this.scrollHeight+oCont2.clipHeight)
		knubbel_move2(step)
		if(loop2) setTimeout(this.obj+".down("+move+")",speed)
		}
	}
function goUp2(move){	//Makes the object go down
	if(this.y<0) {
		this.moveIt(0,this.y-move)
		step=(this.y-move)/(-this.scrollHeight+oCont2.clipHeight)
		knubbel_move2(step)
		if(loop2) setTimeout(this.obj+".up("+move+")",speed)
		}
	}
function scroll2(speed){	//Calls the scrolling functions. Also checks whether the page is loaded or not.
	if(loaded2){
		loop2=true;
		firstMove2=true;
		if(speed>0) oScroll2.down(speed)
		else oScroll2.up(speed)
		}
	}
function noScroll2(){	//Stops the scrolling (called on mouseout)
	loop2=false
	if(timer2) clearTimeout(timer2)
	}

function knubbel_move2(step) {
	if (step<0) step=0
	if (step>1) step=1
	oKnubbel2.css.top=oKnubbel2.topposition+(step*oKnubbel2.laufweite)
	}


function get_knubbel2(e) {
	if((document.layers && e.which!=1) || (document.all && event.button!=1)) return true; // Rechte Mausbutton
	getMouse(e);
	
	// Activation du Drag
	if(bw.ns4){
		document.captureEvents(Event.MOUSEMOVE);
		}
	document.onmousemove = drag2;

if (firstMove2) {
		if((mouseY>=parseInt(oKnubbel2.css.top) && mouseY<=parseInt(oKnubbel2.css.top)+12) && (mouseX>=oKnubbel2.leftposition && mouseX<=oKnubbel2.leftposition+12)){
			Merker2 = true;
			return false;
			}
		}
	else {
		if((mouseY>=oKnubbel2.topposition && mouseY<=oKnubbel2.topposition+12) && (mouseX>=oKnubbel2.leftposition && mouseX<=oKnubbel2.leftposition+12)){
			Merker2 = true;
			firstMove2=true;
			return false;
			}
		}
	}

function drag2(e) {
	if (Merker2) {
		getMouse(e);
		if (mouseY>=oKnubbel2.topposition && mouseY<=oKnubbel2.bottomposition) {
			oKnubbel2.css.top=mouseY;
			knubbel_position=(mouseY-oKnubbel2.topposition)/(oKnubbel2.laufweite);
			if (knubbel_position<0) knubbel_position=0;
			if (knubbel_position>1) knubbel_position=1;
			drag_content=knubbel_position*(oScroll2.scrollHeight-oCont2.clipHeight);
			oScroll2.moveIt(0,-drag_content);
			}
		else if (mouseY<oKnubbel2.topposition) {
			oKnubbel2.css.top=oKnubbel2.topposition;
			oScroll2.moveIt(0,0);
			}
		else if (mouseY>oKnubbel2.bottomposition) {
			oKnubbel2.css.top=oKnubbel2.bottomposition;
			oScroll2.moveIt(0,-oScroll2.scrollHeight+oCont2.clipHeight);
			}
		// if (bw.ie4 || bw.ie5) return false;
		return false;
		}
	}

function lost_knubbel2(e) {
	Merker2=false;
	}

function wheel2(e)
{
	if (!e) e = window.event;
	// window.alert(e.wheelDelta/10);
	scroll2(-e.wheelDelta/10);
	noScroll2();
}

function scrollInit2(left_knubbel,start_knubbel,hoehe_knubbel){	//Makes the object
	oContainer2=new makeObj2('container');
	oCont2=new makeObj2('divCont2')
	oKnubbel2=new makeObj2('knubbel2');
	// oScroll=new makeObj('textbox','divCont')
	oScroll2=new makeObj2('textbox2','divCont2')
	oScroll2.moveIt(0,0)
	if (start_knubbel) oKnubbel2.topposition=start_knubbel
	else oKnubbel2.topposition=0;
	if (left_knubbel) oKnubbel2.leftposition=left_knubbel
	else oKnubbel2.leftposition=0;
	if (hoehe_knubbel) oKnubbel2.bottomposition=oKnubbel2.topposition+hoehe_knubbel
	else oKnubbel2.bottomposition=oKnubbel2.topposition+0;
	oKnubbel2.laufweite=oKnubbel2.bottomposition-oKnubbel2.topposition
	loaded2=true;
	if(bw.ns4){
		document.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
		}
	document.onmousewheel = wheel2;
	document.onmousedown = get_knubbel2;
	// document.onmousemove = drag;
	document.onmouseup = lost_knubbel2;
	scroll2(1);
	scroll2(-1);
	noScroll2();
	}
