// JavaScript Document

// Cross Browser fade in and fade out functions written by GS ********************************************************

// Function to start the fade out of an object with the object id and fade time passed in
function fade_out(oid, otime) {
	fade_out_content=document.getElementById(oid);
	fade_out_tick = otime/20; 
	fade_out_opacity = 100; // starts at fully opaque to begin with for IE
	fade_out_opacity_moz = 1; // starts at fully opaque to begin with for non IE browsers
	animate_out();
}

// Function to animate an object fading 
function animate_out() {	
	fade_out_opacity -= 5; // decrement opacity for IE
	fade_out_content.style.filter = 'alpha(opacity='+fade_out_opacity+')'; // set opacity of content if IE
	fade_out_opacity_moz -= 0.05; // decrement opacity for non IE browsers
	fade_out_content.style.opacity = fade_out_opacity_moz; // set opacity of content for non IE browsers 
	if(fade_out_opacity > 0) {fadeoutID = setTimeout('animate_out()', fade_out_tick); // call this function again in 'fade out tick' milliseconds						
	} else {
		clearTimeout(fadeoutID); // stop fade out timer looping
		fade_out_opacity = 100; // reset opacity for next time IE
		fade_out_opacity_moz = 1; // reset opacity for next time for non IE browsers
		fade_out_content.style.visibility = 'hidden'; // hide faded content
	}
}

// Function to start the fade in of an object with the object id and fade time passed in
function fade_in(iid, itime) {
	fade_in_content=document.getElementById(iid);
	fade_in_tick = itime/20;
	fade_in_opacity = 0; // starts at fully transparent to begin with for IE
	fade_in_opacity_moz = 0; // starts at fully transparent to begin with for non IE browsers
	fade_in_content.style.filter = 'alpha(opacity=0)'; // make new content transparent to begin with for IE
	fade_in_content.style.opacity = 0; // make new content transparent to begin with for non IE browsers
	fade_in_content.style.visibility = "visible"; // make new content visible
	animate_in();
}
	
// Function to animate the fading in of an object
function animate_in() {		
	fade_in_opacity += 5; // increment opacity for IE
	fade_in_content.style.filter = 'alpha(opacity='+fade_in_opacity+')'; // set opacity of content if IE
	fade_in_opacity_moz += 0.05; // increment opacity for all non IE browsers
	fade_in_content.style.opacity = fade_in_opacity_moz; // set opacity of content for all non IE browsers 	
	if(fade_in_opacity < 100) {fadeinID = setTimeout('animate_in()', fade_in_tick); // call this function again in 'fade_in_tick' milliseconds				
	} else {
		clearTimeout(fadeinID); // stop fade in timer looping
		fade_in_opacity = 0; // reset opacity for next time IE
		fade_in_opacity_moz = 0; // reset opacity for next time for non IE browsers
	}
}
// end of fade in and out functions ****************************************************************************

