var opacity_timeouts = new Array();

function animateOpacity(id, opacStart, opacEnd, millisec, executeOnFinish) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if (opacStart > opacEnd) {
		for (i = opacStart; i >= opacEnd; i--) {
			opacity_timeouts.push(setTimeout("changeOpacity(" + i + ",'" + id + "')", (timer * speed)));
			timer++;
		}
	} else if (opacStart < opacEnd) {
		for (i = opacStart; i <= opacEnd; i++) {
			opacity_timeouts.push(setTimeout("changeOpacity(" + i + ",'" + id + "')", (timer * speed)));
			timer++;
		}
	}
	opacity_timeouts.push(setTimeout("eval("+executeOnFinish+")", millisec + 200));
}

//change the opacity for different browsers
function changeOpacity(opacity, id) {
	var object = document.getElementById(id);
	if (object.style.visibility != "hidden" && object.style.display != "none") {
		object.style.opacity = (opacity / 100);
		object.style.MozOpacity = (opacity / 100);
		object.style.KhtmlOpacity = (opacity / 100);
		object.style.filter = "alpha(opacity=" + opacity + ")";
	}
} 

//set to opaque for different browsers
function setOpaque(id) {
	var object = document.getElementById(id);
	object.style.opacity = 100;
	object.style.MozOpacity = 100;
	object.style.KhtmlOpacity = 100;
	object.style.filter = "alpha(opacity=" + 100 + ")";
} 

//set to transparent for different browsers
function setTransparent(id) {
	var object = document.getElementById(id);
	object.style.opacity = 0;
	object.style.MozOpacity = 0;
	object.style.KhtmlOpacity = 0;
	object.style.filter = "alpha(opacity=" + 0 + ")";
} 

function cancelOpacityAnimTimeouts() {
	for (var i in opacity_timeouts) {
		clearTimeout(opacity_timeouts[i]);
	}
	opacity_timeouts = new Array();
}


