var CryptEmailDomain = new String();
var CryptEmailInterval = 0; // 250  für wechselnde Email-Anzeige; Angabe in ms <
var CryptEmailIntervalAktiv = 0;
var CryptEmailAutoRefresh = 25; // 250 für automatische aktivierung der email-Anzeige
var CryptEmailAutoRefreshAktiv = 0;
var CryptEmailHTMLText = 'Email senden';
var CryptEmailTitleText = 'Email senden an ';
var CryptEmailKey = Math.floor(Math.random() * 255) + 1;
var CryptEmailComment = new Array('<!-- >@ -->', '<!-- @.@ -->', '<!-- @ -->',
		'<!-- &#64; -->', '<!-- peter.meier@yahoo.de -->',
		'<!-- bill.gates@microsoft.com -->',
		'<!-- anita.kummermann@gmx.net -->',
		'<span style="display:none">peter.meier@yahoo.de</span>',
		'<span style="display:none">bill.gates@microsoft.com</span>',
		'<span style="display:none">anita.kummermann@gmx.net</span>');

/* DHTML-Bibliothek */
var DHTML = false, DOM = false, MSIE4 = false, NS4 = false, OP = false;
if (document.getElementById) {
	DHTML = true;
	DOM = true;
} else {
	if (document.all) {
		DHTML = true;
		MSIE4 = true;
	} else {
		if (document.layers) {
			DHTML = true;
			NS4 = true;
		}
	}
}
if (window.opera) {
	OP = true;
}

function getElement(Mode, Identifier, ElementNumber) {
	var Element, ElementList;
	if (DOM) {
		if (Mode.toLowerCase() == "id") {
			Element = document.getElementById(Identifier);
			if (!Element) {
				Element = false;
			}
			return Element;
		}
		if (Mode.toLowerCase() == "name") {
			ElementList = document.getElementsByName(Identifier);
			Element = ElementList[ElementNumber];
			if (!Element) {
				Element = false;
			}
			return Element;
		}
		if (Mode.toLowerCase() == "tagname") {
			ElementList = document.getElementsByTagName(Identifier);
			Element = ElementList[ElementNumber];
			if (!Element) {
				Element = false;
			}
			return Element;
		}
		return false;
	}
	if (MSIE4) {
		if (Mode.toLowerCase() == "id" || Mode.toLowerCase() == "name") {
			Element = document.all(Identifier);
			if (!Element) {
				Element = false;
			}
			return Element;
		}
		if (Mode.toLowerCase() == "tagname") {
			ElementList = document.all.tags(Identifier);
			Element = ElementList[ElementNumber];
			if (!Element) {
				Element = false;
			}
			return Element;
		}
		return false;
	}
	if (NS4) {
		if (Mode.toLowerCase() == "id" || Mode.toLowerCase() == "name") {
			Element = document[Identifier];
			if (!Element) {
				Element = document.anchors[Identifier];
			}
			if (!Element) {
				Element = false;
			}
			return Element;
		}
		if (Mode.toLowerCase() == "layerindex") {
			Element = document.layers[Identifier];
			if (!Element) {
				Element = false;
			}
			return Element;
		}
		return false;
	}
	return false;
}

function getAttribute(Mode, Identifier, ElementNumber, AttributeName) {
	var Attribute;
	var Element = getElement(Mode, Identifier, ElementNumber);
	if (!Element) {
		return false;
	}
	if (DOM || MSIE4) {
		Attribute = Element.getAttribute(AttributeName);
		return Attribute;
	}
	if (NS4) {
		Attribute = Element[AttributeName]
		if (!Attribute) {
			Attribute = false;
		}
		return Attribute;
	}
	return false;
}

function getContent(Mode, Identifier, ElementNumber) {
	var Content;
	var Element = getElement(Mode, Identifier, ElementNumber);
	if (!Element) {
		return false;
	}
	if (DOM && Element.firstChild) {
		if (Element.firstChild.nodeType == 3) {
			Content = Element.firstChild.nodeValue;
		} else {
			Content = "";
		}
		return Content;
	}
	if (MSIE4) {
		Content = Element.innerText;
		return Content;
	}
	return false;
}

function setContent(Mode, Identifier, ElementNumber, Text) {
	var Element = getElement(Mode, Identifier, ElementNumber);
	if (!Element) {
		return false;
	}
	if (DOM && Element.firstChild) {
		Element.firstChild.nodeValue = Text;
		return true;
	}
	if (MSIE4) {
		Element.innerText = Text;
		return true;
	}
	if (NS4) {
		Element.document.open();
		Element.document.write(Text);
		Element.document.close();
		return true;
	}
}
/* EOF DHTML-Bibliothek */

function CryptEmail(EmailAccount) {
	var x = new Array;
	for ( var i = 0; i < EmailAccount.length; i++) {
		x[i] = EmailAccount.charCodeAt(i) ^ CryptEmailKey;
	}
	var CryptEmailAccount = x.join(',');
	var a = document.createElement('a');
	with (a) {
		setAttribute('onmouseover', 'CryptEmailTimeOut()', 0);
		setAttribute('onfocus', 'CryptEmailTimeOut()', 0);
		setAttribute('CryptEmailAccount', CryptEmailAccount, 0);
		setAttribute('CrpytEmailFlash', '0', 0);
		innerHTML = CryptEmailHTMLText;
	}

	document.write('<CryptEmailHook></CryptEmailHook>');
	// var b = document.getElementsByTagName('CryptEmailHook')[0];
	// var c = b.appendChild(a).parentNode.previousSibling;
	// c.parentNode.replaceChild(a , c);
	// b.parentNode.removeChild(b);

	var b = getElement('tagname', 'CryptEmailHook', '0');
	var c = b.parentNode.appendChild(a);
	c.parentNode.removeChild(b);
	c.parentNode.removeChild(c.previousSibling);

	if (CryptEmailInterval > 0) {
		CryptEmailIntervalAktiv = window.setInterval('CryptEmailTimeOut()', CryptEmailInterval);
		CryptEmailInterval = CryptEmailInterval * -1;
	}
	if (CryptEmailAutoRefresh > 0) {
		CryptEmailAutoRefreshAktiv = window.setTimeout('CryptEmailTimeOut()', CryptEmailAutoRefresh);
		CryptEmailAutoRefresh = CryptEmailAutoRefresh * -1;
	}
}

function CryptEmailTimeOut() {
	if (CryptEmailDomain.length == 0) {
		var CryptEmailDomain_c = new Array('s', 'h', 'c', 'u', 'Y', 'l', 'f',
				'e', 'a', '.');
		var CryptEmailDomain_n = new Array('0', '2', '1', '3', '5', '7', '6',
				'5', '8', '8', '2', '1', '9', '2', '1');
		for ( var i = 0; i < CryptEmailDomain_n.length; i++) {
			CryptEmailDomain = CryptEmailDomain
					+ CryptEmailDomain_c[CryptEmailDomain_n[i]];
		}
	}
	for ( var i = 0; i < document.getElementsByTagName('a').length; i++) {
		//        with (document.getElementsByTagName('a')[i]) {
		with (getElement('tagname', 'a', i)) {
			switch (getAttribute('CrpytEmailFlash')) {
			case '0':
				href = 'javascript:CryptEmailTo(' + i + ')';
				removeAttribute('onmouseover'); // unregister der funktion funktioniert in opera nicht
				onmouseover = null;
				removeAttribute('onfocus');  // unregister der funktion funktioniert in opera nicht
				onfocus = null;
				setAttribute('id', 'CryptEmailId' + i, 0);
				setAttribute('CrpytEmailFlash', '1', 0);
				var CryptEmailAccount = CryptEmailDecode(getAttribute('CryptEmailAccount'));
				innerHTML = CryptEmailAccount
						+ CryptEmailComment[Math.floor(Math.random()
								* (CryptEmailComment.length - 1))]
						+ '&#'
						+ (2 * 2 * 2 * 2 * 4)
						+ CryptEmailComment[Math.floor(Math.random()
								* (CryptEmailComment.length - 1))]
						+ CryptEmailDomain;
				title = CryptEmailTitleText 
						+ CryptEmailAccount 
						+ '@'
						+ CryptEmailDomain;
				break;
			case '1':
				setAttribute('CrpytEmailFlash', '2', 0);
/*				innerHTML = CryptEmailDecode(getAttribute('CryptEmailAccount'))
						+ CryptEmailComment[Math.floor(Math.random()
								* (CryptEmailComment.length - 1))]
						+ String.fromCharCode(4 * 4 * 4)
						+ CryptEmailComment[Math.floor(Math.random()
								* (CryptEmailComment.length - 1))]
						+ CryptEmailDomain; */
				innerHTML = CryptEmailHTMLText;
						
				break;
			case '2':
				setAttribute('CrpytEmailFlash', '1', 0);
				innerHTML = CryptEmailDecode(getAttribute('CryptEmailAccount'))
						+ CryptEmailComment[Math.floor(Math.random()
								* (CryptEmailComment.length - 1))]
						+ '&#'
						+ (4 * 2 * 4 * 2)
						+ CryptEmailComment[Math.floor(Math.random()
								* (CryptEmailComment.length - 1))]
						+ CryptEmailDomain;
				break;
			default:
				break;
			}
		}
	}
	if (CryptEmailInterval < 0) {
//		window.clearInterval(CryptEmailIntervalAktiv);
	} 
	if (CryptEmailAutoRefresh < 0) {
		window.clearTimeout(CryptEmailAutoRefreshAktiv);	 
	}
}

function CryptEmailTo(Identifier) {
	var CryptEmailMailTo = new String();
	var CryptEmailMailTo_c = new Array('i', 'm', 't', 'l', 'o', ':', 'a');
	var CryptEmailMailTo_n = new Array('1', '6', '0', '3', '2', '4', '5');
	for ( var i = 0; i < CryptEmailMailTo_n.length; i++) {
		CryptEmailMailTo = CryptEmailMailTo
				+ CryptEmailMailTo_c[CryptEmailMailTo_n[i]];
	}
	// alert(CryptEmailMailTo + CryptEmailDecode(document.getElementById('CryptEmailId' + Identifier).getAttribute('CryptEmailAccount')) + String.fromCharCode(64) + CryptEmailDomain)
	// location.href=CryptEmailMailTo +
	// CryptEmailDecode(document.getElementById('CryptEmailId' +
	// Identifier).getAttribute('CryptEmailAccount')) +
	// String.fromCharCode(2*2*4*2*2) + CryptEmailDomain;
	location.href = CryptEmailMailTo
			+ CryptEmailDecode(getElement('id', 'CryptEmailId' + Identifier)
					.getAttribute('CryptEmailAccount'))
			+ String.fromCharCode(2 * 2 * 4 * 2 * 2) + CryptEmailDomain;
	delete CryptEmailMailTo;
}

function CryptEmailDecode(CodedText) {
	var x = CodedText.split(',');
	var Decoded = new String();
	for ( var i = 0; i < x.length; i++) {
		Decoded = Decoded + (String.fromCharCode(x[i] ^ CryptEmailKey))
	}
	return Decoded;
}