var opacity = 1.0;
var currentPanel = "panel0";
var panelIn = "";
var free = 1;

function blend(panelNr)
{
	if(free)
	{
		panelIn = "panel" + panelNr;
		
		if (currentPanel != panelIn)
		{
			free = 0;
			setTimeout(function(){blendOut(currentPanel);}, 75);
		}
		
		switch(panelNr)
		{
			case "1":
				document.getElementById("men1").className = "ab";
				document.getElementById("men2").className = "menu";
				document.getElementById("men3").className = "menu";
				document.getElementById("men4").className = "menu";
				break;
			case "2":
				document.getElementById("men1").className = "menu";
				document.getElementById("men2").className = "up";
				document.getElementById("men3").className = "menu";
				document.getElementById("men4").className = "menu";
				break;
			case "3":
				document.getElementById("men1").className = "menu";
				document.getElementById("men2").className = "menu";
				document.getElementById("men3").className = "re";
				document.getElementById("men4").className = "menu";
				break;
			case "4":
				document.getElementById("men1").className = "menu";
				document.getElementById("men2").className = "menu";
				document.getElementById("men3").className = "menu";
				document.getElementById("men4").className = "pe";
				break;
		}
	}
}

function blendOut(panelOut)
{
	opacity -= 0.15;
	if(opacity > 0)
	{
		document.getElementById(panelOut).style.opacity = opacity + "";
		document.getElementById(panelOut).style.filter = "alpha(opacity=" + (opacity*100) + ")";
		setTimeout(function(){blendOut(panelOut);}, 75);
	}
	else
	{
		document.getElementById(panelOut).style.opacity = "0";
		document.getElementById(panelOut).style.filter = "alpha(opacity=0)";
		opacity = 0;
		setTimeout(function(){blendIn();}, 75);
	}
}
function blendIn()
{
	opacity += 0.15;

	if(opacity < 1)
	{
		document.getElementById(panelIn).style.opacity = opacity + "";
		document.getElementById(panelIn).style.filter = "alpha(opacity=" + (opacity*100) + ")";
		setTimeout(function(){blendIn();}, 75);
	}
	else
	{
		document.getElementById(panelIn).style.opacity = "1";
		document.getElementById(panelIn).style.filter = "alpha(opacity=100)";
		opacity = 1.0;
		currentPanel = panelIn;
		free = 1;
	}
}

