var layerThatFades, layerThatAppears, layerThatFades2, op1, op2, stepAmount, stepInterval, stepCounter, hop;

function Opacitate2() {
	
	  op1-=hop;
	  op2+=hop;
	
		setOpacity(layerThatFades,op1);
		setOpacity(layerThatAppears,op2);
		
		stepCounter++;
		
		if (stepCounter<stepAmount) {
			setTimeout("Opacitate2()", stepInterval);
			return;
		} else {
			document.getElementById(layerThatAppears).style.visibility = "visible";		
			document.getElementById(layerThatFades).style.visibility = "hidden";
			setOpacity(layerThatFades,0);
			setOpacity(layerThatAppears,1);
			return;
		}
	return;
}


function divcrossfade(divToShow, divToHide) {
	
	if (document.getElementById(divToShow).style.visibility == "visible") return;
	
	duration = 100; 	// transition duration in miliseconds
	hop = 0.1; 			// opacity change interval
	
	stepAmount = Math.round( 1 / hop ) +1 ; // how many steps
	stepInterval = Math.round( duration / ( 1 / hop ) );
	stepCounter = 0;
	
	layerThatAppears=divToShow;
	layerThatFades=divToHide;
	
	op1=1; // from one to zero, disappears
	op2=0; // from zero to one, appears

	setOpacity(divToShow,0);
	setOpacity(divToHide,1);
	
	//alert("hello1");
	document.getElementById(layerThatAppears).style.visibility = "visible";		
	//alert("hello2");
	document.getElementById(layerThatFades).style.visibility = "visible";
	//alert("hello3");
	
	setTimeout("Opacitate2()", stepInterval);

	
	return;
	
}


