$(document).ready(function() {
	$("a.anchorLink").anchorAnimate();
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}

$(document).ready(function() {
	 
	 
	 // $('.arrow_up').hover(function() {
			// $(this).fadeOut(100);$(this).fadeIn(50);
			// });
     
	 
	 var i = 0;
	 
	 // Anzahl der Klassen Projekt
	 var projects = $('.project').length;
	 
	 // Erstes Projekt wird angezeigt
	 $('.project:first').css('display', 'block');
	  if (i == 0) {
	 $('.prev a').css('display', 'none');
	 }
	     else {
			 $('.prev a').css('display', 'block');
		 }
	 
	 // Klick auf Next
	 $('.next a').click(function() {
		 i++;
	 $('.project:lt('+i+')').css('display', 'none');
	 $('.project:eq('+i+')').toggle(50);
	 $('.project:eq('+i+')').fadeIn('fast', function() {
   this.style.removeAttribute('filter');
});

	 $('.project:eq('+i+')').css('display', 'block');
	 	  if (i == projects-1) {
		 $('.next a').css('display', 'none');
	 }
	     else {
		 $('.next a').css('display', 'block');
	 }
	  if (i == 0) {
	 $('.prev a').css('display', 'none');
	 }
	     else {
			 $('.prev a').css('display', 'block');
		 }
	 	 });
		 
	 // Klick auf Prev
	 $('.prev a').click(function() {
		 i--;
	 $('.project:gt('+i+')').css('display', 'none');
	 $('.project:eq('+i+')').toggle(50);
	  $('.project:eq('+i+')').fadeIn('fast', function() {
   this.style.removeAttribute('filter');
});
	 $('.project:eq('+i+')').css('display', 'block'); 
	 	 	  if (i == projects-1) {
		 $('.next a').css('display', 'none');
	 }
	     else {
		 $('.next a').css('display', 'block');
	 }
	  if (i == 0) {
	 $('.prev a').css('display', 'none');
	 }
	     else {
			 $('.prev a').css('display', 'block');
		 }
	 	 });
 
});  
