/* 
	Script to support fading of elements over time
	and crossfading images
	
	v.1.0 
	3/31/06
	Kam Figy
	
	Loosely based on original code from http://www.brainerror.net/scripts_js_blendtrans.php
*/

function Fade(id, alphaStart, alphaEnd, duration) {
	//speed for each frame
	var speed = Math.round(duration / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(alphaStart > alphaEnd) {
		for(i = alphaStart; i >= alphaEnd; i--) {
			setTimeout("SetOpacity(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(alphaStart < alphaEnd) {
		for(i = alphaStart; i <= alphaEnd; i++)
			{
			setTimeout("SetOpacity(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function SetOpacity(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
