
	function switch_language(lang) {
		var url = document.URL;
		var link = (url.split('?').length==1) ? '?' : '&';
		location.href = url + link + 'lang=' + lang;
	}
	
	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
		switch (rel) {
			case 'all':
				$('all-details').show();
				$('single-detail').innerHTML = '';
				$('single-detail').hide();
				break;
		
			default:
				$('all-details').hide();
				$('single-detail').show();
				if ($(rel)) $('single-detail').innerHTML=$(rel).innerHTML;
				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 show_adapterlist(searchstring, start, limit) {
		$("loader").show();
		$("adapterlist").hide();
		filter = $("filter2").value;
		var pars = '&searchstring=' + searchstring + '&start=' + start + '&limit=' + limit+ '&filter=' + filter;
		//alert(pars);
		var ajax = new Ajax.Request('/tpl/products/ajax_adapterlist.php', {method: 'post', parameters: pars, 
				onComplete: function(showResult) { 
				$("loader").hide();
				$("adapterlist").innerHTML=showResult.responseText;
				$("adapterlist").show();
				eval("initLightbox()");
			}
		});
	}	
	
	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 #
	}
