// CSS Browser Selector   v0.2.3
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
var css_browser_selector = function() {
	var 
		ua = navigator.userAgent.toLowerCase(),
		is = function(t){ return ua.indexOf(t) != -1; },
		h = document.getElementsByTagName('html')[0],
		b = (!(/opera|webtv/i.test(ua)) && /msie (\d)/.test(ua)) ? ((is('mac') ? 'ieMac ' : '') + 'ie ie' + RegExp.$1)
			: is('gecko/') ? 'gecko' : is('opera') ? 'opera' : is('konqueror') ? 'konqueror' : is('applewebkit/') ? 'webkit safari' : is('mozilla/') ? 'gecko' : '',
		os = (is('x11') || is('linux')) ? ' linux' : is('mac') ? ' mac' : is('win') ? ' win' : '';
	var c = b+os+' js';
	h.className += h.className?' '+c:c;
}();

// dom scripting, s. 103
function addLoadEvent(func){
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func()
		}
	}
}

// link zum top nur sichtbar, wenn seite laenger als browserfenster ist
addLoadEvent(topLinksichtbar);

// http://www.maratz.com/blog/archives/2006/05/22/smart-back-to-top-link/
function topLinksichtbar(){
	var viewport_height = (self.innerHeight) ? self.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : (document.body) ? document.body.clientHeight : 0;
	var page_height = document.getElementsByTagName('body')[0].offsetHeight;
	if (!document.getElementById('scrollTop')) return false;
	var scrollTop = document.getElementById('scrollTop');
	if (page_height < viewport_height){
		scrollTop.style.visibility = 'hidden';
	}
}

// macht das suchfeld sichtbar/unsichtbar
document.write("<style type='text/css'>form#searchform {display:none;}</style>");

function anzeigen(element){
	if (!document.getElementById) return false;
	if (!document.getElementById(element)) return false;
	var ele = document.getElementById(element);
	if (ele.style.display != "block"){
		ele.style.display = "block";
	} else {
		ele.style.display = "none";
	}
}

// dom scripting. s.200
function classeAendern(element, wert){
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById(element)) return false;
	var el= document.getElementById(element);
	el.className = wert;
}

