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


$(document).ready(function(){
	$.easing.bouncy = function (x, t, b, c, d) {
	    var s = 1.70158;
	    if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	    return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	}
	
	// create custom tooltip effect for jQuery Tooltip
	$.tools.tooltip.addEffect("bouncy",
	
		// opening animation
		function(done) {
			this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show();
		},
	
		// closing animation
		function(done) {
			this.getTip().animate({top: '-=15'}, 500, 'bouncy', function()  {
				$(this).hide();
				done.call();
			});
		}
	);
});



// Scroll-Funktionen für Browserfenster
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
		}, 400 , function (){location.hash = ziel;});
   	});
	return false;
});




// RollOver-Effekt für Top4Menü
$(document).ready(function() {
	
	$("#top4Menu li").prepend("<span></span>"); //Throws an empty span tag right before the a tag
	
	$("#top4Menu li").each(function() { //For each list item...
		var linkText = $(this).find("a").html(); //Find the text inside of the a tag
		$(this).find("span").show().html(linkText); //Add the text in the span tag
	}); 
	
	$("#top4Menu li").hover(function() {	//On hover...
		$(this).find("span").stop().animate({ 
			marginTop: "-73" //Find the span tag and move it up 73 pixels
		}, 250);
	} , function() { //On hover out...
		$(this).find("span").stop().animate({
			marginTop: "0" //Move the span back to its original state (0px)
		}, 250);
	});
	
});







// HOVER - FOCUS - ACTIVE Funktion für IE
function suckerfish(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}
sfHover = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" hover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" hover\\b"), "");
		}
	}
}
sfFocus = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onfocus=function() {
			this.className+=" focus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" focus\\b"), "");
		}
	}
}
sfActive = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmousedown=function() {
			this.className+=" active";
		}
		sfEls[i].onmouseup=function() {
			this.className=this.className.replace(new RegExp(" active\\b"), "");
		}
	}
}
sfTarget = function(sfEls) {
	var aEls = document.getElementsByTagName("A");
	document.lastTarget = null;
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].id) {
			if (location.hash==("#" + sfEls[i].id)) {
				sfEls[i].className+=" sftarget";
				document.lastTarget=sfEls[i];
			}
			for (var j=0; j<aEls.length; j++) {
				if (aEls[j].hash==("#" + sfEls[i].id)) aEls[j].targetEl = sfEls[i];
				aEls[j].onclick = function() {
					if (document.lastTarget) docu.lastTarget.className = document.lastTarget.className.replace(new RegExp(" sftarget\\b"), "");
					if (this.targetEl) this.targetEl.className+=" target";
					document.lastTarget=this.targetEl;
					return true;
				}
			}
		}
	}
}



