function emails() {
	for (var i=0; i<madr.length; i++) {
		var xadr = new Array();
		for (var j=0; j<madr[i].length/2; j++) xadr[j] = "0";
		window.setTimeout("decode('"+madr[i]+"','"+xadr.join(",")+"',"+i+","+xadr.length+")",100+Math.ceil(Math.sqrt(i+1)*900));
	}
	bilder_preload();
	//alert("Start?");
}

function decode(muster, tab, nr, len) {
	var hex, codepos, test;
	var out = "";
	var erg = tab.split(",");
	var pos = Math.floor(Math.random()*len);
	while (erg[pos]==1) { pos++; if (pos>erg.length) alert("Prob"); }
	if (len==erg.length) {
		document.getElementById("mail"+nr).style.backgroundColor="#ffff99";
		document.getElementById("mail"+nr).title = "decoding in process";
	}
	for (var i=0; i<erg.length; i++) {
		if (i==pos) { erg[i] = 1; len--; }
		codepos = -1;
		if (erg[i]==1) { if (i<Math.floor(erg.length/2)) codepos = 2*i+2*Math.ceil(erg.length/2)+1; else codepos = 2*i + 2*Math.floor(erg.length/2) - 2*erg.length + 1; }
		if (codepos<1) codepos = 2*i + 1;
		hex = muster.charAt(i*2) + muster.charAt(codepos);
		test = unescape("%"+hex);
		if (test.charCodeAt(0)>34 && test.charCodeAt(0)<127) out += "%"+hex; else out += "!"+hex;
	}
	document.getElementById("mail"+nr).firstChild.nodeValue = unescape(out);
	document.getElementById("mail"+nr).href = "mailto:"+unescape(out);
	if (len>0) window.setTimeout("decode('"+muster+"','"+erg.join(",")+"',"+nr+","+len+")",60+Math.ceil(Math.random()*70));
	else { 
		document.getElementById("mail"+nr).title = "Email is spy-protected";
		document.getElementById("mail"+nr).removeAttribute("style");
	}
}

function sendmailto(adr) {
	var sendto = "mai" + "lto" + ":" + adr + "@ef" + "a2005." + "org";
	window.location.href = sendto;
}

function gallery() {
	var leftpos = 150;
	var winwidth = 520;
	var winheight = 580;
	resiz = (navigator.appName=="Netscape") ? 0 : 1;
	Fg = window.open("gallery/index.php", "printversion","width="+winwidth+",height="+winheight+",top=140,left="+leftpos+",directories=no,location=no,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=yes,resizable="+resiz+"");
	window.Fg.focus();
}
	
function NewWin(p,w,h) {
	if (w) { leftpos = (screen.availWidth-w)/2; winwidth = w; winheight = h; }
	else {
		var leftpos = 130;
		var rightpos = screen.availWidth - 140;
		var winwidth = rightpos - leftpos;
		var winheight = screen.availHeight - 240;
	}
	resiz = (navigator.appName=="Netscape") ? 0 : 1;
	Fp = window.open(p, "printversion","width="+winwidth+",height="+winheight+",top=140,left="+leftpos+",directories=no,location=no,menubar=no,scrollbars=yes,status=no,titlebar=no,toolbar=yes,resizable="+resiz+"");
	window.Fp.focus();
}

function bilder_preload() {
	if (document.images) {
		bilder = new Array;
		bilder["webmaster"] = "webmaster2.gif";
		bilder["edt"] = "edt2.gif";
		bilder["profile"] = "profile2.gif";
		bilder["logout"] = "logout2.gif";
		bild_alt = new Image();
	  bild_alt_name = new String();
	  bild = new Array();
	  for (var bild_x in bilder) {
	  	bild[bild_x] = new Image();
	  	bild[bild_x].src = "pictures/"+bilder[bild_x];
	  }
	}
}

function einschalten(bild_x) {
	if (document.images) {
		bild_alt.src = document[bild_x].src;
		bild_alt_name = bild_x;
  	document[bild_x].src = bild[bild_x].src;
	}
}

function abschalten() { if (document.images) document[bild_alt_name].src = bild_alt.src; }

function bild_oeffnen(adr,nr,w,h) {
	var x = 20;
	var w = w + x;
	var h = h + x;
	F = window.open(adr,"picture"+nr,"width="+w+",height="+h+",left=0,top=0");
	window.F.focus();
}

function stoptime() { clearTimeout(mtimer); }

function akt(menu_id) { if (menu_id!=aktiviert) mtimer = setTimeout("show('"+menu_id+"')",500); }

function show(menu_id) {
	stoptime();
	if (menu_id==aktiviert) {
		document.getElementById(menu_id).removeChild(document.getElementById(menu_id).getElementsByTagName("div")[0]);
		if (aktiviert==aktuell) document.getElementById(aktiviert).appendChild(ersatz);
		aktiviert = "";
	} else {
		if (aktiviert) {
			document.getElementById(aktiviert).removeChild(document.getElementById(aktiviert).getElementsByTagName("div")[0]);
			if (aktiviert==aktuell) document.getElementById(aktiviert).appendChild(ersatz);
		}
		if (menu_id==aktuell) document.getElementById(menu_id).removeChild(document.getElementById(menu_id).getElementsByTagName("div")[0]);
		document.getElementById(menu_id).appendChild(upunkte[menu_id]);
		aktiviert = menu_id;
	}
}

function mark(typ,key) {
	with(document.getElementsByName(typ)[0]) {
		if (key) {
			value=key;
			focus();
			select();
		} else value="No key!";
	}
}

function zeig(id) {
	Knoten = document.getElementById(opty);
	document.getElementById("tab").removeChild(Knoten);
	document.getElementById("tab").appendChild(optx[id]);
	opty = id;
	document.cookie = "opty=" + id;
}

function save_path(link) {
	var ablauf = new Date();
	var zeit = ablauf.getTime() + (5 * 60 * 1000);
	ablauf.setTime(zeit);
	if (document.cookie && navigator.cookieEnabled) document.cookie = "descent=" + window.location.href + "; expires=" + ablauf.toGMTString();
	top.location.href = link;
}

