//---------------------Mouseevents des Scrollers------------------------------------
function mouseDown(e) {
if (scrollableBrowser){
	// lb: if ((ns4 && e.which == 1) || ie4) {
	if ((ns4 && e.which == 1) || ie4 || ns6) {
		if (ns4 || ns6) {var x=e.pageX; var y=e.pageY}
		if (ie4) {var x=event.x; var y=event.y+document.body.scrollTop}
		//mac
//--------------------steuert den sensetiven Bereich im x-Wert--ff---------------------
		if (ie4 && (navOS=='Mac')){x -= 0;}
		myscroll.mouseDown(x,y)		
		//Mausrad beim ie4 deaktivieren
		if(ie4 && event.button == 4){alert('Diese Taste ist in diesem \n Bereich deaktiviert !');
		return false}		
		if (myscroll.active || myscroll.arrow.active) return false
	}
}//end-if
}
function mouseMove(e) {
if (scrollableBrowser){
	// lb: if (ns4) {var x=e.pageX; var y=e.pageY}
	if (ns4 || ns6) {var x=e.pageX; var y=e.pageY
		//status = 'x: ' + x + ' y: '+y
		}
	if(ns6){//vermeiden des feshaengen des scrollers an der maus
		if(y <= 4 || y >= 240){
			myscroll.mouseUp()
			}
		}
	if (ie4) {var x=event.x; var y=event.y+document.body.scrollTop}
	//mac
	if (ie4 && (navOS=='Mac')){x -= 10;}
	myscroll.mouseMove(x,y)
	
	//Text markieren beim ie4 deaktivieren
	if(ie4 && event.button == 1){;}return false	
	if (myscroll.active || myscroll.arrow.active) return false
}//end-if
}
function mouseUp(e) {
if (scrollableBrowser){
	myscroll.mouseUp()
}//end-if
}
//---------------------Classe Scroll---------------
function Scroll() {//name,x,y,width,height
var x = 50;
if(ns4){x = 45;}
if (ie4 && (navOS=='Mac')){x = 40;}
var scrollInc = 7;
if(ns6){scrollInc = 14;}

	this.name = 'myscroll'//name
	ScrollObjects[ScrollObjects.length] = this.name
	this.x = 486//x
	this.y = 160//y
	this.w = 267//width
	this.h = 255//height
	this.url = null
	this.loaded = false
	this.refresh = false
	this.active = false
	this.mouseYnew = 0
	this.mouseYold = 0
	this.bar = new Object()
	this.arrow = new Object()
	this.arrow.active = false
	this.box = new Object()
	this.border = new Object()
	this.images = false
	this.visible = true
	this.setH = false
	this.history = new Array()
	this.historyLoc = -1
	this.historyLen = -1
	this.css = ''
	this.div = ''
	this.visibility = null
	this.zIndex = 25
	this.slideInc = scrollInc
	this.slideSpeed = 20
	this.obj = name + "Object"
	eval(this.obj + "=this")
	this.setMargins = ScrollSetMargins
	this.setMargins(0,2,0,2)//Abstand des Contents zum Scroller
	this.setDimensions = ScrollSetDimensions
	this.setDimensions(11,15,36,1)//Groesse von scrollleiste,up-downButton,scroller,border
	this.setColors = ScrollSetColors
	this.setColors(null,null,null,null,null)//Farben des Scrollers
	this.setNestInfo = ScrollSetNestInfo
	this.setNestInfo(null,0,0)
	this.preload = ScrollPreload
	this.setImages = ScrollSetImages
	this.build = ScrollBuild
	this.load = ScrollLoad
	this.activate = ScrollActivate
	this.jumpTop = ScrollJumpTop
	this.jumpBottom = ScrollJumpBottom
	this.mouseDown = ScrollMouseDown
	this.mouseMove = ScrollMouseMove
	this.mouseUp = ScrollMouseUp
	this.slide = ScrollSlide
}
function ScrollSetDimensions(bar,arrow,box,border) {
	this.bar.v = bar
	this.arrow.v = arrow
	this.box.v = box
	this.border.v = border
	this.bar.height = this.h-2*this.border.v-this.box.v-this.arrow.v
}
function ScrollSetColors(background,border,bar,arrow,box) {
	this.bgcolor = background
	this.border.color = border
	this.bar.color = bar
	this.arrow.color = arrow
	this.box.color = box
}
function ScrollSetMargins(left,right,top,bottom) {//left,right,top,bottom
	this.marginLeft = left
	this.marginRight = right
	this.marginTop = top
	this.marginBottom = bottom
}
function ScrollPreload(imgObj,imgSrc) {
	if (imgSrc!=null) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
		eval(imgObj+'s = true')
	}
	else eval(imgObj+'s = false')
}
function ScrollSetImages(box0,box1,arrowUp0,arrowUp1,arrowDn0,arrowDn1,bar,barHeight) {
if (scrollableBrowser) {
	this.preload(this.obj+'.box.image0',box0)
	this.preload(this.obj+'.box.image1',box1)
	this.preload(this.obj+'.arrow.upimage0',arrowUp0)
	this.preload(this.obj+'.arrow.upimage1',arrowUp1)
	this.preload(this.obj+'.arrow.dnimage0',arrowDn0)
	this.preload(this.obj+'.arrow.dnimage1',arrowDn1)
	this.preload(this.obj+'.bar.image',bar)
	this.bar.imageH = barHeight
}// end-if
}
function ScrollSetNestInfo(nestref,x,y) {
	if (ns4 && nestref) {
		this.nestref = nestref
		this.nest = nestref+'.document.'
	}
	else {
		this.nestref = null
		this.nest = ''
	}
	this.nestX = x
	this.nestY = y
	this.ref = this.nest+this.name+'Div.document.'+this.name+'TextCtr.document.'+this.name+'TextDiv'
}
function ScrollBuild() {
if (scrollableBrowser) {
	var nm = this.name
	var b = this.border.v
	var a = this.arrow.v
	var br = this.bar.v
	var bx = this.box.v
	var ml = this.marginLeft
	var mr = this.marginRight
	var mt = this.marginTop
	this.refX = this.x+b+ml
	this.refY = this.y+b+mt
	var pa = ' {position:absolute'
	var l = '; left:'
	var t = '; top:'
	var w = '; width:'
	var h = '; height:'
	var c = '; clip:rect(0,'
	var ec = ',0); '
	var h2b = this.h-2*b
	var ibc = 'background-color:'
	var nbc = '; layer-background-color:'
	var tw = ""+this.w-br-2*b-ml-mr
	var bgc = (this.bgcolor!=null) ? ibc+this.bgcolor+nbc+this.bgcolor : ''
	var bdc = (this.border.color!=null) ? ibc+this.border.color+nbc+this.border.color : ''
	var barc = (this.bar.color!=null) ? ibc+this.bar.color+nbc+this.bar.color : ''
	var boxc = (this.box.color!=null) ? ibc+this.box.color+nbc+this.box.color : ''
	var arc = (this.arrow.color!=null) ? ibc+this.arrow.color+nbc+this.arrow.color : ''
	end = ';}\n'
	var vis = (this.visibility!=null)? '; visibility:'+this.visibility : ''
	var z = (this.zIndex!=null)? '; z-index:'+this.zIndex : ''
	this.css = '<style type="text/css">\n'+
	'#'+nm+'Div'+pa+l+this.x+t+this.y+w+this.w+h+this.h+c+this.w+','+this.h+ec+bgc+vis+z+end+
	'#'+nm+'BorderTop'+pa+w+this.w+h+b+c+this.w+','+b+ec+bdc+end+
	'#'+nm+'BorderBottom'+pa+t+(this.h-b)+w+this.w+h+b+c+this.w+','+b+ec+bdc+end+
	'#'+nm+'BorderLeft'+pa+w+b+h+this.h+c+b+','+this.h+ec+bdc+end+
	'#'+nm+'BorderRight'+pa+l+(this.w-b)+w+b+h+this.h+c+b+','+this.h+ec+bdc+end+
	'#'+nm+'BarDiv'+pa+l+(this.w-b-br)+t+b+w+br+h+h2b+c+br+','+h2b+ec+barc+'; visibility:hidden'+end+
	'#'+nm+'BoxDiv'+pa+t+a+w+br+h+bx+c+br+','+bx+ec+boxc+end+
	'#'+nm+'ArrowUpDiv'+pa+l+0+t+0+w+br+h+a+c+br+','+a+ec+arc+end+
	'#'+nm+'ArrowDnDiv'+pa+l+0+t+(h2b-a)+w+br+h+a+c+br+','+a+ec+arc+end+
	'#'+nm+'BarCover'+pa+l+0+t+0+w+br+h+h2b+c+br+','+h2b+ec+'}\n'+
	'#'+nm+'TextCtr'+pa+l+(b+ml)+t+b+w+tw+h+h2b+c+tw+','+h2b+ec+'}\n'+
	'#'+nm+'TextDiv'+pa+t+mt+w+tw+end+
	'</style>'
	//alert(this.css);
	this.div = ''
	if (ie4) this.div += '<iframe name="'+this.name+'Frame" width=0 height=0 style="display:none"></iframe>\n'
	// lb Beginn
	if (ns6) this.div += '<iframe name="'+this.name+'Frame" width=0 height=0 style="display:none"></iframe>\n'
	// lb End  class="transparent"
	this.div += '<div id="'+nm+'Div">\n'+
	'<div id="'+nm+'BarDiv">'
	this.div += (this.bar.images)? '<img src="'+this.bar.image.src+'" width="'+this.bar.v+'" height="'+this.bar.imageH+'">':''
	this.div += '<div id="'+nm+'BoxDiv">'
	this.div += (this.box.image0s)? '<img name="'+nm+'BoxImg" src="'+this.box.image0.src+'">':''
	this.div += '</div>\n<div id="'+nm+'ArrowUpDiv">'
	this.div += (this.arrow.upimage0s)? '<img name="'+nm+'ArrowUpImg" src="'+this.arrow.upimage0.src+'">':''
	this.div += '</div>\n<div id="'+nm+'ArrowDnDiv">'
	this.div += (this.arrow.dnimage0s)? '<img name="'+nm+'ArrowDnImg" src="'+this.arrow.dnimage0.src+'">':''
	this.div += '</div>\n'+
	'<div id="'+nm+'BarCover"></div>\n'+
	'</div>\n'+
	'<div id="'+nm+'BorderTop">\n</div>\n'+
	'<div id="'+nm+'BorderBottom">\n</div>\n'+
	'<div id="'+nm+'BorderLeft">\n</div>\n'+
	'<div id="'+nm+'BorderRight">\n</div>\n'+
	'<div id="'+nm+'TextCtr">\n'+
	'<div id="'+nm+'TextDiv">\n'
	this.divStart = this.div
	this.divEnd = '\n</div>\n</div>\n</div>'
	this.div += this.divEnd
	//alert(this.divStart);
	document.write(this.css)
}// end-if
}
function ScrollLoad(url) {
	if (url != this.url) {
		this.historyLoc += 1
		this.historyLen = this.historyLoc
		this.history[this.historyLen] = url
		this.reload()
	}
}
ScrollObjects = new Array()
function ScrollRefresh() {
	for (var i=0;i<ScrollObjects.length;i++) {
		if (eval(ScrollObjects[i]+".refresh")) {
			eval(ScrollObjects[i]+".activate()")
		}
	}
}
function ScrollActivate() {
if (scrollableBrowser){
	if (this.refresh) {
		this.refresh = false
		if (ie4) document.all[this.name+'TextDiv'].innerHTML = parent.frames[this.name+'Frame'].document.body.innerHTML
	}
	this.lyr = new DynLayer(this.name+'Div',this.nestref)
	this.textlyr = new DynLayer(this.name+'TextDiv',this.nest+this.name+'Div.document.'+this.name+'TextCtr')
	this.boxlyr = new DynLayer(this.name+'BoxDiv',this.nest+this.name+'Div.document.'+this.name+'BarDiv')
	this.arrowuplyr = new DynLayer(this.name+'ArrowUpDiv',this.nest+this.name+'Div.document.'+this.name+'BarDiv')
	this.arrowdnlyr = new DynLayer(this.name+'ArrowDnDiv',this.nest+this.name+'Div.document.'+this.name+'BarDiv')
	this.barlyr = new DynLayer(this.name+'BarDiv',this.nest+this.name+'Div')
	if (ns4) {
		this.textlyr.css.clip.right = this.w-this.bar.v-2*this.border.v-this.marginLeft-this.marginRight
		if (!this.setH) {
			this.textlyr.height = this.textlyr.doc.height
			this.textlyr.css.clip.bottom = Math.max(this.textlyr.height,this.h-2*this.border.v-this.marginTop)
		}
		else {
			this.textlyr.height = this.newHeight
			this.textlyr.css.clip.bottom = this.newHeight
			this.setH = false
		}
	}
	else if (ie4) {
		if (!this.setH) this.textlyr.height = document.all[this.name+"TextDiv"].scrollHeight
		else {
			this.textlyr.height = this.newHeight
			this.setH = true
		}
	}
	// lb Beginn -> zentrale Stelle
	else if (ns6) {
		if (!this.setH) this.textlyr.height = document.getElementById(this.name+"TextDiv").offsetHeight
		else {
			this.textlyr.height = this.newHeight
			this.setH = true
		}
	}
	// lb End -> jetzt ist Scroll-Balken sichbar
	this.ratio = (this.textlyr.height+this.marginTop+this.marginBottom-this.h+2*this.border.v)/(this.bar.height-this.arrow.v)
	this.jumpTop()
	if (this.ratio>0) {
		this.loaded = true
		if (this.visibility!='hidden') this.barlyr.show()
	}
	else {
		this.loaded = false
		this.barlyr.hide()
	}
}//end-if
}
function ScrollJumpTop() {
	this.boxlyr.moveTo(0,this.arrow.v)
	this.textlyr.moveTo(0,this.marginTop)
}
function ScrollJumpBottom() {
	this.boxlyr.moveTo(0,this.bar.height)
	this.textlyr.moveTo(0,-this.ratio*(this.boxlyr.y-this.arrow.v)+this.marginTop)
}
function ScrollMouseDown(x,y) {
	var b = this.border.v
	var a = this.arrow.v
	var br = this.bar.v
	var bx = this.box.v
	var xr = this.x+this.nestX
	var yr = this.y+this.nestY
	var brl = xr+this.w-b-br
	if (this.ratio>0 && x>brl && x<brl+br && y>=yr+b && y<yr+this.h-b) {
		var bxt = yr+b+this.boxlyr.y
		if (y>=bxt && y<bxt+bx) {
			if (this.box.image1s) this.boxlyr.doc.images[this.name+"BoxImg"].src = this.box.image1.src
			this.clickYnew = y-this.boxlyr.y
			this.clickYold = y
			this.active = true
		}			
		else if (y<yr+b+a) {
			if (this.arrow.upimage1s) this.arrowuplyr.doc.images[this.name+"ArrowUpImg"].src = this.arrow.upimage1.src
			this.arrow.dir = 1
			this.arrow.active = true
			this.slide()
		}
		else if (y>=yr+this.h-b-a) {
			if (this.arrow.dnimage1s) this.arrowdnlyr.doc.images[this.name+"ArrowDnImg"].src = this.arrow.dnimage1.src
			this.arrow.dir = -1
			this.arrow.active = true
			this.slide()
		}
		else {
			if (y<=yr+b+a+bx/2) this.boxlyr.moveTo(0,a)
			else if (y>yr+this.h-b-a-bx/2) this.boxlyr.moveTo(0,this.bar.height)
			else this.boxlyr.moveTo(0,y-this.y-this.nestY-b-bx/2)
			if (this.box.image1s) this.boxlyr.doc.images[this.name+"BoxImg"].src = this.box.image1.src
			this.textlyr.moveTo(0,-this.ratio*(this.boxlyr.y-a)+this.marginTop)
			this.clickYnew = y-this.boxlyr.y
			this.clickYold = y
			this.active = true
		}
	}
}
function ScrollMouseUp() {
	this.active = false
	this.arrow.active = false
	this.refY = this.y+this.border.v+Math.floor(this.textlyr.y)
	if (this.box.image1s) this.boxlyr.doc.images[this.name+"BoxImg"].src = this.box.image0.src
	if (this.arrow.upimage1s)this.arrowuplyr.doc.images[this.name+"ArrowUpImg"].src = this.arrow.upimage0.src
	if (this.arrow.dnimage1s)this.arrowdnlyr.doc.images[this.name+"ArrowDnImg"].src = this.arrow.dnimage0.src
}
function ScrollMouseMove(x,y) {
	if (!this.active) return
	var diff = y-this.clickYold
	var a = this.arrow.v
	var bxy = this.boxlyr.y
	var brh = this.bar.height
	if ((bxy>a && bxy<brh) || (bxy==a && diff>=0) || (bxy==brh && diff<=0)) {
		if ((bxy>a && bxy+diff<a) || (bxy<brh && bxy+diff>brh)) {
			if (bxy+diff<a) this.boxlyr.moveTo(0,a)
			else if (bxy+diff>brh) this.boxlyr.moveTo(0,brh)
			this.clickYold = bxy+this.clickYnew
		}
		else {
			this.boxlyr.moveTo(0,y-this.clickYnew)
			this.clickYold = y
		}
		this.textlyr.moveTo(0,-this.ratio*(this.boxlyr.y-a)+this.marginTop)
	}
}
function ScrollSlide() {
	if (this.arrow.active) {
		if ((this.arrow.dir==1 && this.textlyr.y<this.marginTop-this.slideInc) || (this.arrow.dir==-1 && this.textlyr.y>-(this.textlyr.height+2*this.border.v+this.marginBottom-this.h-this.slideInc))) {
			this.textlyr.moveBy(0,this.arrow.dir*this.slideInc)
			this.boxlyr.moveTo(0,(this.textlyr.y-this.marginTop)/-this.ratio+this.arrow.v)
			setTimeout(this.obj+".slide()",this.slideSpeed)
		}
		else {
			if (this.arrow.dir==1) this.textlyr.moveTo(0,this.marginTop)
			else if (this.arrow.dir==-1) this.textlyr.moveTo(0,-(this.textlyr.height+2*this.border.v+this.marginBottom-this.h))
			this.boxlyr.moveTo(0,(this.textlyr.y-this.marginTop)/-this.ratio+this.arrow.v)
		}
	}
}

/*
Copyright (C) 2001    opus 5 interactive medien gmbh
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
