// Scripts (c) by Andreas Glatz and selfhtml

var NavVersion = navigator.appVersion;

var NavName    = navigator.appName;

var isV4 = (NavVersion >= 4); 
var isNS = (NavName == 'Netscape');
var isIE = (NavName == 'Microsoft Internet Explorer');

var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;


function DHTML_init() {

 if (window.opera) {
     OP = 1;
 }
 if(document.getElementById) {
   DHTML = 1;
   DOM = 1;
 }
 if(document.all && !OP) {
   DHTML = 1;
   MS = 1;
 }
if(window.netscape && window.screen && !DOM && !OP) {
   DHTML = 1;
   NS = 1;
 }
}

var stat=0;
var infowin = null;
function showinfo(URL)
 {
  if (stat != 0) {infowin.close();stat=0}
  infowin=window.open(URL,'titel','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,hotkeys=no,width=840, height=650, left=100, top=25')
  infowin.focus()
  stat=1
 }                    
 
 
var scrollbarlength=250;
var Gloss = null;
function Glossary(titel,text)
 {
  if (stat != 0) {Gloss.close();stat=0}

    scb='no';
    if (text.length > scrollbarlength) scb = 'yes';
    Gloss=window.open('','titel','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scb+',resizable=yes,copyhistory=no,hotkeys=no,width=400,height=400,left=40,top=120')
    Gloss.document.open();
    Gloss.document.write('<HTML><HEAD>');
    Gloss.document.write('<TITLE>'+titel+'</TITLE></HEAD>');
    Gloss.document.write('<BODY BGCOLOR="#FFFFFF" Background="grayg.gif" TOPMARGIN="0" text=#000000 link=#000080 vlink=#000080 alink=#000080>');
    Gloss.document.write('<table cellspacing="0" cellpadding="10" border="0"><tr valign="top">');
    Gloss.document.write('<td><b>'+titel+'</b></td></tr>');
    Gloss.document.write('<tr valign="top">');
    Gloss.document.write('<td>'+text);
    Gloss.document.write('<br><A HREF="JavaScript:self.close()">Schließen</A></td>');
    Gloss.document.write('</tr></table></BODY></HTML>');

    Gloss.document.close();
    Gloss.focus();
    stat=1;
 }  

function hexstrtoint(str,l)
{
 if((l>8) || (l>str.length)) return 0;
 str.toUpperCase();
 var a,n,c;
 var n=1;
 var res=0;
 for(i=l-1;i>=0;i--)
  {
   c=str.charCodeAt(i);
   if((c>=0x30) && (c<=0x39)) a=c-0x30;
   else	if((c>=0x41) && (c<=0x46)) a=10+c-0x41;
   res=res+a*n;
   n=n*16;
  }	
 return res;
}

function decm(a,sbj)
{
 a=a.replace(/<ANL>/,"<A>anl<D>gov");
 a=a.replace(/<A>/,"@");
 while(a.search(/<D>/)!=-1) a=a.replace(/<D>/,".");
 a="mailto:"+a+"?subject="+sbj;
 window.open(a);
}

function chksite(site)
{
 if(site.length==0) return true;	 
 if(document.URL.toLowerCase().search(site)==-1) return false;
 return true;
}

function strdecode(str,pwkey)
{
	var s="";
	var n=str.length;
	var ver=hexstrtoint(str,2);
	var a,i,pwc,val,valb,dig;

	if(ver==1)
   {
    for(i=1;i<(n>>1);i++)
    {
    dig=str.charAt(i*2)+str.charAt(i*2+1);
    val=hexstrtoint(dig,2);
    pwc=((pwkey>>(8*((i-1)%4))) & 0xFF);
    //alert(i+": "+val+" xor "+pwc+" = "+(val^pwc));
    s=s+String.fromCharCode(val^pwc);
   }		
 }
else if(ver==2)
 {
  dig=str.charAt(n-2)+str.charAt(n-1);
  valb=hexstrtoint(dig,2);
  for(i=(n>>1)-3;i>=0;i--)
   {
    dig=str.charAt(2*i+2)+str.charAt(2*i+3);
    val=hexstrtoint(dig,2);
    pwc=((pwkey>>(8*(i%4))) & 0xFF);
    a=val^valb;      
    //alert(i+": "+val+" xor "+valb+" = "+a+" xor "+pwc+" ="+(a^pwc));
    s=String.fromCharCode(a^pwc)+s;
    valb=val;
   }		
 } 
  //alert(s);
	return s;
}


function maildecode(str,site)
{
var mail="";
var pw=0xA2B7C1D8;
var a,b,i;

site=site.toLowerCase();
if(site.length>0)
{
 if(!chksite(site)) return "decode not allowed";
 
 a=site.length;
 if(a>0)
  {
   while((a%4)!=0) {a++;site=site+"*";}
   b=a>>2;
   for(i=0;i<b;i++)
    pw=pw+site.charCodeAt(i*4)+0x100*site.charCodeAt(i*4+1)+0x10000*site.charCodeAt(i*4+2)+0x1000000*site.charCodeAt(i*4+3);
  }
}

 mail=strdecode(str,pw);

 if(mail.length==0) return "cannot decode mail";

return mail;
}

function decsec(str,site,chkpw,chkval)
{
	var site=site.toLowerCase();
	var pw="";
	var pwkey=0x271828AC;
	var i,a,b;
	
	if(!chksite(site)) return "section decoding prohibited!";
	if(chkval)
	 {
	 	var rn;
	 	var rstr,ret;
	 	rstr="";
	 	for(i=0;i<4;i++)
	 	 {
	 	 	rn=Math.floor(Math.random()*62);
	 	 	if(rn<26) rn+=65;
	 	 	else if(rn<52) rn+=71;
	 	 	else rn-=4;	
	 	 	rstr=rstr+String.fromCharCode(rn);
	 	 }
	 	ret=prompt("Please enter: "+rstr);
	 	if(rstr!=ret) return "denied"; 
	 }	
	
	if(chkpw)
	 {
	 	 pw=prompt("Password to decrypt section:");
	 	 if(pw.length==0) return "password needed for decryption. please reload.";
	 }
	site=pw+site; 

	a=site.length;
	if(a>0)
	 {
     while((a%4)!=0) {a++;site=site+"*";}
     b=a>>2;
     for(i=0;i<b;i++)
      pwkey=pwkey+site.charCodeAt(i*4)+0x100*site.charCodeAt(i*4+1)+0x10000*site.charCodeAt(i*4+2)+0x1000000*site.charCodeAt(i*4+3);
	 }
	
	var s=strdecode(str,pwkey);
	
	return s;
}

function domail(str)
  {
  window.open(maildecode(str,''));
  }
  
  
//access a dynamic text display, named tdisp

var deftext;
  
function showtext(text) 
 {
  if(text=="") text=deftext;
  
  if(DHTML && (text!="")) {
   if(NS) setCont("id","tdisp",null,"<span class=\"disp\">" + text + "<\/span>");
   else   setCont("id","tdisp",null,text);
  } 
  else if(DHTML) setCont("id","tdisp",null,"");
 }
 
 
//DHTML Selfhtml code

function getElem(p1,p2,p3) {
 var Elem;
 if(DOM) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.getElementById(p2) == "object")
     Elem = document.getElementById(p2);
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document.getElementsByName(p2) == "object")
     Elem = document.getElementsByName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.getElementsByTagName(p2) == "object" || (OP && typeof document.getElementsByTagName(p2) == "function"))
     Elem = document.getElementsByTagName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(MS) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.all[p2] == "object")
     Elem = document.all[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.all.tags(p2) == "object")
     Elem = document.all.tags(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(NS) {
   if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name") {
   if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="index") {
    if (typeof document.layers[p2] == "object")
     Elem = document.layers[p2];
    else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
}

function getCont(p1,p2,p3) {
   var Cont;
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild) {
     if(getElem(p1,p2,p3).firstChild.nodeType == 3)
       Cont = getElem(p1,p2,p3).firstChild.nodeValue;
     else
       Cont = "";
     return(Cont);
   }
   else if(MS && getElem(p1,p2,p3)) {
     Cont = getElem(p1,p2,p3).innerText;
     return(Cont);
   }
   else return void(0);
}

function getAttr(p1,p2,p3,p4) {
   var Attr;
   if((DOM || MS) && getElem(p1,p2,p3)) {
     Attr = getElem(p1,p2,p3).getAttribute(p4);
     return(Attr);
   }
   else if (NS && getElem(p1,p2)) {
       if (typeof getElem(p1,p2)[p3] == "object")
        Attr=getElem(p1,p2)[p3][p4]
       else
        Attr=getElem(p1,p2)[p4]
         return Attr;
       }
   else return void(0);
}

function setCont(p1,p2,p3,p4) {
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild)
     getElem(p1,p2,p3).firstChild.nodeValue = p4;
   else if(MS && getElem(p1,p2,p3))
     getElem(p1,p2,p3).innerText = p4;
   else if(NS && getElem(p1,p2,p3)) {
     getElem(p1,p2,p3).document.open();
     getElem(p1,p2,p3).document.write(p4);
     getElem(p1,p2,p3).document.close();
   }
}

DHTML_init();