
// --- Funções VIRTUAIS para dar override
function PlayFlashNav(stID_, bMouseOver_)
{
	return;
}

function TabFromFlash(stSecao_, bMouseOver_)
{
	return;
}
// ----


// Função para alterar gradualmente um elemento para um novo estilo
function ElementShift(stID_, StyleOld_, StyleNew_, iMilisecondsDuration_, iSteps_, bPlayFlash_, bPlayFlashArg1_)
{
	SetShiftTimeout(stID_, StyleOld_, StyleNew_, iMilisecondsDuration_, iSteps_);
	
	if (bPlayFlash_)
	{
		PlayFlashNav(stID_, bPlayFlashArg1_);
	}
}

// Limpa as transições configuradas para um elemento específico.
function ClearTimeoutArray(ID_)
{
	if (document.getElementById(ID_).arrayTimeout == null)
	{
		document.getElementById(ID_).arrayTimeout = new Array();
	}

	for (var i= 0 ; i < document.getElementById(ID_).arrayTimeout.length ; i++)
	{
		if (document.getElementById(ID_).arrayTimeout[i] < 0)
		{
			continue;
		}
		clearTimeout(document.getElementById(ID_).arrayTimeout[i]);
	}
	
	document.getElementById(ID_).arrayTimeout = new Array();
}


// Programa o sistema para executar as funções de transição entre dois estilos em vários elementos simultaneamente
function SetShiftTimeoutList(aIDList_, styleStart_, styleEnd_, millisec_, steps_)
{
	for (var i=0 ; i < aIDList_.length ; i++)
	{
		SetShiftTimeout(aIDList_[i], styleStart_, styleEnd_, millisec_, steps_);
	}
}


// Programa o sistema para executar as funções de transição entre dois estilos
function SetShiftTimeout(ID_, styleStart_, styleEnd_, millisec_, steps_)
{	
	if (document.getElementById(ID_) == null)
	{
		return;
	}
	
	var bgStart, bgDif, padStart, padDif, marginStart, topStart, topDif;
	
	if (document.getElementById(ID_).style.backgroundColor == "")
	{
		bgStart = RGBValueToArray(styleStart_.backgroundColor);
		bgDif = RGBVariationArray(styleStart_.backgroundColor, styleEnd_.backgroundColor);
		
		padStart = RemoveUnit(styleStart_.padding.split(" ")[0]);
		padDif = RemoveUnit(styleEnd_.padding.split(" ")[0]) - padStart;
		
		marginStart = RemoveUnit(styleStart_.marginLeft);
		
		topStart = RemoveUnit(styleStart_.top);
		topDif = RemoveUnit(styleEnd_.top) - topStart;
	}
	else
	{
		var elementoEstilo = document.getElementById(ID_).style;		
		
		bgStart = RGBValueToArray(elementoEstilo.backgroundColor);
		bgDif = RGBVariationArray(elementoEstilo.backgroundColor, styleEnd_.backgroundColor);
		
		padStart = RemoveUnit(elementoEstilo.padding.split(" ")[0]);
		padDif = RemoveUnit(styleEnd_.padding.split(" ")[0]) - padStart;
		
		marginStart = RemoveUnit(elementoEstilo.marginLeft);
		
		topStart = RemoveUnit(elementoEstilo.top);
		topDif = RemoveUnit(styleEnd_.top) - topStart;
	}
	
	var padUnit = GetUnit(styleEnd_.padding.split(" ")[0]);
	var topUnit = GetUnit(styleEnd_.top);

	ClearTimeoutArray(ID_);
	
	var rgb = new Array(3);
	
	// Se houver só um passo, executa logo o último estágio, sem passar pelos timeouts.
	if (steps_ == 1)
	{
		ChangeTab(ID_, styleEnd_.backgroundColor, styleEnd_.padding, styleEnd_.marginLeft, styleEnd_.top, document.getElementById(ID_).arrayTimeout.length);
		return;
	}
	
	for (var i = 1/steps_ ; i < 0.98 ; i+= 1/steps_) 
	{
		rgb[0] = bgStart[0] + Math.floor(bgDif[0]*i);
		rgb[1] = bgStart[1] + Math.floor(bgDif[1]*i);
		rgb[2] = bgStart[2] + Math.floor(bgDif[2]*i);
		var padNow = Math.floor(padStart+(padDif*i));
		var marginNow = Math.ceil(marginStart - (padDif*i));
		var topNow = Math.floor(topStart + (topDif*i));		
		
		document.getElementById(ID_).arrayTimeout.push(setTimeout("ChangeTab('" + ID_ + "','" + RGBArrayToValue(rgb) + "','" + padNow + padUnit + "','" + marginNow + padUnit + "','" + topNow + topUnit + "'," + (document.getElementById(ID_).arrayTimeout.length) + ")",millisec_*i));
	}
	
	//Último quadro
	document.getElementById(ID_).arrayTimeout.push(setTimeout("ChangeTab('" + ID_ + "','" + styleEnd_.backgroundColor + "','" + styleEnd_.padding + "','" + styleEnd_.marginLeft + "','" + styleEnd_.top + "'," + (document.getElementById(ID_).arrayTimeout.length) + ")", millisec_));
	
}



function ChangeTab(ID_, bgValue_, paddingValue_, marginValue_, topValue_, positionTimeout_) 
{	
	if (document.getElementById(ID_) == null)
	{
		return;
	}
	
	document.getElementById(ID_).style.backgroundColor = bgValue_;
	document.getElementById(ID_).style.padding = paddingValue_;
	document.getElementById(ID_).style.marginLeft = marginValue_;
	document.getElementById(ID_).style.marginRight = marginValue_;
	document.getElementById(ID_).style.top = topValue_;
	
	if (positionTimeout_ >= 0)
	{
		clearTimeout(document.getElementById(ID_).arrayTimeout[positionTimeout_]);
		document.getElementById(ID_).arrayTimeout[positionTimeout_] = -1;
	}
}