//====================================
// ==============================================================
//  REcore Engine
// ==============================================================
//====================================

// Please refer to the SVN log for version information.

// (c) Copyright REaction Marketing. All Rights Reserved.

// Notes: This document contains most visual appeal and effects such as fades and window overlays.

// =================================
//  Button Effect
// =================================
function buttonEffect(i, tf)
{
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	if(tf == "TRUE")
	{
       	 	if(ie5) document.getElementById(i).filters.alpha.opacity = 50;
        	if(ns6) document.getElementById(i).style.MozOpacity = .5;
	}
	else
	{
       	 	if(ie5) document.getElementById(i).filters.alpha.opacity = 100;
        	if(ns6) document.getElementById(i).style.MozOpacity = 1;
	}
}

// =================================
//  Launch a Hidden Window
// =================================
function winLaunch(i)
{
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	if(window.document.getElementById(i).style.visibility == "visible")
	{
		fadeWinOut(i, 100, 50);
	}
	else
	{
		window.document.getElementById(i).style.visibility="visible";
		fadeWin(i, 0, 50);
	}
}
// =================================
//  Cross Dissolve
// =================================
function crossDissolve(id_fadein, id_fadeout) 
{
	fadeWin(id_fadein, 0, 5);
	fadeWinOut(id_fadeout, 100, 5);	
}

// =================================
//  Generic Fade Animation
// =================================
// Fade in and out are placed in seperate functions
// for performance reasons in Firefox.

function fadeWin(i, opac, increment) 
{
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	var element = document.getElementById(i);
	window.document.getElementById(i).style.visibility="visible";
	if(opac < 100)
	{
  		opac+=increment;
		if (ie5) element.style.filter = "alpha(opacity:"+opac+")";
		else
		element.style.opacity = element.style.MozOpacity = opac/100;
		setTimeout(function() { fadeWin(i, opac, increment) }, 2);
	}	
}

function fadeWinOut(i, opac, increment) 
{
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);
	var element = document.getElementById(i);
	if (opac > 0)
	{
  		opac-=increment;
		if (opac != 0) //prevents division by zero
		{
			if (ie5) element.style.filter = "alpha(opacity:"+opac+")";
			else
			element.style.opacity = element.style.MozOpacity = opac/100;
		}
		setTimeout(function() { fadeWinOut(i, opac, increment) }, 2);
		if (opac == 0)
		{
			window.document.getElementById(i).style.visibility="hidden";
		}
	}
}
