$(document).ready(function() {
		xOffset = 35;
		yOffset = 25;		
	$("a.tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id=\"tooltip\">"+ this.t +"</p>");
		$("#tooltip").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip").mousemove(function(e){
		$("#tooltip").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px");
	});	
	
	// select #flowplanes and make it scrollable. use circular and navigator plugins
	$("#flow_content").scrollable({
			circular: true
		}).navigator({
			navi: "#flow_navigator",
			naviItem: 'a',
			activeClass: 'current'
		}).autoscroll({
			interval: 10000,
			steps: -1
		});
	
	$('a[href=#top]').click(function() {
		if ($(this).attr('href')=='#top')
		{
			if ($.browser.opera) {
				var target = 'html';
			}
			else {
				var target = 'html,body';
			}
			$(target).animate({
				scrollTop: 0
			}, 500 );
		return false;
		}
		else if ($(this).attr('href')=='#back')
		{
			$('#body').slideUp('slow', function(){
				$('#intro').toggle();
				$('#flow').toggle();
				$('#content').toggle();
				$('.fadein').fadeOut('normal',$('.fadein').detach());
				if (slide){
					clearInterval(slideshow);
				}
				$('#footer_zipfel a').css('background-image', 'url(zipfel_unten.png)').attr({title: 'nach oben', href: '#top'});
				$(this).slideDown();
			});
		}
	});
	
	
	if (typeof slideshow_imgs != 'undefined')
	{
		var fadein = '<div class="fadein">';
		for (var i = 0; i < slideshow_imgs.length; i++) 
		{
			add = '<img src="' + slideshow_imgs[i] + '">'
			fadein += add
		}
		fadein += '</div>'
		var slide = false;
		
		$('#intro_img img').click(function(){
			$('#body').slideUp('slow', function(){
				$(fadein).appendTo('#body');				
				$('.fadein img:gt(0)').hide();
				slide = true;
				slideshow = setInterval(function(){
				  $('.fadein :first-child').fadeOut('slow')
					 .next('img').fadeIn('slow')
					 .end().appendTo('.fadein');}, 
					  3000);
				$('#footer_zipfel a').css('background-image', 'url(zipfel_unten_dia.png)').attr({title: 'zurück', href: '#back'});
				$(this).slideDown()
				$('.fadein').click(function(){
					if (slide){
						clearInterval(slideshow);
					}
					$('.fadein :first-child').fadeOut('slow')
						 .next('img').fadeIn('slow')
						 .end().appendTo('.fadein')
				});
			});
			$('#intro').fadeOut();
			$('#flow').fadeOut();	
			$('#content').fadeOut();
		});
	
		$('#intro_img img').hover(
			function(){
				$(this).animate({opacity: 0.25});
			},
			function(){
				$(this).animate({opacity: 1});
		});
	}
		$('#menu ul#menu_1_ul li.menu_1_li').hover(
		function(){
			$('ul', this).slideDown();
		},
		function() {
			$('ul', this).slideUp();
	});
});
