setTimeout("oben=open('','_parent')",200)
satz=""
zeichensatz =new Array("Arial,Normal,12","Times New Roman,Italic,18")
i=new Array()
il=document.getElementsByTagName("img").length
tl=document.getElementsByTagName("span").length
links=0
zz=1
ab=0
foc=0
q=""
z=32
ps=new Array()
v=0
ff="Arial";fst="Normal";fsz='10pt';

function zieh() {
oben.foc=0
bild.style.top=window.event.y-(bild.height/2);
bild.style.left=window.event.x-(bild.width/2)
}

function hol(wert,ob,unt,weit,hoh){
oben.foc=1
bild.src=wert
bild.style.top= ob
bild.style.left=unt
bild.style.height=hoh
bild.style.width=weit
oben.hoch=hoh
oben.quer=weit
}

function textzieh() {
oben.foc=1
if(window.event.button==1){document.getElementsByTagName("textarea")[0].style.top=window.event.y-10;
document.getElementsByTagName("textarea")[0].style.left=window.event.x-20}
}

function gleichzieh() {

if(window.event.button==1){
oben.foc=2
document.getElementsByName("gleichung")[0].style.top=window.event.y-15;document.getElementsByName("gleichung")[0].style.left=window.event.x-20
document.getElementById("gleichfeld").style.top=window.event.y-10;document.getElementById("gleichfeld").style.left=window.event.x-20

}
}


function drucken(){
i=document.getElementsByTagName("img").length
t=document.getElementsByTagName("span").length

document.getElementById("bild").src='null.gif';
druck=open("","_blank","width=800px,height=1200px,fullscreen=no,menubar=yes,toolbar=yes");


with(druck.document){
write("<html><head><title>Protokollfix</title>")
write("<style>sub{font-size:12px;}</style>")
}

druck.document.write("</head><body>")
druck.document.write("<h1 align=center>" + document.getElementsByTagName('h1')[0].lastChild.data) +"</h1>";
druck.document.write("</h1>")

for(x=0;x<i;x++)if(document.images[x].style.visibility != 'hidden')druck.document.write(' <img src=' + document.images[x].src + '  style=\"position:absolute;top:'  + document.images[x].style.top + ';left:' + document.images[x].style.left + ';width:' + document.images[x].width + ';height:' + document.images[x].height +  '; \">' )

for(x=0;x<t;x++)if(document.getElementsByTagName("span")[x].style.visibility != 'hidden')druck.document.write(' <span id=\"tz\" style=\"font-family:Arial;position:absolute;top:'  + document.getElementsByTagName("span")[x].style.top + ';left:' + document.getElementsByTagName("span")[x].style.left + ';font-size:\'' + document.getElementsByTagName("span")[x].style.fontSize + '\';font-style:\'' + document.getElementsByTagName("span")[x].style.fontStyle +  '\';\" >' + document.all.tz[x].innerHTML + ' </span> ')


druck.document.write("</body></html>")
druck.window.print()
druck.focus()
}



function setz() {

if(window.event.button==1){
graufind=bild.src.substr(bild.src.length-8, bild.src.length)

if(graufind=='grau.gif'){
document.write("<div style='background:#bbbbbb;width:" + bild.width + ";height:" + bild.height + ";'></div>");
bild.src='null.gif';
return}else{
document.write(" <img id = 'note' src=" + bild.src + " style='position:absolute;left:"+ (window.event.x-(bild.width/2)) + ";top:"+ (window.event.y-(bild.height/2 )+1) + ";height:"+ oben.hoch +";width:"+ oben.quer + ";' ondblclick=\" hol(this.src,this.style.top,this.style.left,this.style.width,this.style.height); this.src='null.gif';\"> "  );
bild.style.top=window.event.y-(bild.height/2);bild.style.left=window.event.x+(bild.width/2);
}
}
}

function setztext(wert){

satz=""
if(wert.length>0){
for(x=0;x<wert.length;x++){
zeichen=wert.substr(x,1)
if(zeichen==String.fromCharCode(13)) zeichen="<BR>"
if(zeichen==String.fromCharCode(32)) zeichen="&nbsp;"
satz=satz+zeichen

}

document.write("<span id='tz' style=\"position:absolute;left:" + (parseInt(document.getElementsByTagName("textarea")[0].style.left)+1) + ";top:"+ (parseInt(document.getElementsByTagName("textarea")[0].style.top) + 1) + ";font-family:'" + oben.ff + "';font-style:'" + oben.fst + "';font-size:'" + oben.fsz + "';\" ondblClick='holtext(this.innerHTML,this.style.top,this.style.left);this.innerHTML=\"\"'  >" +  satz + "</span>")
with(document.getElementsByTagName("textarea")[0]){
style.top=  50
style.left=50
value=""
}
}
satz=""
}

function holtext(satz,ob,li){
while(satz.indexOf("&nbsp;")>0){
satz=satz.replace(/&nbsp;/," ")
}
while(satz.indexOf("<BR>")>0){
satz=satz.replace(/<BR>/,"\n")
}
textzeile.value=satz
textzeile.style.top=ob
textzeile.style.left=li;
}

function setzgleich(){
if(gleichung.value!=""){
document.write("<span id='tz' style=\"position:absolute;left:" + (parseInt(document.all.gleichfeld.style.left) ) + ";top:"+ (parseInt(document.all.gleichfeld.style.top) ) + ";font-family:'" + oben.ff + "';font-style:'" + oben.fst + "';font-size:'" + oben.fsz + "';\" onclick=this.style.visibility=\"hidden\" >" +  document.all.gleichfeld.innerHTML + "</span>")

with(document.getElementsByName("gleichung")[0]){
style.top=  100
style.left=100
value=""
}
}
document.all.gleichfeld.style.top=100
document.all.gleichfeld.style.left=100
 gleichung.style.top=100
gleichung.style.left=100
gleichung.style.cursor="e-resize"
gleichung.value=""
q=""
document.all.gleichfeld.innerHTML=""
}


function ausloes(wert){
u=window.event.keyCode
if(u==13 && window.event.shiftKey){satz=satz + "<br>";return}
if(u==13)setztext(textzeile.value)
return
}

function gleich() {
oben.foc=2
y=z
ps[0] = " "
z=window.event.keyCode
qlen=gleichung.value.length
if(z<13){z=27}
if (z==13){
setzgleich()
} else if (z==62) {
v=v+1
ps[v]= "&#8594;" // statt &THORN
q = q + ps[v]
} else if (z == 27) {
if (v>0) {q = q.substr(0,q.length - ps[v].length)
v=v-1
} else {
gleichung.focus()
}
} else if ((z>32) && ( y == 94)) {
v=v+1
sus = String.fromCharCode(z)
ps[v]=sus.sup()
q = q.substr(0,q.length-1) + ps[v]
} else if ((z>32) && (y==95) ) {
v=v+1
sus = String.fromCharCode(z)
ps[v]=sus.sub()
q = q.substr(0,q.length-1) + ps[v]
} else {
v=v+1
ps[v]= String.fromCharCode(z)
q= q + ps[v]
}
qalt=gleichung.value.length
gleichung.style.color="yellow"
gleichung.value=""
document.all.gleichfeld.innerHTML="<body bgcolor='#aabb99' ><font face='arial' size='+1'>&nbsp;" +q +"</font>"
}
