//
//	Modulare DHTML Navigation 1.0
//	-----------------------------


//_________________________________________________________________________________________________________________
var layerList = new Array()


function getLayerByID(ID){
	ID=ID*1
	for (var i=0;i<layerList.length;i++) if (layerList[i].id==ID) return layerList[i]
	alert("Layer "+ID+" not found!")
	return null
}


function layerObject(name, id, left, top, width, height, visible,content,zind) {
	this.getLayer=getLayer
	this.init=init
	this.content=content

	//STANDARDVARIABLEN
	this.layer=null
	this.document=null
	this.zind=zind

	this.name=name
	this.id=id
	this.x=left
	this.y=top
	this.width=width
	this.height=height
	this.visible=visible	
	this.ox=left
	this.oy=top

	this.realWidth
	this.realHeight
	this.clipleft=0
	this.cliptop=0
	this.clipright=width
	this.clipbottom=height
	
	//FUNTIONEN
	this.hide=hide
	this.show=show
	this.move=move
	this.clip=clip

	// ANIMATION
	this.action_sx=0
	this.action_sy=0
	this.action_step=0
	this.RunAction=RunAction
	this.doRunAction=doRunAction

	function RunAction(x2,y2,steps){
		this.action_sx=(x2-this.x)/steps
		this.action_sy=(y2-this.y)/steps
		this.action_step=steps
		this.doRunAction()
	}

	function doRunAction(){
		if (this.action_step>0){
			this.action_step--
			this.move(this.x+this.action_sx,this.y+this.action_sy)			
			setTimeout("getLayerByID("+this.id+").doRunAction()",20)
		}else {
			this.ox=this.x
			this.oy=this.y
			
			}
	}


	function hide() {
		this.visible=false
		if (browser.isNav4) this.layer.visibility = "hide"
		else this.layer.visibility = "hidden"
	}

	function show() {
		this.visible=true
		if (browser.isNav4) this.layer.visibility = "show"
		else this.layer.visibility = "visible"
	}

  	function move(x,y) {
		if (browser.isNav4) this.layer.moveTo(x,y);
		else {this.layer.left=x;this.layer.top=y}
		this.x=x
		this.y=y
	}

	function clip(a1,b1,a2,b2) {
		this.clipleft=a1
		this.cliptop=b1
		this.clipright=a2
		this.clipbottom=b2
		if (browser.isNav4) {
			this.layer.clip.left   = a1
			this.layer.clip.top    = b1
			this.layer.clip.right  = a2
			this.layer.clip.bottom = b2
		}
		else this.layer.clip = 'rect(' + b1 + ' ' +  a2 + ' ' + b2 + ' ' + a1 +')'
	}



	function getLayer(){
		var rw,body,vis
	
		body="<body marginwidth=0 marginheight=0 topmargin=0 leftmargin=0>"
		vis=""
		if (browser.isNav4) {
			if (this.visible) vis="show"
			else vis="hide"
			rw="<layer name=\"L"+this.id+"L\" left="+this.x+" top="+this.y+" width="+this.width+" height="+this.height+" visibility=\""+vis+"\" z-index="+this.zind+">"
			rw+=body+this.content
			rw+="</layer>\n"
		}else {
			if (this.visible) vis="visible"
			else vis="hidden"
			if (!(this.width==0&&this.height==0)) rw="<div id=\"L"+this.id+"L\"  style=\"position:absolute; overflow:hidden; left:"+this.x+"px; top:"+this.y+"px; width:"+this.width+"px; height:"+this.height+"px; visibility:"+vis+"; z-index:"+this.zind+"\">"
			else rw="<div id=\"L"+this.id+"L\"  style=\"position:absolute; overflow:hidden; left:"+this.x+"px; top:"+this.y+"px;  visibility:"+vis+"; z-index:"+this.zind+"\">"
			
			rw+=body+this.content
			rw+="</div>\n"
		}
		return rw
	}
	

	function init(){
		//KONSTRUKTOR
		if (browser.isNav4) {
			this.layer=document.layers["L"+this.id+"L"]
			this.layer.width=width
			this.layer.height=height
			this.realWidth=this.layer.document.width
			this.realHeight=this.layer.document.height
		}
		else {
			this.document=eval('document.all.L' + this.id + 'L')
			this.layer=this.document.style
			this.realWidth=this.document.offsetWidth
			this.realHeight=this.document.offsetHeight
		}
		if (this.visible) this.show()
		this.clip(0,0,this.width,this.height)
		layerList[layerList.length]=this
	}
}

//----


	//globale browser variablen
	var isIE,isNav4,isW3C

	// BROWSER bestimmen
	if (navigator.appName.indexOf("Netscape") != -1) {
		if (parseInt(navigator.appVersion) == 4) 				// Netscape Communicator 4.x
		isNav4 = true
		else if (parseInt(navigator.appVersion) >= 5) 		// Netscape 6 oder Mozilla
		isW3C = true
	}
	else {
		if ((parseInt(navigator.appVersion) >= 4)
		 && (navigator.appName.indexOf("Microsoft") != -1)) 	// MSIE 4.x oder hoeher
		isIE = true
		if (navigator.userAgent.indexOf("Opera 5") != -1) 	// Opera 5.x - wird wie MSIE behandelt
		isIE = true
	}

	
	
	//sichtbare dimensionen
	function getInnerWidth() {return isIE?document.body.clientWidth:isNav4||isW3C?window.innerWidth:0}
	function getInnerHeight() {return isIE?document.body.clientHeight:isNav4||isW3C?window.innerHeight:0}

	//virtuelle gršsse des doks bestimmen
	function getScrollWidth() {return isIE?document.body.scrollWidth:isNav4||isW3C?document.width:0}
	function getScrollHeight(){return isIE?document.body.scrollHeight:isNav4||isW3C?document.height:0}

	//aktuelle scrollposition auslesen
	function getScrollLeft() {return isIE?document.body.scrollLeft:isNav4?window.pageXOffset:isW3C?window.scrollX:0}
	function getScrollTop(){return isIE?document.body.scrollTop:isNav4?window.pageYOffset:isW3C?window.scrollY:0}

	//scrollposition neu setzen

	function setScroll(x,y) {
		if (isIE) {document.body.scrollLeft=x;document.body.scrollTop=y}
		else if ((isNav4)||(isW3C)) window.scrollTo(x,y)
	}




	//globale variablen, die man braucht...
	var action_sx,action_sy,action_step,action_time,actual_event,action_max,action_acc
	// intern: einen schritt ausfŸhren
	function doRunAction(){
		if (action_step>0){
			action_step--
			window.scroll(getScrollLeft()+action_sx,getScrollTop()+action_sy)
		if (action_acc)
			setTimeout("doRunAction()",action_time+Math.abs(action_step-action_max)/
			action_max/2*action_time)
		else setTimeout("doRunAction()",action_time)
		}else doEvent()
	}



	

	// wird immer am ende aufgerufen, wenn man am ziel angekommen ist
	function doEvent(){
		//hier kann man "actual_event" pruefen und entsprechend weiterern code ausfuehren lassen
		actual_event=null
	}



/*
	go ist die hauptfunktion, um irgendwohin zu scrollen
   parameter:
   - x2,y2: endposition
   - steps: schritte, die gebraucht werden, um zu der position zu laufen
   - timeintervall: zeitverzšgerung zwischen den schritten in ms (gut zwischen 20 u. 50 ms)
   - theEvent: frei definierbarer wert, der spŠter in der funktion doEvent geprŸft werden kann
   - acceleration (true/false) bei false werden die schritte linear ausgefŸhrt,
   							   bei true erreicht der schritt in der mitte die hoechste geschwindigkeit (timeintervall), am anfang und ende ist das tempo langsamer (timeintervall*1.5)

   beispiel:

   go(100,200,20,30,"home")

   scrollt in 20 schritten zur position 100,200 und braucht pro schritt 30ms.
   wenn das fertig ist, wird doEvent() ausgelšst, dort kšnnte man weiteren code einfŸgen, z.b.:

   if (actual_event=="home") alert('Jetzt bin ich zuhause!')
   if (actual_event=="kitchen") alert('Jetzt bin ich in der KŸche!')
*/

	function go(x2,y2,steps,timeintervall,theEvent,acceleration){
		action_acc=acceleration
		action_max=steps/2
		action_time=timeintervall
		actual_event=theEvent
		if (steps<1) steps=1
		action_sx=(x2-getScrollLeft())/steps
		action_sy=(y2-getScrollTop())/steps
		action_step=steps
		doRunAction()
	}

/*
var NEWWIN=null
	
function openNEW(urlvar)
{
	var newwin=true
	if (NEWWIN!=null) if (!NEWWIN.closed)NEWWIN.focus()
	if (newwin)NEWWIN=window.open(urlvar, "NEW", 'toolbar=no,resizable=no,scrollbars=no,width=400,height=400,screenX=0,screenY=0,left=0,top=0');
}


if ((navigator.userAgent+"").toUpperCase().indexOf("MAC") > -1){
	document.write('<LINK HREF="font/style.css" REL="styleSheet" TYPE="text/css">')

	if(navigator.appName=='Netscape')
	{document.write('<LINK HREF="font/style-mac.css" REL="styleSheet" TYPE="text/css">')}
	else 
	{document.write('<LINK HREF="font/style.css" REL="styleSheet" TYPE="text/css">')}	
}
else {
	if(navigator.appName=='Netscape')
	{document.write('<LINK HREF="font/style-ne.css" REL="styleSheet" TYPE="text/css">')}
	else 
	{document.write('<LINK HREF="font/style-pc.css" REL="styleSheet" TYPE="text/css">')}	
}

*/




function GotoUrl(url)
{
	top.location.href=url
}


