function cambiaColor(colores, id, ms, t, f) {
	var fondos = window[colores];
	var elemento = document.getElementById(id);
	elemento.setAttribute("incremento", "-1");
	elemento.setAttribute("valor", (fondos.length - 2).toString());
	transitarColor(colores, id, ms, t, f);
}

function recuperaColor(colores, id, ms, t, f)	{
	var elemento = document.getElementById(id);
	elemento.setAttribute("incremento", "1");
	if (parseInt(elemento.getAttribute("valor")) < 0)
		elemento.setAttribute("valor", "1");
	transitarColor(colores, id, ms, t, f);
}

function transitarColor(colores, id, ms, t, f) {
	var fondos = window[colores];
	var elemento = document.getElementById(id);
	var incre = parseInt(elemento.getAttribute("incremento"));
	var valorActual = parseInt(elemento.getAttribute("valor"));
	var nuevoValor = valorActual + incre;
	elemento.setAttribute("valor", nuevoValor);
	if (nuevoValor >= 0 && nuevoValor < (fondos.length)) {
		if (f)	elemento.style.backgroundColor = fondos[nuevoValor];
		if (t)	elemento.style.color = fondos[(fondos.length) - nuevoValor - 1];
		var recurrir = "transitarColor('" + colores + "', '" + id + "', " + ms + ", " + t + ", " + f + ")";
		setTimeout(recurrir, ms);
	}
}

