$(document).ready(function() {

	/*
	Funktionen zum animierten Scrollen an Links mit Anker als Ziel binden
	*/
	var scrollSpeed = 1000;
	$('a[href*=#]').bind("click",
		function (event) {
			href = $(this).attr("href").split("#");
			if(href[1] != ""){
				ziel = "";
				if ($("#" + href[1]).length > 0) {
					ziel = "#" + href[1];
				}else if($("a[name=" + href[1] + "]").length > 0){
					ziel = "a[name=" + href[1] + "]";
				}
				if(ziel){
					event.preventDefault();
					target = ($.browser.opera) ? 'html' : 'html,body';
					offsetTop = (!$.browser.msie) ? $(ziel).offset().top - 11 : $(ziel).offset().top;
					$(target).animate({ scrollTop: offsetTop}, scrollSpeed, function () { location.hash = href[1]; });
				}
			}else{
				this.blur();
			}
		}
	);

	/*
	Menu-Funktionen
	*/
	// Auf- und zuklapp-Aktionen zuweisen
	$("ul.f-m li").hover(
		function () {
			// Submenu beim Hover des Elternelementes aufklappen
			$(this).find("ul").stop(true, true).slideDown('fast').show(); 
		},
		function () {
			// Submenu beim Mouseout des Elternelementes zuklappen
			$(this).parent().find("ul").slideUp('fast');
		}
	);

	/*
	Scripts für ImageSlider
	*/
	$('.imageSlider').imageSlider({
		width: 247,
		height: 144, 
		resizeContents: true, 
		startStopped: false,  
		toggleArrows: true,
		startText: "&nbsp;",
		stopText: "&nbsp;",
		delay: 3000, /*war 10000*/
		navigationFormatter : function(index, panel){ // Format navigation labels with text
			return index;
		}
	});

	/*
	Funktion zum Einblenden von Tooltips
	*/
	var xOffset = -10; // x distance from mouse
	var yOffset = 15; // y distance from mouse
	if($.browser.version == "7.0" && $.browser.msie == true)
		yOffset += 25;
	var vtip;
	$("area").unbind().hover(    
		function(e) {			
			e.preventDefault();
			id = $(this).attr("id");
			this.altStore = $(this).attr("alt");
			$(this).attr("alt", "");
			vtip = $("#" + id + "_content");         
         			vtip.stop(true, true).css("top", this.top+"px").css("left", this.left+"px").fadeIn("fast");
		},
		function() {
			vtip.fadeOut("fast");
			$(this).attr("alt", this.altStore);
			this.altStore = "";

		}
	).mousemove(
		function(e) {
			if(vtip){
				xO = xOffset - $("#zusatzdiv").offset().left;
				yO = yOffset - $("#zusatzdiv").offset().top;
				this.top = (e.pageY + yO);
				this.left = (e.pageX + xO);                         
				vtip.css("top", this.top+"px").css("left", this.left+"px");
			}
		}
   	);
	
	/*
	Verhindert Anzeige von Alt-Tags im IE < 8
	*/
	$("img").hover(
		function(e){
			this.altStore = $(this).attr("alt");
			$(this).attr("alt", "");
		},
		function(e){		
			$(this).attr("alt", this.altStore);
			this.altStore = "";
		}
	);

		return false;
});
