function mail(email) { 
	var email2 = email.split('*AT*').join('@');
	document.location.href = "mailto:" + email2; 
}





function initScroll(){
	_nav = document.getElementById('menu');
	_scrolltimer = null;
	_scrolling = false;
	if (document.all) {
		if (document.documentElement && document.documentElement.clientHeight) {
			var doc = document.documentElement;
		} else {
			var doc = document.body;
		}
	} else {
		var doc = document;
	}
	doc.onscroll = startScroll;
	window.onresize = startScroll;
}
function resetScroll(){
	stopScroll();
	_nav.style.top = '0px';
	window.scrollTo(0,0);
}
function startScroll(){
	if ( ! _scrolling) {
		_scrolling = true;
		doScroll();
	}
}
function stopScroll(){
	_scrolling = false;	
	clearTimeout(_scrolltimer);
}
function doScroll(){
	if (document.documentElement && document.documentElement.clientHeight) {
		var windowHeight = document.documentElement.clientHeight;
	} else if (document.body && document.body.clientHeight) {
		var windowHeight = document.body.clientHeight;
	} else {
		var windowHeight = window.innerHeight;
    }
	if (window.pageYOffset) {
		var scrollTop = window.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		var scrollTop = document.documentElement.scrollTop;
	} else if (document.body && document.body.scrollTop) {
		var scrollTop = document.body.scrollTop;
	} else {
		scrollTop = 0;
	}
	if (windowHeight >= 550) {
		var yCurrent = parseInt(_nav.style.top) || 0;
		
		if (yCurrent >= 0) {
			// 160
			var yTarget = scrollTop;
		} else {
			// 160
			var yTarget = 0;
		}
		
		var y = yCurrent + (yTarget - yCurrent) / 2;
		_nav.style.top = y + 'px';
		if (Math.abs(yTarget - y) <= 2) {
			stopScroll();
			_nav.style.top = yTarget + 'px';
		} else {
			_scrolltimer = setTimeout('doScroll()', 50);
		}
	} else {
		stopScroll();
		_nav.style.top = '0px'; // 160px
	}
}

$(document).ready(function(){
	initScroll();
	
	// Alle internen Links auswählen
	$('a[href*=#]').bind("click", function(event) {
		// Standard Verhalten unterdrücken
		event.preventDefault();
		// Linkziel in Variable schreiben
		var ziel = $(this).attr("href");
		//Browserweiche
		if ($.browser.opera) {
                //Wenn Browser Opera
				var target = 'html';
            }else{
				//Wenn der Browser NICHT Opera
                var target = 'html,body';
            }
		//Scrollen der Seite animieren, body benötigt für Safari
		//Variable für Browserweiche
		//$('html,body').animate({
		$(target).animate({
			//Zum Ziel scrollen (Variable)
			scrollTop: $(ziel).offset().top
		// Dauer der Animation und Callbackfunktion die nach der Animation aufgerufen wird, sie stellt das Standardverhalten wieder her und ergänzt die URL
		}, 700 , function (){location.hash = ziel;});
   	});
	return false;
});







sfFocus = function(elementX) {
	var sfEls1 = document.getElementsByTagName("INPUT");
	for (var i=0; i<sfEls1.length; i++) {
		sfEls1[i].onfocus=function() {
			this.className+=" focus";
		}
		sfEls1[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" focus\\b"), "");
		}
	}
	
	var sfEls2 = document.getElementsByTagName("TEXTAREA");
	for (var i=0; i<sfEls2.length; i++) {
		sfEls2[i].onfocus=function() {
			this.className+=" focus";
		}
		sfEls2[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" focus\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfFocus);

