

$(window).load(function () {
    if ( $('#intro_bild').length != 0 )
    {
	setTimeout("fadeOutAndRedirect();",1000);
    }
});


function fadeOutAndRedirect ()
{

    $('#intro_bild').fadeOut('slow', function() {
	window.location='/startseite';
    });


}

$(document).ready(function(){

    //if on hp
    if ($('#intro').length != 0)
    {
	//	$('#index').css('display', 'none');
	$('#navigation').css('display', 'none');
	$('#logo').css('display', 'none');
	$('#header').css('display', 'none');
	$('#fruehlings_staffel').css('display', 'none');
    }

    for (var i=1; i<=8; i++)
    {
	$('#index_nav_0'+i).addClass('mouseout');
	$('#index_nav_0'+i).mouseenter(function(){
	    var id_str = this.id.substr(this.id.lastIndexOf('_'));
	    //change background pos on $('#index_'+this.id)
	    $('#nav'+ id_str).addClass('btn_mouseover');
	    $('#nav'+ id_str).removeClass('btn_mouseout');

	},function(){


	    });

	$('#index_nav_0'+i).mouseleave(function(){
	    var id_str = this.id.substr(this.id.lastIndexOf('_'));
	    //change background pos on $('#index_'+this.id)
	    $('#nav'+ id_str).removeClass('btn_mouseover');
	    $('#nav'+ id_str).addClass('btn_mouseout');

	},function(){


	    });
    }


    $('a.nav').mouseenter(function(){
	//change background pos on $('#index_'+this.id)
	$('#index_'+ this.id).addClass('mouseover');
	$('#index_'+ this.id).removeClass('mouseout');
	
    },function(){
		
		
	});

    $('a.nav').mouseleave(function(){
	//change background pos on $('#index_'+this.id)
	$('#index_'+ this.id).removeClass('mouseover');
	$('#index_'+ this.id).addClass('mouseout');

    },function(){


	});


    $('.scroll_btn_short_down').click(function(){
	scrollDown(this);
    });
    $('.scroll_btn_short_up').click(function(){
	scrollUp(this);
    });


    $('.scroll_btn_down').click(function(){
	scrollDown(this);
    });
    $('.scroll_btn_up').click(function(){
	scrollUp(this);
    });


    $('.scroll_btn_long_down').click(function(){
	scrollDown(this);
    });
    $('.scroll_btn_long_up').click(function(){
	scrollUp(this);
    });

    function scrollUp( obj )
    {
	var id = obj.id.substring(obj.id.lastIndexOf('_')+1);
	$('#scroller_'+id).scrollTo({top:'-=100px', left:'0'}, 800);
    }
    function scrollDown( obj )
    {
	var id = obj.id.substring(obj.id.lastIndexOf('_')+1);
	$('#scroller_'+id).scrollTo({top:'+=100px', left:'0'}, 800);
    }

    $('#next_pic').click(function(){
	nextPic();
    });

    $('.gal_pic').click(function(){
	nextPic();
    });

    function nextPic()
    {
	$('.gal_pic').each(
	    function(index){
		//is current visible pic
		if ( $(this).hasClass('invisible') == false ){
		    if ($(this).next().length == 0)
		    {
			$('.gal_pic').first().removeClass('invisible');
		    }
		    else
		    {
			$(this).next().removeClass('invisible');
		    }
		    $(this).addClass('invisible');
		    //leave
		    return false;

		}
	    });
    }

    $('#prev_pic').click(function(){
	$('.gal_pic').each(
	    function(index){
		//is current visible pic
		if ( $(this).hasClass('invisible') == false ){
		    if ($(this).prev().length == 0 || $(this).prev().attr('id') == 'next_pic')
		    {
			$('.gal_pic').last().removeClass('invisible');
		    }
		    else
		    {
			$(this).prev().removeClass('invisible');
		    }
		    $(this).addClass('invisible');
		    //leave
		    return false;

		}
	    });
    });




//	$('a.nav').hover(function(){
//
//		$(this).stop().animate({
//			backgroundColor: '#ffbe00'
//		},200);
//
//		$('#index_'+this.id).stop().animate({
//			opacity:0
//		},200);
//
//
//	},function(){
//
//		$(this).stop().animate({
//			backgroundColor: '#9f9f9f'
//		},400);
//
//		$('#index_'+this.id).stop().animate({
//			opacity:1
//		},400);
//
//	});
	
//	$('#index img').hover(function(){
//
//		var call = this.id;
//		var call2= '#'+call.substr(6,6);
//
//		$(call2).stop().animate({
//			backgroundColor: '#ffbe00'
//		},400);
//
//		$(this).stop().animate({
//			opacity: 0
//		},400);
//
//	},function(){
//
//		var call = this.id;
//		var call2= '#'+call.substr(6,6);
//
//		$(call2).stop().animate({
//			backgroundColor: '#9f9f9f'
//		},400);
//
//		$(this).stop().animate({
//			opacity: 1
//		},400);
//
//	});
	
	
//	$('div.gradient img').hover(function(){
//	    alert('äää');
//		$(this).stop().animate({
//			opacity:1},400);
//	},function(){
//		$(this).stop().animate({
//			opacity:0.3},400);
//	})
//
//	$('div.fade').innerfade({
//		animationtype: 'fade',
//		speed: 1000,
//		timeout:4000,
//		type: 'sequence',
//		containerheight: '420px',
//		runningclass: 'fade'
//	});
	
});
