$(document).ready(function(){

	var interval_time = 5000;
	var fade_time = 3000;
	
	$("#image_animation img").hide();
	$("#image_animation img:first").show().addClass("image_animation_aktiv");

	setInterval(do_animation, interval_time);
	
	var anzahl = $("#image_animation img").length;
	//alert(anzahl);
	
	var anzahl_aktuell = 1;
	
	
	
	function do_animation() {
		if(anzahl_aktuell < anzahl) {
			$(".image_animation_aktiv").next("img").fadeIn(fade_time);
			$(".image_animation_aktiv").removeClass("image_animation_aktiv").next("img").addClass("image_animation_aktiv");
			anzahl_aktuell++;
		}
		
		else { 
			$("#image_animation img").hide();
			$("#image_animation img:first").show();
			$("#image_animation img:first").addClass("image_animation_aktiv");
			$("#image_animation img:last").show();
			$("#image_animation img:last").removeClass("image_animation_aktiv").fadeOut(fade_time);
			
			anzahl_aktuell = 1;
		}		
	}
	
});


	
/* ####### TEAM SLIDER ###########*/
	
	
$(document).ready(function(){

	var slideSpeed = 600;
	 var imgCount = $("#team_content_wrapper .team_content").length;
	var maxWidth = 0;
	var currentBox = 0;
	var theWidth = $("#team_content_wrapper .team_content:first").eq(0).outerWidth(true);
	//alert(imgCount);
	
	for (i=0;i<imgCount;i++){
		maxWidth = maxWidth + $("#team_content_wrapper .team_content").eq(i).outerWidth(true);
		if(i==imgCount-1) { startScript(); }
	} 
	
	
	function startScript(){
	
		//alert(maxWidth);
		
		arrowcheck();
	
		$("#team_content_wrapper").css("width", maxWidth); 
		
		$(".team_arrow#right").click(function(){
		
			if(currentBox < imgCount-1) {
				$("#team_content_wrapper").animate({ 
					left: -theWidth*(currentBox+1)+"px"
				  }, slideSpeed);
				  currentBox++;
			}
			arrowcheck();
		});
		
		$(".team_arrow#left").click(function(){	

		
			if(currentBox >= 1) {
				$("#team_content_wrapper").animate({ 
					left: -theWidth*(currentBox-1)+"px"
				  }, slideSpeed);
				  currentBox--;
			}
			arrowcheck();
		});
		
		function arrowcheck(){
			//alert(currentBox);
			
			if(currentBox < imgCount-1) { 
				$(".team_arrow#right").removeClass("empty");
			} else { 
				$(".team_arrow#right").addClass("empty");
			}
			
			
			if(currentBox >= 1) { 
				$(".team_arrow#left").removeClass("empty");
			} else { 
				$(".team_arrow#left").addClass("empty");
			}
		}
		
	}
	
	

});	
	
/* ####### CLIENTS SLIDER ###########*/
	
$(document).ready(function(){
	
		var x = $(".clients_content").outerWidth(true);
		var x_width = $(".clients_content:first").outerWidth(true);
		var inhalt = "nix";
		var slideSpeed = 600;
		var images = $("#clients_content_wrapper > div").size();
		/*
		$(".image_gallery_navigation_box:first").addClass("aktiv");
		
		$("#team_content_wrapper").animate({ 
					left: -theWidth*(currentBox-1)+"px"
				  }, slideSpeed);
			
		$(".image_gallery_navigation_box").click(function(){
		
			$(".image_gallery_navigation_box").removeClass("aktiv");
			$(this).addClass("aktiv");
			
			inhalt = $(this).html();
			
			$("#image_gallery_container div").fadeOut(800).delay(50).eq(inhalt-1).fadeIn(1500);
			
		});
		*/
		
		$(".client_box_count").click(function(){
			$(".client_box_count").removeClass("active");
			$(this).addClass("active");
			
			inhalt = $(this).find("a").html();
			
			$("#clients_content_wrapper").animate({ 
				left: -x_width*(inhalt-1)+"px"
			}, slideSpeed);
						
				
			
			
		});
		
		
	});
	
/* ####### FRIENDS ROTATOR ########## */
	
$(document).ready(function(){
    
	var imgCount = $(".friends_picture").length;
	
	var $elie = $(".friends_picture");
    
	for (i=0;i<imgCount;i++){
		
		var degree = Math.floor(Math.random()*15)-5;
		var theMargin = Math.floor(Math.random()*16)-20;
		
		$(".friends_picture").eq(i).css({ WebkitTransform: 'rotate(' + degree + 'deg)'});
		$(".friends_picture").eq(i).css({ '-moz-transform': 'rotate(' + degree + 'deg)'});
		$(".friends_picture").eq(i).css({ marginRight: theMargin });
		
		
	} 
	
	/*
	rotate(4);
    function rotate(degree) {

          // For webkit browsers: e.g. Chrome
        $elie.css({ WebkitTransform: 'rotate(' + degree + 'deg)'});
          // For Mozilla browser: e.g. Firefox
        $elie.css({ '-moz-transform': 'rotate(' + degree + 'deg)'});

    }
	*/
});

	

