var slideShowSpeed = 10000
var maximal = 2
var t
var step = 0
var step2 = 0
var step3 = 0
var step4 = 0
var j = 0
function pause(millis) {
	var date = new Date();
	var curDate = null;
	
	do { curDate = new Date(); } 
	while(curDate-date < millis);
}

function fade(step) {
	step = step || 0;

    document.getElementById("slideshow1").style.opacity = 1-step/100;
    document.getElementById("slideshow2").style.opacity = 1-step/100;
    document.getElementById("slideshow3").style.opacity = 1-step/100;
    document.getElementById("slideshow1").style.filter = "alpha(opacity=" + 1-step + ")"; // IE
    document.getElementById("slideshow2").style.filter = "alpha(opacity=" + 1-step + ")"; // IE
    document.getElementById("slideshow3").style.filter = "alpha(opacity=" + 1-step + ")"; // IE

    step = step + 1;

    if (step <= 100) {
    	window.setTimeout(function () { fade(step); }, 5);
    }
    else {
    	document.getElementById("slideshow4").style.display='block';
		document.getElementById("slideshow5").style.display='block';
		document.getElementById("slideshow6").style.display='block';
		document.getElementById("slideshow1").style.display='none';
		document.getElementById("slideshow2").style.display='none';
		document.getElementById("slideshow3").style.display='none';
		document.getElementById("slideshow4").style.opacity='0';
		document.getElementById("slideshow5").style.opacity='0';
		document.getElementById("slideshow6").style.opacity='0';
		step = step || 100;
		step2 = step-100;
    	document.getElementById("slideshow4").style.opacity = step2/100;
    	document.getElementById("slideshow5").style.opacity = step2/100;
    	document.getElementById("slideshow6").style.opacity = step2/100;
    	document.getElementById("slideshow4").style.filter = "alpha(opacity=" + step2 + ")"; // IE
    	document.getElementById("slideshow5").style.filter = "alpha(opacity=" + step2 + ")"; // IE
    	document.getElementById("slideshow6").style.filter = "alpha(opacity=" + step2 + ")"; // IE
	
	    step = step + 1;
	
	    if (step <= 200) {
	    	window.setTimeout(function () { fade(step); }, 5);
	    }
    }
}

function fade2(step3) {
	step3 = step3 || 0;
    document.getElementById("slideshow4").style.opacity = 1-step3/100;
    document.getElementById("slideshow5").style.opacity = 1-step3/100;
    document.getElementById("slideshow6").style.opacity = 1-step3/100;
    document.getElementById("slideshow4").style.filter = "alpha(opacity=" + 1-step3 + ")"; // IE
    document.getElementById("slideshow5").style.filter = "alpha(opacity=" + 1-step3 + ")"; // IE
    document.getElementById("slideshow6").style.filter = "alpha(opacity=" + 1-step3 + ")"; // IE

    step3 = step3 + 1;

    if (step3 <= 100) {
    	window.setTimeout(function () { fade2(step3); }, 5);
    }
    else {
    	document.getElementById("slideshow1").style.display='block';
		document.getElementById("slideshow2").style.display='block';
		document.getElementById("slideshow3").style.display='block';
		document.getElementById("slideshow4").style.display='none';
		document.getElementById("slideshow5").style.display='none';
		document.getElementById("slideshow6").style.display='none';
		document.getElementById("slideshow1").style.opacity='0';
		document.getElementById("slideshow2").style.opacity='0';
		document.getElementById("slideshow3").style.opacity='0';
		step3 = step3 || 100;
		step4 = step3-100;
    	document.getElementById("slideshow1").style.opacity = step4/100;
    	document.getElementById("slideshow2").style.opacity = step4/100;
    	document.getElementById("slideshow3").style.opacity = step4/100;
    	document.getElementById("slideshow1").style.filter = "alpha(opacity=" + step4 + ")"; // IE
    	document.getElementById("slideshow2").style.filter = "alpha(opacity=" + step4 + ")"; // IE
    	document.getElementById("slideshow3").style.filter = "alpha(opacity=" + step4 + ")"; // IE
	
	    step3 = step3 + 1;
	
	    if (step3 <= 200) {
	    	window.setTimeout(function () { fade2(step3); }, 5);
	    }
    }
}

function runSlideShow()
{
	j = j + 1
	if (j > maximal) j=1
	
	if (j == 1) {
		fade();
	}
	else if (j == 2) {
		fade2();
	}
	
	t = setTimeout('runSlideShow()', slideShowSpeed)
}

function hoverIn(bild){
	$("#grundmann-consulting-team-bild1-gross").fadeOut(400);
	$("#grundmann-consulting-team-bild2-gross").fadeOut(400);
	$("#grundmann-consulting-team-bild3-gross").fadeOut(400);
	$("#grundmann-consulting-team-bild4-gross").fadeOut(400);
	$("#grundmann-consulting-team-bild5-gross").fadeOut(400);
	$("#grundmann-consulting-team-bild6-gross").fadeOut(400);
	$("#grundmann-consulting-team-bild7-gross").fadeOut(400);
	$("#grundmann-consulting-team-bild8-gross").fadeOut(400);
	$("#grundmann-consulting-team-bild9-gross").fadeOut(400);
	$("#grundmann-consulting-team-bild"+bild+"-gross").fadeIn(400);
}
function hoverOut(bild){
	$("#grundmann-consulting-team-bild"+bild+"-gross").fadeOut(400);
}
function teamEckeIn(bild){
	$("#teamexpertise-ecke"+bild+"-gross").fadeIn(400);
}
function teamEckeOut(bild){
	$("#teamexpertise-ecke"+bild+"-gross").fadeOut(400);
}
function start(){
	cookieSchreiben("startanimation","true",1);
	if (cookieLesen("startanimation") != "true"){
		document.getElementById("mitte-links").style.display = "none";
		document.getElementById("mitte-rechts").style.display = "none";
		document.getElementById("slideshow1").style.display = "none";
		document.getElementById("slideshow2").style.display = "none";
		document.getElementById("slideshow3").style.display = "none";
		document.getElementById("grundmann-consulting-team-bild1").style.display = "none";
		document.getElementById("grundmann-consulting-team-bild2").style.display = "none";
		document.getElementById("grundmann-consulting-team-bild3").style.display = "none";
		document.getElementById("grundmann-consulting-team-bild4").style.display = "none";
		document.getElementById("grundmann-consulting-team-bild5").style.display = "none";
		document.getElementById("grundmann-consulting-team-bild6").style.display = "none";
		document.getElementById("grundmann-consulting-team-bild7").style.display = "none";
		document.getElementById("grundmann-consulting-team-bild8").style.display = "none";
		document.getElementById("grundmann-consulting-team-bild9").style.display = "none";
		document.getElementById("index_kasten").style.display = "none";
		$("#grundmann-consulting-text").animate({
		  "margin-top": "250px"
		}, 1000);
		setTimeout("animationStart()",10000);
	}
	else {
		runSlideShow();
	}
}
function animationStart() {
	$("#grundmann-consulting-text").animate({
	  "margin-top": "50px"
	}, 1000,function(){
		$("#mitte-links").fadeIn(400, function(){
			$("#grundmann-consulting-team-bild1").fadeIn(400);
			$("#grundmann-consulting-team-bild2").fadeIn(400);
			$("#grundmann-consulting-team-bild3").fadeIn(400);
			$("#grundmann-consulting-team-bild4").fadeIn(400);
			$("#grundmann-consulting-team-bild5").fadeIn(400);
			$("#grundmann-consulting-team-bild6").fadeIn(400);
			$("#grundmann-consulting-team-bild7").fadeIn(400);
			$("#grundmann-consulting-team-bild8").fadeIn(400);
			$("#grundmann-consulting-team-bild9").fadeIn(400);
		});
		$("#mitte-rechts").fadeIn(400, function(){
			$("#slideshow1").fadeIn(400);
			$("#slideshow2").fadeIn(400);
			$("#slideshow3").fadeIn(400, function(){
				$("#index_kasten").fadeIn(400);
				runSlideShow();	
			});
		});
	});
	cookieSchreiben("startanimation","true",1);
}

function coaching(bereich,full){
	if (full == 'full'){
		$("#kasten1_c").fadeOut(400);
		$("#linie1_c").fadeOut(400);
		$("#kasten2_c").fadeOut(400);
		$("#linie2_c").fadeOut(400);
		$("#kasten3_c").fadeOut(400);
		$("#coaching-fuehrung").fadeOut(400);
		$("#coaching-experten").fadeOut(400);
		$("#coaching-standort").fadeOut(400);
		$("#coaching-frauen").fadeOut(400);
		$("#coaching-praesentation").fadeOut(400);
		$("#coaching-"+bereich).fadeIn(400);
		$("#transparenz").fadeIn(400);
	}
	else {
		$("#kasten1_c").fadeIn(400);
		$("#linie1_c").fadeIn(400);
		$("#kasten2_c").fadeIn(400);
		$("#linie2_c").fadeIn(400);
		$("#kasten3_c").fadeIn(400);
		$("#transparenz").fadeOut(400);
		$("#coaching-fuehrung").fadeOut(400);
		$("#coaching-experten").fadeOut(400);
		$("#coaching-standort").fadeOut(400);
		$("#coaching-frauen").fadeOut(400);
		$("#coaching-praesentation").fadeOut(400);
	}
}

//COOKIES
function cookieSchreiben(name,wert,zeit){
	//ZEIT IN TAGEN
	var a = new Date();
	a = new Date(a.getTime() +zeit*1000*60*60*24);
	document.cookie = name+'='+wert+'; expires='+a.toGMTString()+';';
}

function cookieLesen(name){
	a = document.cookie;
	res = '';
	while(a != ''){
		while(a.substr(0,1) == ' '){
			a = a.substr(1,a.length);
		}
		cookiename = a.substring(0,a.indexOf('='));
		if(a.indexOf(';') != -1){
			cookiewert = a.substring(a.indexOf('=')+1,a.indexOf(';'));
		}
		else{
			cookiewert = a.substr(a.indexOf('=')+1,a.length);
		}
		if(name == cookiename){
			res = cookiewert;
		}
		i = a.indexOf(';')+1;
		if(i == 0){
			i = a.length
		}
		a = a.substring(i,a.length);
	}
	return(res)
}

function cookieLoeschen(name){
	document.cookie = name+'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
