

	// global arrays
	var fading_els = new Array();		// this is used to store whether an element is "busy" with a transition, or is free to be transitioned
	var myOpacity = new Array();		// this is used to store an elements current opacity
	
	
	// fading an element through an opacity range
	function opacity(id, opacStart, opacEnd, millisec) {
	    //speed for each frame
	    var speed = Math.round(millisec / 100);
	    var timer = 0;
		document.getElementById(id).style.display = '';
	
	    //determine the direction for the blending, if start and end are the same nothing happens
	    if(opacStart > opacEnd) {
	        for(i = opacStart; i >= opacEnd; i--) {
	            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
	            timer++;
	        }
	    } else if(opacStart < opacEnd) {
	        for(i = opacStart; i <= opacEnd; i++) {
	            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
	            timer++;
	        }
	    }
	}
	
	
	//change the opacity for different browsers
	function changeOpac(opacity, id) {
		try {
		    var object = document.getElementById(id).style;
		    object.opacity = (opacity / 100);
		    object.MozOpacity = (opacity / 100);
		    object.KhtmlOpacity = (opacity / 100);
		    object.filter = "alpha(opacity=" + opacity + ")";
			myOpacity[id] = opacity;
	    } catch(ex) {
		}
	}
	
	
	// fades in/out for an element. Can specify the time in ms. 
	// Will check to see that whether or not the element is busy with a fade.
	function fade(el_id, inout, ms) {
		if (fading_els[el_id] !== 'busy') {
			var thisOpac = "" + myOpacity[el_id];
			if (inout == 'in') {
				if (thisOpac == "0" || thisOpac == "" || thisOpac == "undefined") {
					opacity(el_id, 0, 100, ms);
					fading_els[el_id] = 'busy';
					window.setTimeout("fade_freeup('" +el_id + "')", ms);
				}
			} else {
				if (thisOpac == "100" || thisOpac == "" || thisOpac == "undefined") {
					opacity(el_id, 100, 0, ms);
					fading_els[el_id] = 'busy';
					window.setTimeout("fade_freeup('" +el_id + "')", ms);
				}
			}
		}
	}

	
	function fade_freeup(el_id) {
		fading_els[el_id] = '';
	}


