// herwig.petershausen.de

var r=-80; // onmouseover bei muecke.gif
function movebug()
{ var d=document.getElementById("bug"), x;
  if (d)
  { x=parseInt(d.style.left);
    if (x<100) r=80; else if (x>620) r=-80;
    d.style.left=x+r;
    d.style.top=40+parseInt(Math.random()*360) 
} }

function MailErr(s) // true bei falscher Mail-Adresse
{ var j=true, k, w='.-_%#!+~';
  if (s.indexOf('@')>0 && s.lastIndexOf('.')>2 && s.length>5)
  { j=false;
    for (i=0; i<s.length; i++)
    { k=s.charAt(i);
      if ((k<"@"||k>"Z")&&(k<"a"||k>"z")&&(k<"0"||k>"9")&& w.indexOf(k)<0)
      { j=true; break
    } }
  } return j
}

function checkform() // Mail-Formular prüfen
{ m=document.f.Text.value;
  if (m.length<60 || m.lastIndexOf(" ")<40)
  { alert ('Kein plausibler Text.'); return false }
  if (document.f.Fa.value=="")
  { alert ('Bitte geben Sie Ihren Namen ein.'); document.f.Fa.focus(); return false }
  m=document.f.Mail.value;
  if (MailErr(m))
  { alert ('Mail-Adresse fehlt oder fehlerhaft.'); document.f.Mail.focus(); return false }
  return true
}

// Vergrößertes Bild ein- oder ausblenden
var shown='';
function switchbox(b)
{ var e, i, x=document.getElementById('ovl'), y=document.getElementById('img');
  if(x)
  { if (b!='' && b!=shown)
    { y.innerHTML='<img src="'+b+'" alt="Aktuell">'; e="visible"; shown=b
      i=document.documentElement.clientHeight;
      if (i<580) i=2; else i=parseInt(i/2-240); x.style.bottom=i+"px";
      i=document.documentElement.clientWidth;
      if (i<780) i=2; else i=parseInt(i/2-380); x.style.right=i+"px";
    } else { e="hidden"; shown='' }
    x.style.visibility=e; return false
  } else return true
}
