breite=0
oben=0

ie=document.all?true:false
eingeblendet=0
feldgeklickt=0

function Einblendung(text1,text2,fs,fn_nr,nr_nicht_anzeigen,teil,teil2,x,x2,proforma) {
	if (ie && event) {
		var Klick=event.srcElement
		geklicktesElement=Klick
		zuletztgeklickt=absTop(Klick)
		geklicktesElementAbstandVonOben=zuletztgeklickt-document.body.scrollTop
	}

	proforma=0
	if (text2=="" || text2=="<P>") proforma=1
	teil=text2.split("{P STYLE='font-family:Arial; font-size:{ohne}1{ohne}0pt;'}")
	text2=teil[0]
	for (x=1; x<teil.length; x++) {
		teil2=teil[x].split("{BR}{BR}_~_")
		teil[x]=teil2[0]
		for (x2=1; x2<teil2.length; x2++) {
			farbe="#007c38"
			klasse="IBRtext"
			if (teil2[x2].match(/DocType=BauR/)) {
				farbe="#da203d"
				klasse="Wernertext"
			}
			teil[x]+="{DIV CLASS=idvDOKUMENTABSATZ_links STYLE='margin-top:10px; border-left: "+farbe+" 5px solid; padding-left:4px;' CLASS='"+klasse+"'}_~_"+teil2[x2]+"{/DIV}"
		}
		text2+="{DIV CLASS=idvDOKUMENTABSATZ_links STYLE='font-family:Arial; font-size:{ohne}1{ohne}0pt; border: 1px dashed; margin-top:10px; padding:4px;'}"+teil[x].replace(/\{\/P\}\{\/DIV\}$/,"</DIV></DIV>")
	}
	feldgeklickt=1
	schliessen()
	if (eingeblendet) return
	linkspunkt=10
	hochpunkt=10
	schliessen()
//	alert("*"+text1+"*")
	txtart="einblrspr"
	Registerkarte="Fundstelle"
	if (text1 == "" && text2.match(/<!-- Norm: ([^ ]*) -->/)) {
		Ziel=RegExp.$1
		text1="<IMG SRC=\"/bilder/pfeilrechts.gif\" width=\"10\" height=\"10\" BORDER=0> <I><FONT SIZE=-2><A HREF=\"/IBRNavigator/dokumentanzeige.php?"+Ziel+"\" onClick=\"parent.Hauptframe.oeffne_neu(this.href); return false\">In separatem Fenster anzeigen</A></FONT></I>"
		txtart="einblnorm"
		Registerkarte="Gesetz"
	}
	drag=0
	if (text1 != "") {
		text1=text1.replace(/\{/g,"<").replace(/\}/g,">").replace(/<ohne>/g,"")
		text2=text2.replace(/\{/g,"<").replace(/\}/g,">").replace(/<ohne>/g,"")
	}
	einzublenden='<table border=0 width=100% style="font-family:Arial; font-size:10pt;"><tr><td>'
	einzublenden+='<P CLASS=idvDOKUMENTABSATZ_links STYLE="font-weight:bold">'+text1.replace(/\@/g,"")+'</tr>'
	fundstelle="diesem Aktenzeichen"
	if (fs!=3) text2=text2.replace(/(<A HREF[^>]*)>/g,"$1 onClick=\"parent.Hauptframe.oeffne_neu(this.href); return false\">")
	if (fs!=2) {
		if (fs==1) fundstelle="dieser Fundstelle"
		einzublenden+='<tr><td colspan=2><P CLASS=idvDOKUMENTABSATZ_links STYLE="font-style:italic">Zu '+fundstelle+' finden Sie bei ibr-online:'+text2.replace(/_~_/g,"<IMG SRC=\"/bilder/pfeilrechts.gif\" width=\"10\" height=\"10\" BORDER=0> ").replace(/~~_#_~~/g,"'")
	}
	einzublenden+='</td></tr></table>'
	if (fs==3) {
		einzublenden='<table width="100%" border="0"><tr><td>Standort in der Gliederung:</td><td align="right"><a href="#" onClick="parent.Hauptframe.schliessen(); return false;"><img src="/bilder/ico_close.gif" border="0" title="Schließen"></a></td></tr></table>'
		txtart="einblort"
	}
	if (fs==4) {
		if (nr_nicht_anzeigen) fn_nr0=""
		else fn_nr0=" "+fn_nr
		einzublenden=fussnoten_navigation(fn_nr)
		txtart="einblfn"
		Registerkarte="Fussnote"
	}
	if (fs==2) {
		einzublenden+='<p CLASS=idvDOKUMENTABSATZ_links>'+text2.replace(/_~_/g,"<IMG SRC=\"/bilder/pfeilrechts.gif\" width=\"10\" height=\"10\" BORDER=0> ").replace(/~~_#_~~/g,"'")
	}
	else if (fs>1) {
		einzublenden+='<p class=idvDOKUMENTABSATZ_links>'+text2
	}
	if (fs==4) {
		einzublenden+=fussnoten_navigation2(fn_nr)
	}
	einzublenden=einzublenden.replace(/<ohne>/g,"")
	parent.InfoFrame.document.getElementById("Registerkarte"+Registerkarte).innerHTML=einzublenden
	if (parent.InfoFrameSichtbar==0 && !proforma && confirm("Die gewünschte Zusatzinformation steht im linken Info-Bereich zur Verfügung. Soll dieser wieder eingeblendet werden?")) { //  Dabei springt die vorliegende Textanzeige an den Anfang des aktuellen Abschnitts.
		parent.InfoFrame.InfoFrame_ausblenden_einblenden()
// 	Durchführung der Positionsanpassung
//		alert("!"+absTop(geklicktesElement)+"\n"+geklicktesElementAbstandVonOben)
		document.body.scrollTop=absTop(geklicktesElement)-(2/3*geklicktesElementAbstandVonOben)
	}
	parent.InfoFrame.Wechseln("Reiter"+Registerkarte)
}

function fussnoten_navigation(akt_fn) {
	var nr_nicht_anzeigen=1
	var tmp = 
'<table border="0" cellspacing="0" cellpadding="0" align="center" style="margin-top:15pt;">'+
'	<tr>'+
'		<td class="nav-button" width="100">'+
'			<table width="100%" border="0" cellspacing="1" cellpadding="0">'+
'				<tr>'+
'					<td class="nav-funktion" width="15"><a title="Vorherige Fußnote" href="javascript:parent.Hauptframe.fussnote('+(akt_fn-1)+','+nr_nicht_anzeigen+')" onClick="this.title=\'\'; this.blur()"><img src="pixelpfeil-links.gif" alt="" width="4" height="12" border="0"></a></td>'+
'					<td class="nav-funktion" width="70"><span class=info>Fußnote</span></td>'+
'					<td class="nav-funktion" width="15"><a title="Nächste Fußnote" href="javascript:parent.Hauptframe.fussnote('+(akt_fn+1)+','+nr_nicht_anzeigen+')" onClick="this.title=\'\'; this.blur()"><img src="pixelpfeil-rechts.gif" alt="" width="4" height="12" border="0"></a></td>'+
'				</tr>'+
'			</table>'+
'		</td>'+
'	</tr>'+
'</table>'
	return tmp
}

function fussnoten_navigation2(akt_fn) {
	var nr_nicht_anzeigen=1
	var tmp = 
'<table border="0" cellspacing="0" cellpadding="0" align="center" style="margin-top:15pt;">'+
'	<tr>'+
'		<td class="nav-button" width="100">'+
'			<table width="100%" border="0" cellspacing="1" cellpadding="0">'+
'				<tr>'+
'					<td class="nav-funktion" width="100"><a href="javascript:fussnote_sync('+(akt_fn)+')"  onClick="this.blur()" style="font-weight:normal; font-size: 10px; font-family: Arial;">Zur Fußnote im<br>Text springen</a></td>'+
'				</tr>'+
'			</table>'+
'		</td>'+
'	</tr>'+
'</table>'
	return tmp
}

function schliessen() {
	parent.InfoFrame.document.getElementById("einblendung").style.visibility="hidden"
	eingeblendet=0
	return false
}

function klick() {
	if (!feldgeklickt) schliessen()
	feldgeklickt=0
}

function initialisieren() {
	if (!ie) {
		document.getElementsByTagName("body")[0].addEventListener("click", geklickt, true)
	}
}


function geklickt(ev) {
	geklicktesElement=ev.target
	zuletztgeklickt=absTop(geklicktesElement)
	geklicktesElementAbstandVonOben=zuletztgeklickt-document.body.scrollTop
}

function block_a() {
	if (document.all) document.write("<P>")
	if (document.layers) document.write("<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=#C0C0C0><TR><TD VALIGN=TOP>")
	else document.write("<DIV ALIGN=Center><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"85%\"><TR><TD><TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0><TR><TD width=1 height=1 BGCOLOR=#C0C0C0><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=#C0C0C0><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD BGCOLOR=#C0C0C0><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=#C0C0C0><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=black><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD></TR><TR><TD width=1 height=1 BGCOLOR=#C0C0C0><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=white><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD BGCOLOR=white><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=#808080><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=black><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD></TR><TR><TD width=1 height=1 BGCOLOR=#C0C0C0><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=white><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD BGCOLOR=#C0C0C0><TABLE BORDER=0 CELLPADDING=2 CELLSPACING=10 BGCOLOR=beige><TR><TD VALIGN=TOP>")
}

function block_b() {
	if (document.layers) document.write("</TD></TR></TABLE>")
	else document.write("</TD></TR></TABLE></TD><TD width=1 BGCOLOR=#808080><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 BGCOLOR=black><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD></TR><TR><TD width=1 height=1 BGCOLOR=#C0C0C0><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=#808080><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD BGCOLOR=#808080><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=#808080><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=black><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD></TR><TR><TD width=1 height=1 BGCOLOR=black><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=black><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD BGCOLOR=black><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=black><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD><TD width=1 height=1 BGCOLOR=black><IMG WIDTH=1 HEIGHT=1 src=\"leer.gif\"></TD></TR></TABLE></TD></TR></TABLE></DIV>")
}

function norm(a,b,c) {
	// Vorbereitung der Positionsanpassung
	if (ie && event) {
		var Klick=event.srcElement
		geklicktesElement=Klick
		zuletztgeklickt=absTop(Klick)
		geklicktesElementAbstandVonOben=zuletztgeklickt-document.body.scrollTop
//		alert(Klick.tagName+"\n"+absTop(Klick)+"\n"+document.body.scrollTop+"\n"+geklicktesElementAbstandVonOben)
	}

	Einblendung("","<P>")
	Einblendung("","<P STYLE=\"font-family:Arial; font-size:10pt;\"><B>"+vs[a]+"<SPAN ID=GesetzAbschluss></SPAN>",2)
	if (b != "") Norm_markieren(a,b)
}

function oeffne_neu(url) {
	url=url.replace(/.*WEBSITEPREFIX__/,"http://www.ibr-online.de")
	win=window.open(url,'documentWindow','width=600,height=600,top=50,left=300,resizable=Yes,scrollbars=Yes')
	win.focus()
}

function separatesfenster(abschnitt) {
	TextNrJS="0"
	if (parent.InfoFrame.TextNrJS) TextNrJS=parent.InfoFrame.TextNrJS
	zeige_in_eigenem_fenster=abschnitt
	win=window.open('kommentar-einzelansicht.php?Textnr='+TextNrJS,'documentWindow'+TextNrJS,'width=600,height=600,resizable=Yes,scrollbars=Yes,screenX=50, screenY=50,left=50,top=50');
	win.focus();
}

function zu_merkerliste(abschnitt) {
	parent.InfoFrame.abschnitt_merken(abschnitt)
	return // IK!!
}

function fussnote(fn_nr,nr_nicht_anzeigen,text) {
	// Vorbereitung der Positionsanpassung
	if (ie && event) {
		var Klick=event.srcElement
		geklicktesElement=Klick
		zuletztgeklickt=absTop(Klick)
		geklicktesElementAbstandVonOben=zuletztgeklickt-document.body.scrollTop
	}

	if (document.getElementById("fn"+fn_nr)) {
		text=document.getElementById("fn"+fn_nr).innerHTML.replace(/onclick="Einblendung/g,"onclick=\"parent.Hauptframe.Einblendung").replace(/onclick="norm/g,"onclick=\"parent.Hauptframe.norm")
		Einblendung("","",4,fn_nr,nr_nicht_anzeigen)
		Einblendung("",text,4,fn_nr,nr_nicht_anzeigen)
	}
	else {
		alert("Keine weitere Fußnote in diesem Kapitel vorhanden")
	}
}
	
function Norm_markieren(norm,temp,temp2) {
	norm = norm.replace(/ § |\/|-/g,"_")
	temp=norm+temp
	if (parent.InfoFrame.document.getElementById(temp)) {
		temp2 = temp.replace(/S[0-9]+$/,"")
		if (!parent.InfoFrame.document.getElementById(temp2)) {
			temp2=temp
		}
		if (parent.InfoFrame.document.getElementById(temp).offsetTop>parent.InfoFrame.document.body.clientHeight-30) {
			parent.InfoFrame.document.body.scrollTop=absTop(parent.InfoFrame.document.getElementById(temp))-60
		}
		parent.InfoFrame.document.getElementById(temp).style.backgroundColor="silver"
	}
}

if (!ie) {
	document.getElementsByTagName("body")[0].addEventListener("click", geklickt, true)
}

window.onerror = Fehler

function Fehler(Nachricht,Datei,Zeile) {
	meinFehler = Nachricht+"\n"+Datei+"\n"+Zeile
	if (ie && Nachricht == "Zugriff verweigert") {
//		alert("Es ist ein Fehler aufgetreten:\n\nDer untere Frame ist nicht in der gleichen Domain wie die Suchmaschine. Sie haben zwei Möglichkeiten, den Fehler zu beheben:\n\nEntweder gehen Sie mit der Rückwärtstaste soweit zurück, bis im unteren Frame wieder eine IBR-Seite angezeigt wird\n\noder\n\nSie laden die Suchmaschine neu, indem Sie mit der Maus das Adressfeld aktivieren und die Eingabetaste drücken.\n\nDieser Fehler tritt meistens dann ein, wenn Sie den Schalter \"Treffer markieren\" betätigen, bevor die Seite vollständig geladen ist.")
	}
	else {
//		alert("Es ist ein Fehler aufgetreten. Die Fehlerangaben lauten:\n\n"+meinFehler+"\n\nWenn dieser Fehler häufiger auftritt, so melden Sie ihn bitte unter Angabe der Fehlermeldung und der Umstände, unter denen er auftritt, an die Email-Adresse cd@id-verlag.de")
	}
	return true
}


function InhaltsverzeichnisErstellen(x,y) {
	self.focus()
	if (!parent.initialisiert && parent.InfoFrame.document.getElementById("RegisterkarteGliederung")) {
		parent.InfoFrame.initialisierung(1)
	}
	verweise = document.getElementsByTagName("A")
	letzterpunkt = 0
	ersterpunkt = 0
	bearbeiter=""
	if (document.getElementById("Bearbeiter")) bearbeiter=" ("+document.getElementById("Bearbeiter").innerHTML+")"
	for (y=0; y<verweise.length; y++) {
		if (verweise[y].id.indexOf("verz")==0) {
			tempv=verweise[y].id.replace(/^verz/,"verznr")
			glnrtmp=""
			if (document.getElementById(tempv)) glnrtmp=document.getElementById(tempv).innerHTML+" "
			letzterpunkt=verweise[y].id.substr(4).replace(/_$/,"").replace(/_/g,".")
			if (ersterpunkt == 0) ersterpunkt=letzterpunkt
			if (!parent.gl_txt_Angabe[letzterpunkt]) parent.gl_txt[parent.gl++]=letzterpunkt+"\t"+glnrtmp+verweise[y].innerHTML+bearbeiter
			bearbeiter=""
		}
	}
	aktuellerabschnitt=letzterpunkt.replace(/\..*/,"")
	parent.InfoFrame.gliederung_generieren(aktuellerabschnitt)
}

// ---

function absTop(el) {
	if (!el) return 0
	return (el.offsetParent)? el.offsetTop+absTop(el.offsetParent) : el.offsetTop;
}

function a2() {
	if (breite != document.body.clientWidth) sammeln2()
	hoehe=document.body.clientHeight //document.getElementsByTagName("body")[0].offsetHeight
//	alert(document.body.clientHeight)
	for (x in stelle) {
//		if (confirm(x)) break
		if (x > document.body.scrollTop+20) break
	}
//	self.status=">>"+document.body.scrollTop+" >> "+x+" >> "+stelle[x]+" >> "+(hoehe+document.body.scrollTop)+" >> "+positionganzunten
//	if (altsprung!=stelle[x]) window.setTimeout("parent.InfoFrame.sprung(stelle[x].substr(1))",100)
	if ((hoehe+document.body.scrollTop) > positionganzunten && positionganzunten != 0) {
//		alert("Wir sind ganz unten...\n"+letzterpunkt)
		if (letzterpunkt != 0 && letzterpunkt!=altsprung) parent.InfoFrame.sprung(letzterpunkt)
		altsprung=letzterpunkt
	}
	else if (altsprung!=stelle[x]) {
		if (stelle[x]==0) {
//			alert("Wir sind ganz oben...")
			if (ersterpunkt != 0) parent.InfoFrame.sprung(ersterpunkt)
		}
		else {
			sprungziel=stelle[x].substr(1).replace(/\.$/,"")
//			alert(sprungziel)
//			window.setTimeout("parent.InfoFrame.sprung(sprungziel)",1000)
			parent.InfoFrame.sprung(sprungziel)
		}
		altsprung=stelle[x]
	}
//	stat.src = "/include/stat.php?komm-"+stelle[x]+"&x"+zahl.substr(0,4)
	if (mz5) window.setTimeout("a2()",500)
}

stelle = new Array()
altsprung=""

function sammeln2() {
	breite=document.body.clientWidth // document.getElementsByTagName("body")[0].offsetWidth
	stelle = new Array()
	v=0
//	protokoll=""
	for (x=0; x<document.getElementsByTagName("td").length; x++) {
		if (document.getElementsByTagName("td")[x].id.indexOf("g")==0) {
//			protokoll+=document.getElementsByTagName("td")[x].id
			elementposition=absTop(document.getElementsByTagName("td")[x])
			stelle[elementposition]=v
//			protokoll+="\t"+elementposition+"\t"+v+"\n"
			v=document.getElementsByTagName("td")[x].id
		}
	}
	positionganzunten=absTop(document.getElementById("weiterzu"))
//	protokoll+="0"
	elementposition=positionganzunten
	stelle[elementposition]=v
//	protokoll+="\t"+elementposition+"\t"+v+"\n"
//	alert(protokoll)
}

function SeiteGeladen() {
	sammeln2() // ggf. wird 2mal hintereinander gesammelt, aber das ist in Ordnung
	anker=window.location.hash.replace(/^#/,"")
	if (anker != "") {
		if (document.getElementById("g"+anker)) { // korrigiert die Sprungungenauigkeit des IE und bewegt den Moz überhaupt, zu springen, wenn der Anker von oben übernommen wurde
			document.getElementById("g"+anker).scrollIntoView(true)
		}
		else if (anker.match(/^[0-9]+$/)) {
			if (document.getElementById("rz"+anker)) { // Randziffern-Sprung: mit etwas Rand nach oben
				document.body.scrollTop=absTop(document.getElementById("rz"+anker))-30
			}
			else {
				alert("Die gewählte Randnummer ist nicht vorhanden")
			}
		}
	}
/*
	spantags=document.getElementsByTagName("TREFFER")
	trefferliste=""
	trefferlisteZ=0
	for (x=0; x<spantags.length; x++) {
		trefferliste+=x+"\n"
		trefferlisteZ++
	}
//	alert("Treffer: "+trefferlisteZ)
	if (parent.InfoObenFrame.document.getElementById("Trefferzahl")) {
		if (trefferlisteZ>0) {
			parent.InfoObenFrame.document.getElementById("Trefferzahl").innerHTML=trefferlisteZ+" "
		}
		else {
			parent.InfoObenFrame.document.getElementById("Trefferzahl").innerHTML=""
		}
	}
*/
	if (mz5) {
		a2()
	}
}

function mouseMove(e) {
	mx=event.x+document.body.scrollLeft
	my=event.y+document.body.scrollTop
}

breite=0
hoehe=0

breite=0
//alert(window.name)
oben=0

window.onscroll = a2
window.onload = SeiteGeladen
//document.body.onclick=angeklickt
//window.addEventListener ("scroll" , a2 , true );
mz5 = ((document.getElementById) && (!document.all) && (document.documentElement))

function angeklickt() { //DEAK
	var Klick=event.srcElement
	alert(Klick.tagName+"\n"+absTop(Klick)+"\n"+document.body.scrollTop)
//	zuletztgeklickt=absTop(Klick)
	if (window.positionsanpassung && positionsanpassung==1) {
		document.body.scrollTop=absTop(Klick) //document.body.scrollTop
		positionsanpassung=0
	}
}



