var layerThatFades, layerThatAppears, layerThatFades2, op1, op2, stepAmount, stepInterval, stepCounter, hop;

function Opacitate() {
	
	  op1-=hop;
	  op2+=hop;
	
		setOpacity(layerThatFades,op1);
		setOpacity(layerThatAppears,op2);
		
		stepCounter++;
		
		if (stepCounter<stepAmount) {
			setTimeout("Opacitate()", stepInterval);
		} else {
			document.getElementById(layerThatAppears).style.visibility = "visible";		
			document.getElementById(layerThatFades).style.visibility = "hidden";	
			document.getElementById(layerThatFades2).style.visibility = "hidden";
			setOpacity(layerThatFades,0);
			setOpacity(layerThatFades2,0);
			setOpacity(layerThatAppears,1);
			return;
		}
}


function divcrossfadethree(divToShow, divToHide2, divToHide1) {
	
	if (document.getElementById(divToShow).style.visibility == "visible") return;
	
	duration = 200; 	// transition duration in miliseconds
	hop = 0.05; 			// opacity change interval
	
	stepAmount = Math.round( 1 / hop ); // how many steps
	stepInterval = Math.round( duration / stepAmount );
	stepCounter = 0;

	layerThatAppears=divToShow;
	
	op1=1; // from one to zero, disappears
	op2=0; // from zero to one, appears
	
	if (document.getElementById(divToHide1).style.visibility == "visible") {
		layerThatFades=divToHide1;
		layerThatFades2=divToHide2;
	}
	else {
		layerThatFades=divToHide2;
		layerThatFades2=divToHide1;
	}
	
	setOpacity(layerThatAppears,0);
	setOpacity(layerThatFades,1);
	
	document.getElementById(layerThatAppears).style.visibility = "visible";		
	document.getElementById(layerThatFades).style.visibility = "visible";
	
	setTimeout("Opacitate()", stepInterval);
	
	return;
}



function changetn(tn1,tn2,tn3) {
	
	if (document.getElementById(tn1).className == 'tnSel') return;
	
	if (document.getElementById(tn2).className == 'tnSel') {
		document.getElementById(tn2).className = 'tnReg';	
	}
	else {
		document.getElementById(tn3).className = 'tnReg';	
	}
	
	document.getElementById(tn1).className = 'tnSel';
	
	return;
}
