
function navigationObject(imagepath){
	
	this.imagepath=imagepath
	this.current=null
	this.helpisActive=false
	this.x=0
	this.y=0
	this.dx=0
	this.dy=0
	this.move=move
	
	this.oldTime
	this.offSet=0
	this.currPos=0
	this.naviTop=0
	this.distance=0
	this.factor=0
	this.chaser=null
	this.chaseRate=20
	this.moveTime = 1200	
	this.schienenD=0

	this.dragLayerList=new Array()
	this.activeList = null	
	this.anhangList = new Array()
	this.init=init

	this.setActiveList=setActiveList
	this.addAnhang = addAnhang
	this.positionAnhang = positionAnhang
	
	this.moveDecelerating=moveDecelerating
	this.chaseInit=chaseInit
	this.chase=chase
	this.chaseSwitch=chaseSwitch
	
	
	this.setdxdy=setdxdy
	this.getLayer=getLayer
	this.drag=drag
	this.releaseLayer=releaseLayer
	this.naviimage=null
	this.changeImage = changeImage
	
	
	this.getStat=getStat
	this.getNewStat=getNewStat
	
	this.getLayerByName=getLayerByName
	this.shrinkSchiene=shrinkSchiene
	this.appendLayer=appendLayer
	this.adjustSchiene=adjustSchiene
	
	this.aktivMenu=1
	this.medmenustat=1
	this.news=false
	//this.bnFormFocus = false
	
	this.showMenu=showMenu


	function getStat(){
		
		return (this.x-browser.getScrollLeft())+";"+(this.y-browser.getScrollTop())+";"+this.aktivMenu+";"+this.medmenustat+";"+0+";"+(RoObj.getActive()?RoObj.getActive():this.naviimage) 
	}
	function getNewStat(TG,news){	
		return (this.x-browser.getScrollLeft())+";"+(this.y-browser.getScrollTop())+";"+this.aktivMenu+";"+this.medmenustat+";"+(news?1:0)+";"+TG
	}

	function init(con){
		this.setActiveList()
		
		if (con){
			var tmp=con.split(";")
			for(var i=0;i<3;i++){
				tmp[i]=parseInt(tmp[i])
				if (isNaN(tmp[i])) tmp[i]=0
			}
			this.move(tmp[0],tmp[1])
			this.currPos = this.y
			this.naviTop=this.y
			this.medmenustat=tmp[3]*1
			if (tmp[2]==2){
				this.aktivMenu=this.medmenustat
				this.showMenu(2)
			} else this.showMenu(tmp[2]*1)
			
			this.news=(tmp[4]*1==1)

			this.naviimage=tmp[5]
		}
		else this.showMenu(1)
		this.getLayerByName("LAYER_dragSchiene1").show()
		this.getLayerByName("LAYER_dragSchiene2").show()
		this.setActiveList()
		this.chaseSwitch("on")
		browser.addMouseDownEvent("navigation.getLayer")
		browser.addMouseUpEvent("navigation.releaseLayer")
	}

	function changeImage() {
		if(browser.isIE)
		document.images["bieten"].src = "../modul_xboard/images/navi/bieten.gif"
		document.images["C1_0"].src = "../images/navigation/marker.gif"
	}
	
	function move(x,y){
		this.x=x
		this.y=y
		if (this.x>browser.getInnerWidth()-50) this.x=browser.getInnerWidth()-50
		//if (this.y>browser.getInnerHeight()-50) this.y=browser.getInnerHeight()-50
		if (this.x<-100) this.x=-100
		if (this.y<-50) this.y=-50
		
		for( var i=0; i<this.activeList.length; i++ ) {
			if( this.activeList[i].dragY ) {
			  this.activeList[i].top= this.y + this.activeList[i].oy
			  this.activeList[i].moveY()
			}
		 } 
		 for( var i=0; i<this.activeList.length; i++ ) {
			if( this.activeList[i].dragX) {
			  this.activeList[i].left = this.x + this.activeList[i].ox
			  this.activeList[i].moveX()  
			} 
		}
	}
	
	
	function appendLayer(name){
		var nl=this.getLayerByName(name)
		this.activeList[this.activeList.length] = nl
		nl.move(this.x+nl.left,this.y+nl.top)

	}
	

	function showMenu(nr){
			//alert(this.aktivMenu+" "+nr)
			if ((this.aktivMenu>0)&&(nr==0)) {RoObj.moveBy(-30,0)}
			if ((this.aktivMenu==0)&&(nr>0)) {RoObj.moveBy(30,0)}
			if (this.aktivMenu!=2) {this.medmenustat=this.aktivMenu}
			if (nr==2) naviSETmedMenu()
			
			this.getLayerByName("LAYER_GARAGESMALL").hide()
			this.getLayerByName("LAYER_GARAGEBIG").hide()
			this.getLayerByName("LAYER_GARAGEMEDIUM").hide()
			switch(nr){
				case 0:this.getLayerByName("LAYER_GARAGESMALL").show(); this.shrinkSchiene(38); break
				case 1:this.getLayerByName("LAYER_GARAGEBIG").show(); this.shrinkSchiene(0); break
				case 2:this.getLayerByName("LAYER_GARAGEMEDIUM").show(); this.shrinkSchiene(38); break
			}
			
			this.aktivMenu=nr
			if( this.anhangList.length > 0 ){
				for( var i=0; i<this.anhangList.length; i++ ) 
				this.positionAnhang(this.anhangList[i].id)
			}
	}


	function positionAnhang( name ) {
		var obj = this.getLayerByName( name )
		if( obj.visible ){ 
			switch( this.aktivMenu ){
				case( 0 ) : obj.oy = 62; obj.move(this.x,this.y+62); break
				case( 1 ) : obj.oy = 100; obj.move(this.x,this.y+100); break
				case( 2 ) : obj.oy = 62; obj.move(this.x,this.y+62); break
				default : alert( "Error - Funktion 'positionAnhang'")
			}
		}
		return true	
	}
	
	
	function getLayerByName(name){
		for (i=0;i<this.dragLayerList.length;i++) if (this.dragLayerList[i].id==name) return this.dragLayerList[i]
		return null
	}

	function shrinkSchiene(y){
		this.schienenD=y
		var s1=this.getLayerByName("LAYER_dragSchiene1")
		var s2=this.getLayerByName("LAYER_dragSchiene2")
		s2.oy=s1.oy-y+94
		s2.show()
		s1=this.getLayerByName("LAYER_ECKE")
		s1.clip(0,0,s1.width-y/2,s1.height-y)
	}

	function adjustSchiene(){
		var nw=browser.getInnerWidth()+browser.getScrollLeft()
		var s1=this.getLayerByName("LAYER_dragSchiene1")
		var s2=this.getLayerByName("LAYER_dragSchiene2")
		if( browser.isNav4 ) {
			s1.clip(0,0,nw,s1.height)
			s2.clip(0,0,nw,s2.height)
			s1.layer.width = nw
			s2.layer.width = nw
		
		}else{
			s1.layer.width = nw
			s2.layer.width = nw
			s1.clip(0,0,nw,s1.height)
			s2.clip(0,0,nw,s2.height)
			/*s1.move(browser.getScrollLeft(),s1.top)
			s2.move(browser.getScrollLeft(),s2.top)*/
		}
		
		
		

	}
	

	//Abstaende von Maus-Position zur navi  berechnen
	function setdxdy(e) {
		if( browser.isNav4 ) {
		 	 this.dx = browser.mouseX - this.x
		   this.dy = browser.mouseY - this.y
		}
		if( browser.isIE ) {
		  this.dx = browser.mouseX - this.x
		  this.dy = browser.mouseY - this.y
		}
		return false
	}

	//Wurde ein dragLayer angeklickt?
	function getLayer(e) {
		
		if( browser.isIE || browser.isW3C ) {
			if( browser.isIE ) {
				var obj = window.event.srcElement
				var parent= obj
				while((parent.parentElement!=null)&&(parent.id+"".indexOf("LAYER")==-1)) 
					parent=parent.parentElement
			}
			else if( browser.isW3C ) {
				var obj = e.target
				var parent = obj.parentNode
			}
			if( obj != null ) { 
				for( var i=0; i<this.dragLayerList.length; i++ ) {
					if( parent.id == this.dragLayerList[i].id ) {
						this.current = this.dragLayerList[i]
						break
					}
				}
			}
			if (this.current) if ((!this.current.selectable)||(!this.current.visible)) this.current=null
		}
		
		else if( browser.isNav4 ) {
			this.current=null
			for( var i=0; i<this.dragLayerList.length; i++ )
				if ((this.dragLayerList[i].selectable)&&(this.dragLayerList[i].visible)&&(this.dragLayerList[i].isInside(browser.mouseX-browser.getScrollLeft(),browser.mouseY-browser.getScrollTop()))){
					if (!this.current) this.current=this.dragLayerList[i]
					else if (this.dragLayerList[i].zIndex>=this.current.zIndex) this.current=this.dragLayerList[i]
				}
		}	
		
		//alert(this.current.id)
		//this.setActiveList()
		if(this.current != null) {
			this.chaseSwitch("off")
			if (this.helpisActive) help.chaseSwitch("off")
			this.setdxdy(e)	
			browser.addMouseMoveEvent("navigation.drag")
			return true
		} 
		
		return false
	}

	function drag(e) {
		if(browser.isIE){
			if (this.helpisActive) help.chaseSwitch("off")
			this.chaseSwitch("off")
		}
		this.move(browser.mouseX-this.dx,browser.mouseY-this.dy)
		return true	
	}


	function releaseLayer() {
		browser.removeMouseMoveEvent("navigation.drag")
		this.current = null
		//this.y =  browser.getScrollTop()
		this.naviTop = this.y-browser.getScrollTop()
		this.chaseSwitch("off")
		this.chaseSwitch("on")
		if (this.helpisActive) {
			help.chaseSwitch("off")
			help.chaseSwitch("on")
		}
		
		// help navigation!!!!! **************************************************
		if (this.helpisActive) {
			
			f=getFormular()
			f.helpPos.value=help.getHelpLayerByName('L_HELP').left+';'+help.getHelpLayerByName('L_HELP').top+';'+help.helpContentVisible			
			//help.releaseHelpLayer()
			
		}
		//************************************************************************
		
		return true
	}

	//Liste mit allen Objekten, die verschiebbar und sichtbar sind
	function setActiveList() {
		this.activeList=new Array()
		for( var i=0; i<this.dragLayerList.length; i++ ) {
		  if((this.dragLayerList[i].dragX||this.dragLayerList[i].dragY)&&(this.dragLayerList[i].visible) ) 
		  this.activeList[this.activeList.length] = this.dragLayerList[i]
		}
		return true
	}

	function addAnhang( obj ) {
		this.anhangList[this.anhangList.length] = obj
		return true
	}


	function moveDecelerating( ) {
		var now = new Date()
		var newPos = this.distance * Math.sin( this.factor * ( now.getTime() - this.oldTime )) + this.offSet
		newPos = Math.round( newPos )
		if( this.distance > 0 && newPos > this.currPos || this.distance < 0 && newPos < this.currPos )
		this.move(this.x,this.y+(newPos-this.currPos) )
		return false
	}



	function chaseInit() {

		var now = new Date()
		this.distance = this.target - this.currPos
		this.factor = Math.PI / ( 2 * this.moveTime )
		this.oldTime = now.getTime( )
		var maxDiff = browser.getInnerHeight()
		this.offSet = this.currPos
	}

	function chase() {
		navigation.adjustSchiene()
		browser.dragging=false
		if(this.activeList.length > 0 ) {
			this.currPos = this.y
			var newTarget = browser.getScrollTop()+this.naviTop
			if( this.currPos != newTarget) {
				if( newTarget != this.target ) {
					
					this.target = newTarget
					this.chaseInit()
					
				}
				this.moveDecelerating()
			}
		}
	}

	function chaseSwitch( stat ) {
		//stat = "off"
		if( stat == "on" ) this.chaser=window.setInterval("navigation.chase()", this.chaseRate)
		else {
			window.clearInterval( this.chaser)
			this.chaser=null
		}
		return true
	}
}



function dragObj( id, left, top, width, height, zIndex, visible, dragX, dragY ) {
	
	this.clipleft=0
	this.cliptop=0
	this.clipright = width
	this.clipbottom = height
	this.realWidth=width
	this.realHeight=height
	this.anhang = false
	
	//eigenschaften
	this.id = id
	this.left = left
	this.top = top
	this.width = width
	this.height = height
	this.zIndex = zIndex
	this.visible = visible
	this.dragX = dragX
	this.dragY = dragY
	this.selectable=true
	this.isActive = false
	
	//varibalen
	this.layer = null
	this.ox=left
	this.oy=top
	
	
	//methoden
	this.init = init
	this.show = show
	this.hide = hide
	this.move = move
	this.clip = clip
	this.moveX = moveX
	this.moveY = moveY
	this.setHeight = setHeight
	this.setImage=setImage
	this.origin=origin
	this.isInside=isInside
	this.document=null
	

	this.init()
	
	
	function isInside(x,y){
		return ((x >= this.left) && 
				(x < this.left + this.width) &&
				(y > this.top) &&
				(y < this.top + this.height))
	}

	function clip( left,top,right, bottom ) {
		
		this.cliptop = top
		this.clipright = right
		this.clipbottom = bottom
		this.clipleft = left
		if( browser.isNav4 ) {
			this.layer.clip.top    = top
			this.layer.clip.right  = right
			this.layer.clip.bottom = bottom
			this.layer.clip.left   = left
		}
		else if( browser.isIE )	this.layer.clip = 'rect(' + top + ' ' +  right + ' ' + bottom + ' ' + left +')'
		else if( browser.isW3C ) this.layer.clip = 'rect(' + top + 'px ' +  right + 'px ' + bottom + 'px ' + left +'px )'
	}

	
	function setImage(name,src){
		if (browser.isNav4) this.layer.document.images[name].src=src
		else document.images[name].src=src
	}

	function init() {
		this.layer = browser.isIE?eval('document.all.'+this.id+'.style'):browser.isNav4?document.layers[this.id]:browser.isW3C?document.getElementById(this.id).style:null
		navigation.dragLayerList[navigation.dragLayerList.length] = this
		
		this.document=browser.isIE?eval('document.all.'+this.id):null

		if (browser.isNav4) {
			this.realWidth=this.layer.document.width
			this.realHeight=this.layer.document.height
		}
		else {
			this.realHeight=this.document.offsetHeight
			this.realWidth=this.document.offsetWidth
		}
		
		return false
	}
	
	function hide() {
		if( browser.isIE || browser.isW3C ) 
		this.layer.visibility = "hidden"
		if( browser.isNav4 )
    	this.layer.visibility = "hide"
		this.visible = false
	}

	function origin(){
		this.move(this.dragX?navigation.x+this.ox:this.ox,this.dragY?navigation.y+this.oy:this.oy)
	}

	function show() {
		this.origin()
		if( browser.isIE || browser.isW3C ) 
		this.layer.visibility = "visible"
		if( browser.isNav4 )
    	this.layer.visibility = "show"
		this.visible = true
		navigation.setActiveList()
	}
	
	function move(x,y) {
		this.left=x
		this.top=y
		this.moveX()
		this.moveY()
	}
	
	function moveX() {
		if( browser.isIE) this.layer.pixelLeft = this.left
		else if ( browser.isNav4 ) this.layer.moveTo(this.left,this.top)
		else if( browser.isW3C)	this.layer.left = this.left
	}
	
	function moveY() {
		if( browser.isIE ) this.layer.pixelTop = this.top
		else if ( browser.isNav4 ) this.layer.moveTo(this.left,this.top)
		else if( browser.isW3C )this.layer.top = this.top
	}
	
	function setHeight( h ) {
		this.layer.height = h
		this.height = h
	}
	

}


function menuCOL(col){
	this.aktivMenu=col
	this.aktivImage=null
		
	this.col=col

	this.panels=new Array()
	this.panelstxt=new Array()
	this.activePanel=-1
	this.switchOff=switchOff
	this.showITEM=showITEM
	this.setImage=setImage

	this.switchOff=switchOff

	this.hide=hide
	this.show=show
	this.addPanel=addPanel
	this.getPanel=getPanel
	this.getPanelNrByName=getPanelNrByName
	this.getActiveText=getActiveText		
	this.moveBy=moveBy
	
	
	function moveBy(x,y){
		for (var i=0;i<this.panels.length;i++){
			this.getPanel(i).ox+=x
			this.getPanel(i).oy+=y
		}
	}

		
	function getActiveText(){
		if (this.aktivImage!=null){
			return this.panelstxt[this.activePanel][this.aktivImage.charAt(this.aktivImage.length-1)]
		}else return ""
	}
		
	function addPanel(name,text){
		this.panels[this.panels.length]=name
		this.panelstxt[this.panelstxt.length]=text.split(",")
	}

	function getPanelNrByName(name){
		for (var i=0;i<this.panels.length;i++) if (this.panels[i]==name) return i
		return null
	}
	
	function getPanel(nr){return navigation.getLayerByName("LAYER_COL"+this.panels[nr])}
	function hide(){
		this.switchOff()
		this.aktivImage=null
		for (var i=0;i<this.panels.length;i++)this.getPanel(i).hide()
	}
		
		
	function show(nr){
		if (nr!=this.activePanel){
			if (this.activePanel!=-1){
				this.switchOff()
				this.getPanel(this.activePanel).hide()
			}
		}
		this.activePanel=nr
		this.getPanel(this.activePanel).show()

	}
	
	function setImage(name,aktiv){
		var newimg=navigation.imagepath+"/marker"+(aktiv?"_a":"")+".gif"
		this.getPanel(this.activePanel).setImage("C"+name,newimg)
	}
		

		
	function showITEM(name,more,text,imgnr){
		
		if (this.aktivImage!=null)
			if (this.aktivImage!=name+"_"+imgnr)
				this.setImage(this.aktivImage,false)
				
		this.aktivImage=name+"_"+imgnr
		this.setImage(this.aktivImage,true)
			
		if (more) {
			if (this.aktivMenu==1) {
				RoObj.setTop(2)
				RoObj.menuC3.hide()
				RoObj.menuC2.show(RoObj.menuC2.getPanelNrByName(name+"_"+(imgnr+1)))
			}
			if (this.aktivMenu==2) {
				RoObj.setTop(3)
				RoObj.menuC3.show(RoObj.menuC3.getPanelNrByName(name+"_"+(imgnr+1)))
			}
			RoObj.showPath(RoObj.getStat())
		}
		else{
			if (this.aktivMenu==1) {
				RoObj.showPath("")
				RoObj.setTop(1)
				RoObj.menuC2.hide()
				RoObj.menuC3.hide()
			}
			if (this.aktivMenu==2) {
				RoObj.setTop(2)
				RoObj.menuC3.hide()
				RoObj.showPath(RoObj.getStat())
			}
			if (this.aktivMenu==3) RoObj.showPath(RoObj.getStat())
		}

	}
		
	function switchOff(){
		if (this.aktivImage!=null)
			this.setImage(this.aktivImage,false)
		this.aktivImage=null
	}
}


function ROMENU(){
	this.menuC1=new menuCOL(1)
	this.menuC2=new menuCOL(2)
	this.menuC3=new menuCOL(3)
		
	this.visible=false

	this.show=show
	this.hide=hide
	this.setTop=setTop
	this.getStat=getStat
	this.getActive=getActive

	this.showPath=showPath
	this.moveBy=moveBy
	
	
	function moveBy(x,y){
		this.menuC1.moveBy(x,y)
		this.menuC2.moveBy(x,y)
		this.menuC3.moveBy(x,y)
		var l=navigation.getLayerByName("LAYER_MENUTOP")
		l.ox+=x
		l.oy+=y
		l=navigation.getLayerByName("LAYER_MENU_BACK")
		l.ox+=x
		l.oy+=y
	}

	function showPath(txt)	{
		if (browser.isIE) document.all.THENAVIPAD.innerText=txt
		//else if(browser.isNav4) {
		//	var x=window.document.THENAVIPAD+""
		//	if (x) window.document.THENAVIPAD.SetVariable("path",txt)
		//}
		status=txt
	}
	
	function getActive(){
		return this.menuC3.aktivImage?this.menuC3.aktivImage:this.menuC2.aktivImage?this.menuC2.aktivImage:this.menuC1.aktivImage?this.menuC1.aktivImage:null
	}

	function getStat(){
		return (this.menuC1.aktivImage?this.menuC1.getActiveText():"") + (this.menuC2.aktivImage?" | "+this.menuC2.getActiveText():"") + (this.menuC3.aktivImage?" | "+this.menuC3.getActiveText():"")
	}
	
	function setTop(nr){
		var w
		switch(nr){
			case 1:w=128;break
			case 2:w=256;break
			case 3:w=448;break
		}
		navigation.getLayerByName("LAYER_MENUTOP").clip(0,0,w,46)
		navigation.getLayerByName("LAYER_MENU_BACK").clip(0,0,w+20,220)
	}
	
	function show(){
		if (!this.visible){
			this.visible=true
			this.setTop(1)
			navigation.getLayerByName("LAYER_MENUTOP").show()
			this.menuC1.show(0)
			navigation.getLayerByName("LAYER_MENU_BACK").show()
		}
	}
	function hide(){
		if (this.visible){
			this.showPath("")
			this.visible=false
			navigation.getLayerByName("LAYER_MENUTOP").hide()
			this.menuC1.hide()
			this.menuC2.hide()
			this.menuC3.hide()
			navigation.getLayerByName("LAYER_MENU_BACK").hide()
		}
	}
}



//navlogo_over = new Image()
//navlogo_over.src = "../images/navigation/navilogo_over5.gif"
//off = setInterval("animateLogoOn()",10000)

//onBlur="alert('blur')" //navigation.chaseSwitch('off')

function animateLogoOn() {
	clearInterval(off)
	document.images.navlogo.src = navlogo_over.src
	on = setInterval("animateLogoOff()", 600)
}

function animateLogoOff() {
	clearInterval( on )
	document.images.navlogo.src = "../images/navigation/navilogo.gif"
	off = setInterval("animateLogoOn()",6000)
}
//animateLogo( 'on' )