
	function switch_language(lang) {
		var url = document.URL;
		var link = (url.split('?').length==1) ? '?' : '&';
		location.href = url + link + 'lang=' + lang;
	}
	
	function update_checkboxes(val, chk_class) {
		$$('input.' + chk_class).each(function(c) { c.checked = val; });
	}

	function fadeout(id) {
		new Effect.Fade(id, { duration: 2.0, delay: 3.5 });
	}
	
	function save_hint(id) {
		if (id == undefined) id = 'hint';
			
		new Effect.Appear(id, { duration: 0.3 });
		new Effect.Fade(id, { duration: 1.8, delay: 2.5 });
	}
	
	function detail_tab_switch(current) {
		var rel = current.rel;
		if (!$(rel)) rel='all';
		setcookie('detail-tab', rel, 3600*12, '/');
		//update tab display status
		//alle tabs auslesen
		var boxes = $('tabs').getElementsByClassName('sep-tab');

		switch (rel) {
			case 'all':
				for(i=0;i<boxes.length;i++) {
					boxes[i].show();
				}
				var split = $('tabs').getElementsByClassName('nosplit');
				for(i=0;i<split.length;i++) {
					split[i].addClassName('split-small');
					split[i].removeClassName('nosplit');
				}
				
				//$('all-details').show();
				//$('single-detail').innerHTML = '';
				//$('single-detail').hide();
				break;
		
			default:
				//$('all-details').hide();
				//$('single-detail').show();
				//if ($(rel)) $('single-detail').innerHTML=$(rel).innerHTML;
				var split = $('tabs').getElementsByClassName('split-small');
				for(i=0;i<split.length;i++) {
					split[i].addClassName('nosplit');
					split[i].removeClassName('split-small');
				}				

				for(i=0;i<boxes.length;i++) {
					if(boxes[i].id==rel)boxes[i].show();
					else boxes[i].hide();
				}				
				break;
		}
		
		//update link display status
		var links = $$('ul.tabs a');
		for (i=0; i<links.length; i++) { 
			(links[i].rel==rel) ? links[i].addClassName('active') : links[i].removeClassName('active');	
		}
		
		$(current).blur();
	}
	
	function tabClick(current, site) {
		var rel = $(current).rel;
		
		//update link display status
		var links = $$('ul.tabs a');
		for (i=0; i<links.length; i++) { (links[i].rel==rel) ? links[i].addClassName('active') : links[i].removeClassName('active');	}
		
		//update tab display status
		var tabs = $$('div.tabs');
		for (i=0; i<tabs.length; i++) { (tabs[i].id==rel) ? tabs[i].show() : tabs[i].hide();	}
		
		//set cookie
		setcookie('tab-' + site, rel, 3600*2, '/');
		$(current).blur();
	}	
	
	shortcut.add("Shift+Pause",function() {	
		new Effect.Shake('white', { duration: 0.2, distance: 10 });
		$('alien').clonePosition('white', { offsetTop: 20, offsetLeft: 20 }).show();
		new Effect.Move('alien', { x: -210, y: 0, duration: 1.0, mode: 'relative' });
		window.setTimeout('new Effect.Move(\'alien\', { x: 210, y: 0, duration: 1.0, mode: \'relative\' });', 1000);
		window.setTimeout('$(\'alien\').hide();', 2100);
	});
	
	function overfade(hide) {
		ch = document.body.clientHeight;
		oh = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
		mh = (ch>oh) ? ch : oh;
		
		$('body').insert(new Element('div', { 'id': 'blocker' }));
		$('blocker').setStyle({ top: 0, left: 0, width: '100%', height: (mh + 350) + 'px' });
		$('blocker').setOpacity(0.3);
	}
	
	function overlay(w, h, duration) {
		//Einstellungen
		var shadow_padding = 5;
		var border_opacity = 0.5;
		var main_opacity = 0.3;
	
		//Element erzeugen wenn nicht vorhanden
		$('body').insert(new Element('div', { 'id': 'blocker' }));
		$('body').insert(new Element('div', { 'id': 'popup' }));
		$('body').insert(new Element('div', { 'id': 'popup-content' }));
		
		//Blocker für den Hintergrund
		ch = document.body.clientHeight;
		oh = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
		mh = (ch>oh) ? ch : oh;
		
		$('blocker').setStyle({ top: 0, left: 0, width: '100%', height: (mh + 150) + 'px' });
		$('blocker').setOpacity(main_opacity);
		
		increase_size('popup', shadow_padding*2, shadow_padding*2);
		center_element('popup');
		center_element('popup-content');
		
		var p = get_center_position(w + shadow_padding * 2, h + shadow_padding * 2);
		var pc = get_center_position(w, h);

		$('popup').setOpacity(0);
		new Effect.Appear($('popup'), { duration: duration, to: border_opacity });
		new Effect.Morph($('popup'), { style: { width: w + shadow_padding * 2 + 'px', height: h + shadow_padding * 2 + 'px',
			top: p.top + 'px', left: p.left + 'px'}, delay: duration, duration: duration });
		new Effect.Morph($('popup-content'), { style: { width: w + 'px', height: h + 'px',
			top: pc.top + 'px', left: pc.left + 'px'}, delay: duration, duration: duration });
	}	
	
	function hide_overlay() {
		$('popup').remove();
		$('popup-content').remove();
		$('blocker').remove();
	}
	
	function center_element(id) {
		var w = parseInt($(id).getStyle('width'));
		var h = parseInt($(id).getStyle('height'));
		var pos = get_center_position(w, h);
		$(id).setStyle({'top': pos.top + 'px', 'left': pos.left + 'px'});
	}
	
	function increase_size(id, w, h) {
		if (w!=undefined) $(id).setStyle({'width': (parseInt($(id).getStyle('width')) + w) + 'px'});
		if (h!=undefined) $(id).setStyle({'height': (parseInt($(id).getStyle('height')) + h) + 'px'});
	}
	
	function get_center_position(w, h) {
		w = parseInt(w); h = parseInt(h);
	
		wsize = get_window_dimensions();
		var l = (wsize.width-w)/2;
		var t = (wsize.height-h)/2;
		
		return {top: t, left: l};
	}
	
	function get_window_dimensions() {
		var body_width = parseInt(document.body.clientWidth);
		var body_height = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.documentElement.clientHeight);
		
		return {width: body_width, height: body_height};
	}
	
	// Returns anchor from link string
	function getHash() {
		var hash = window.location.hash;
		return hash.substring(1); // remove #
	}
	
	function urlencode(str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // +      input by: Ratheous
    // %          note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
                             
    var hash_map = {}, unicodeStr='', hexEscStr='';
    var ret = (str+'').toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The hash_map is identical to the one in urldecode.
    hash_map["'"]   = '%27';
    hash_map['(']   = '%28';
    hash_map[')']   = '%29';
    hash_map['*']   = '%2A';
    hash_map['~']   = '%7E';
    hash_map['!']   = '%21';
    hash_map['%20'] = '+';
    hash_map['\u00DC'] = '%DC';
    hash_map['\u00FC'] = '%FC';
    hash_map['\u00C4'] = '%D4';
    hash_map['\u00E4'] = '%E4';
    hash_map['\u00D6'] = '%D6';
    hash_map['\u00F6'] = '%F6';
    hash_map['\u00DF'] = '%DF';
    hash_map['\u20AC'] = '%80';
    hash_map['\u0081'] = '%81';
    hash_map['\u201A'] = '%82';
    hash_map['\u0192'] = '%83';
    hash_map['\u201E'] = '%84';
    hash_map['\u2026'] = '%85';
    hash_map['\u2020'] = '%86';
    hash_map['\u2021'] = '%87';
    hash_map['\u02C6'] = '%88';
    hash_map['\u2030'] = '%89';
    hash_map['\u0160'] = '%8A';
    hash_map['\u2039'] = '%8B';
    hash_map['\u0152'] = '%8C';
    hash_map['\u008D'] = '%8D';
    hash_map['\u017D'] = '%8E';
    hash_map['\u008F'] = '%8F';
    hash_map['\u0090'] = '%90';
    hash_map['\u2018'] = '%91';
    hash_map['\u2019'] = '%92';
    hash_map['\u201C'] = '%93';
    hash_map['\u201D'] = '%94';
    hash_map['\u2022'] = '%95';
    hash_map['\u2013'] = '%96';
    hash_map['\u2014'] = '%97';
    hash_map['\u02DC'] = '%98';
    hash_map['\u2122'] = '%99';
    hash_map['\u0161'] = '%9A';
    hash_map['\u203A'] = '%9B';
    hash_map['\u0153'] = '%9C';
    hash_map['\u009D'] = '%9D';
    hash_map['\u017E'] = '%9E';
    hash_map['\u0178'] = '%9F';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
 
    for (unicodeStr in hash_map) {
        hexEscStr = hash_map[unicodeStr];
        ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
	}
	
	function checkAll(id, checked) {
		$$('#' + id + ' input').each(function(c) { 
			c.checked = checked;
		});
	}