//	Using Multiple JavaScript Onload Functions: http://simonwillison.net/code/js/addloadevent/
	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}


//	Avoid framing
	if(top!=self) top.location=self.location;


//	Layout control
	function resizeCol() {
		if(!document.getElementById || !document.getElementsByTagName) return;
		var w = 0;
		if(!window.innerWidth) {//IE
			if(!(document.documentElement.clientWidth == 0)) w = document.documentElement.clientWidth;//strict mode
			else w = document.body.clientWidth;//quirks mode
		}
		else w = window.innerWidth;//w3c
		//alert(w);
		if(w < 984) {
			document.getElementById("head").className = "page-s";
			document.getElementById("main").className = "page-s";
			document.getElementById("foot").className = "page-s";
		}else {
			document.getElementById("head").className = "page";
			document.getElementById("main").className = "page";
			document.getElementById("foot").className = "page";
		}
	}
	addLoadEvent(resizeCol);
	window.onresize = resizeCol;


//	Fix IE alt-as-tooltip-bug
	function fixTooltip() {
		if(navigator.appName == "Microsoft Internet Explorer") {
			// detect support
			if(!document.getElementById || !document.getElementsByTagName) return;
			var imgs = document.getElementsByTagName("img");
			if(!imgs) return;
			for(var i=0; i<imgs.length; i++) {
				var elImg = imgs[i];
				// if there isn't already a title attribute set on the image, set the title attribute to blank, thus overriding the alt tooltip behaviour
				// use == '' because IE always thinks title is a string (cannot distinguish between undefined and empty attributes)
				if(elImg.getAttribute('title') == '') elImg.setAttribute('title','');
			}
		}
	}
	addLoadEvent(fixTooltip);


//	Manipulate links
	function Links() {
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for(var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			/*anchor.tabindex = i;*/
			if (anchor.getAttribute("href")) {
				anchor.onfocus = function() {
					this.blur();
				}
				if (anchor.getAttribute("rel") == "ext" || anchor.className.search(/link-extern/) != -1 || anchor.className.search(/link-download/) != -1) {
					anchor.target = "_blank";
					if (document.getElementsByTagName("html")[0].lang == "en") {
						if (!anchor.title) anchor.title = "open in new window"
						else anchor.title += " (new window)";
					}else {
						if (!anchor.title) anchor.title = "in neuem Fenster öffnen"
						else anchor.title += " (neues Fenster)";
					}
				}
			}
		}
		var forms = document.getElementsByTagName("form");
		for(var i=0; i<forms.length; i++) {
			var form = forms[i];
			if (form.getAttribute("rel") == "ext") {
				form.target = "_blank";
			}
		}
	}
	addLoadEvent(Links);


//	E-Mail Obfuscation
/*
 *  Written by: Florian Wobbe
 *  Contact: www.eprofs.de
 *  Created: 2008-01-12 - v1.1
 *  Modified: 2008-01-17 - v1.2 - Email encoding
 *  Modified: 2008-01-19 - v1.3 - Custom Base64 encoding
 *  For: MODx cms (modxcms.com)
 *  Name: emo - E-Mail Obfuscation
 *  Description: These javascript functions replace html placeholder span elements with decrypted email addresses.
 *  License: GPL
 */
//	Decrypt all email addresses
	function emo_replace() {
		for (var i = 1; i < emo_addresses.length; i++) {
			var id = '_emoaddrId' + i;
			var elem = document.getElementById(id);
			if (elem) {
				if (elem.firstChild) {
					elem.removeChild(elem.firstChild);
				}
				elem.innerHTML = decrypt_string(i);
			}
		}
	}
//	Manage decryption cache
	var decryption_cache = new Array();
	function decrypt_string(n) {
	  var cache_index = "'"+n+"'";
	
	  if(decryption_cache[cache_index])			// If this string has already been decrypted, just
		return decryption_cache[cache_index];	// return the cached version.
	
	  if(emo_addresses[n])						// Is crypted_string an index into the addresses array?
		var crypted_string = emo_addresses[n];
	
	  if(!crypted_string.length)				// Make sure the string is actually a string
		return "Error, not a valid index.";
	
	  var decrypted_string = decode_base64(crypted_string);
	
	  // Cache this string for any future calls
	  decryption_cache[cache_index] = decrypted_string;
	
	  return decrypted_string;
	}
//	Custom base 64 decoding
	function decode_base64(data) {
	  var tab = emo_addresses[0];
	  var out = "", c1, c2, c3, e1, e2, e3, e4;
	  for (var i = 0; i < data.length; ) {
		e1 = tab.indexOf(data.charAt(i++));
		e2 = tab.indexOf(data.charAt(i++));
		e3 = tab.indexOf(data.charAt(i++));
		e4 = tab.indexOf(data.charAt(i++));
		c1 = (e1 << 2) + (e2 >> 4);
		c2 = ((e2 & 15) << 4) + (e3 >> 2);
		c3 = ((e3 & 3) << 6) + e4;
		out += String.fromCharCode(c1);
		if (e3 != 64)
		  out += String.fromCharCode(c2);
		if (e4 != 64)
		  out += String.fromCharCode(c3);
	  }
	  return out;
	}