fadeval = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

faderunning = new Array(40);

//foreColA = new Array(232, 232, 232); //hellgrau
foreColA = new Array(255, 255, 255); //weiß
foreColB = new Array (0, 80, 255); //hellblau

boxlink = new Array(3);
boxlink[1] = 24;
boxlink[2] = 13;


function fadein(nr) {

	faderunning[nr] = 1;
	dofadein(nr);

}

function fadeout(nr) {

	faderunning[nr] = 2;
	dofadeout(nr);
}

function dofadein(nr) {

	var tVal;
	
	if (faderunning[nr] == 1) if (fadeval[nr] < 255) {
		
		fadeval[nr] += 5;
			
		tVal = fadeval[nr];
		document.getElementById('link' + nr).style.backgroundColor = 
			'rgb(' + Math.round(foreColA[0] + (foreColB[0] - foreColA[0]) * tVal / 255) + ',' 
				   + Math.round(foreColA[1] + (foreColB[1] - foreColA[1]) * tVal / 255) + ',' 
				   + Math.round(foreColA[2] + (foreColB[2] - foreColA[2]) * tVal / 255) + ')';
			
		fontColB = new Array(255, 255, 255);
		if (nr < 30)
		{
			fontColA = new Array(0, 0, 0);
		}
		else
		{
			fontColA = new Array(153, 153, 153);
		}

		//tVal = 255 - fadeval[nr];
		document.getElementById('link' + nr).style.color = 
			'rgb(' + Math.round(fontColA[0] + (fontColB[0] - fontColA[0]) * tVal / 255) + ',' 
				   + Math.round(fontColA[1] + (fontColB[1] - fontColA[1]) * tVal / 255) + ',' 
				   + Math.round(fontColA[2] + (fontColB[2] - fontColA[2]) * tVal / 255) + ')';
			
			
		window.setTimeout('dofadein(' + nr + ')', 20);
		
	} else faderunning[nr] = 0
}

function dofadeout(nr) {

	var tVal;
	
	if (faderunning[nr] == 2) if (fadeval[nr] > 0) {
		
		fadeval[nr] -= 5;
		
		tVal = fadeval[nr];
		document.getElementById('link' + nr).style.backgroundColor = 
			'rgb(' + Math.round(foreColA[0] + (foreColB[0] - foreColA[0]) * tVal / 255) + ',' 
				   + Math.round(foreColA[1] + (foreColB[1] - foreColA[1]) * tVal / 255) + ',' 
				   + Math.round(foreColA[2] + (foreColB[2] - foreColA[2]) * tVal / 255) + ')';

		fontColB = new Array(255, 255, 255);
		if (nr < 30)
		{
			fontColA = new Array(0, 0, 0);
		}
		else
		{
			fontColA = new Array(153, 153, 153);
		}

		//tVal = 255 - fadeval[nr];
		document.getElementById('link' + nr).style.color = 
			'rgb(' + Math.round(fontColA[0] + (fontColB[0] - fontColA[0]) * tVal / 255) + ',' 
				   + Math.round(fontColA[1] + (fontColB[1] - fontColA[1]) * tVal / 255) + ',' 
				   + Math.round(fontColA[2] + (fontColB[2] - fontColA[2]) * tVal / 255) + ')';
		
		window.setTimeout('dofadeout(' + nr + ')', 20);
		
	} else faderunning[nr] = 0
}

function ShowNext(state) {
	document.getElementById('next').src = 'weiter' + state + '.gif';
}


/* Hover-Boxen */

basehover    = new Array(0,0,0,0,0,0,0,0,0,0,0); 
boxhover     = new Array(0,0,0,0,0,0,0,0,0,0,0);
boxmaxheight = new Array(0,0,0,0,0,0,0,0,0,0,0);
boxheight    = new Array(0,0,0,0,0,0,0,0,0,0,0);
startclose   = new Array(0,0,0,0,0,0,0,0,0,0,0);

function initSize() {
	GetSize(1);
	GetSize(2);
}

function GetSize(num) {
   boxmaxheight[num] = document.getElementById('box' + num).offsetHeight; 
}

function showbox(num) {
	if (boxmaxheight[num] == 0) return;
	document.getElementById('box' + num).style.display = '';
	y = document.getElementById("basediv").offsetTop + document.getElementById('link' + boxlink[num]).offsetTop + 158;
	x = document.getElementById("basediv").offsetLeft + document.getElementById('link' + boxlink[num]).offsetLeft + 0;
	document.getElementById('box' + num).style.left = x + 'px';
	document.getElementById('box' + num).style.top  = y + 'px'; 
	document.getElementById('box' + num).style.height = '0px';
	basehover[num] = 1;
	openBox(num);
}

function hidebox(num, in_box) {
	if (in_box) boxhover[num]  = 0;
	else        basehover[num] = 0;
	if (basehover[num] + boxhover[num] == 0) {
		if (boxmaxheight[num] == 0) return;
		closeBox(num); 
	}
}

function overbox(num) {
	boxhover[num] = 1;
	document.getElementById('box' + num).style.display = '';
}

function openBox(num) {

	if (!(basehover[num] || boxhover[num])) {
		closeBox(num);
		return;
	}
	
	startclose[num] = 0;
	
	if (boxheight[num] >= boxmaxheight[num]) {
		boxheight[num] = boxmaxheight[num];
		document.getElementById('box' + num).style.display='';
		document.getElementById('box' + num).style.height = boxmaxheight[num] + 'px';
		return;
	}
	
	boxheight[num] = Math.min(boxheight[num] + 2, boxmaxheight[num]);
	document.getElementById('box' + num).style.display='';
	document.getElementById('box' + num).style.height = boxheight[num] + 'px';
	if (boxheight[num] < boxmaxheight[num]) {
		window.setTimeout('openBox(' + num + ')', 10);
	}
	
	

	
}	

function closeBox(num) {
	if (basehover[num] || boxhover[num]) {
		openBox(num);
		return;
	}
	
	if (startclose[num] == 0) // "Zittern" vermeiden
	{
		startclose[num] = 1;
	}
	else
	{
		boxheight[num] -= 2;
		if (boxheight[num] < 0) boxheight[num] = 0;
		document.getElementById('box' + num).style.height = boxheight[num] + 'px';
		if (boxheight[num] == 0) document.getElementById('box' + num).style.display='none';
	}
	
	
	if (boxheight[num] > 0) {
		window.setTimeout('closeBox(' + num + ')', 10);
	}
	
}	

