// fade-out text effect with rotation 

var texts = new Array(
"<font color='{col}' >\&ldquo;Redeemer has been a wonderful school for our daughter. The teachers truly care about the children as well as how they are doing academically. The communication between the teachers and parents is very open. It is money well spent!\&rdquo;<br><br><small>&mdash; Parent</small></font>",
"<font color='{col}' >\&ldquo;My child has attended Redeemer since the Preschool Program. He has blossomed under the care and guidence of the staff at Redeemer. Academically, he tests as advanced and I credit that to the educational programs of Redeemer.\&rdquo;<br><br><small>&mdash; Parent</small></font>",
"<font color='{col}' >\&ldquo;My wife went to Redeemer when she was young. Now, we have 2 girls that have gone to Redeemer since they were 3 years old. Very affordable and the teachers are the best I''ve ever seen. There is so much sincere love in the school from the teachers, staff, and students!\&rdquo;<br><br><small>&mdash; Parent</small></font>",
"<font color='{col}' >\&ldquo;The environment definitely helps my son grow more mature than he used to be. Extracurricular activities are great for my son to increase his physical endurance.\&rdquo;<br><br><small>&mdash; Parent</small></font>",
"<font color='{col}' >\&ldquo;Our daughter is thriving at Redeemer, and about to start 6th grade. We were welcomed with loving arms. The school is Christian based, but they have children from every religion attending. Redeemer is #1 in our book!\&rdquo;<br><br><small>&mdash; Parent</small></font>",
"<font color='{col}' >\&ldquo;We knew that the school experience for our kids anywhere else would not be able to compare to what they have here. You and your staff are to be commended for what you do. It is very evident that the Lord is working through each and every one of you. I praise the Lord each day for Redeemer and the difference the church and school has made in the lives of my family.\&rdquo;<br><br><small>&mdash; Stan</small></font>"
);

var bgcolor = "#eeeeee";
var fcolor = "#6883B0";
var steps = 20; // smoothness
var show = 7000; // timing
var sleep = 130;
var loop = true;

var colors = new Array(steps);
getFadeColors(bgcolor,fcolor,colors);
var color = 0;
var text = Math.round(Math.random()*(texts.length-1))
var step = 1;

function fade() {

	var text_out = texts[text].replace("{col}", colors[color]);
	
	if (document.all) fader.innerHTML = text_out;
	if (document.layers) { document.fader.document.write(text_out); 
		document.fader.document.close(); }
	if(!document.all && document.getElementById){
		document.getElementById("fader").innerHTML = text_out;
			}


color += step;

if (color >= colors.length-1) {
step = -1;

if (!loop && text >= texts.length-1) return;
}

if (color == 0) {
step = 1;

text += 1;
if (text == texts.length) text = 0;
}

setTimeout("fade()", (color == colors.length-2 && step == -1) ? show : ((color == 1 && step == 1) ? sleep : 50)); 
}

function getFadeColors(ColorA, ColorB, Colors) {
len = Colors.length;

if (ColorA.charAt(0)=='#') ColorA = ColorA.substring(1);
if (ColorB.charAt(0)=='#') ColorB = ColorB.substring(1);

var r = HexToInt(ColorA.substring(0,2));
var g = HexToInt(ColorA.substring(2,4));
var b = HexToInt(ColorA.substring(4,6));
var r2 = HexToInt(ColorB.substring(0,2));
var g2 = HexToInt(ColorB.substring(2,4));
var b2 = HexToInt(ColorB.substring(4,6));

var rStep = Math.round((r2 - r) / len);
var gStep = Math.round((g2 - g) / len);
var bStep = Math.round((b2 - b) / len);

for (i = 0; i < len-1; i++) {
Colors[i] = "#" + IntToHex(r) + IntToHex(g) + IntToHex(b);
r += rStep;
g += gStep;
b += bStep;
}
Colors[len-1] = ColorB;
}

function IntToHex(n) {
var result = n.toString(16);
if (result.length==1) result = "0"+result;
return result;
}

function HexToInt(hex) {
return parseInt(hex, 16);
}
