
// fade-out text effect with rotation 

var texts = new Array(
"<font color='{col}' >\"I have called Dan many times from the gate at an airport. In just a few minutes he gets me centred and grounded. Then I take off! I am free to fly with freedom and ease anytime.\" <br />&#8212; Catherine, Coral Springs, FL</font>",
"<font color='{col}' >\"Dan has the ability to listen, get my problem, and then coach me on what I couldn’t see on my own. In doing so, I am immediately returned to feeling powerful and ready to take on whatever comes my way!\" <br />&#8212; Melanie, Whitby, ON</font>",
"<font color='{col}' >\"Just talking to Dan a few times last year was enough to get me on a plane from Ottawa to Chicago. Since then, I have flown eight times, changed careers and I’m even talking with my boyfriend about taking a trip to Asia!\" <br />&#8212; Amanda, Ottawa, ON</font>",
"<font color='{col}' >\"I asked Dan to coach me around writing a movie script. Thanks to structures and practices I created from his coaching, in less than 6 weeks it was completed and picked up by the producers!\" <br />&#8212; Melissa, Toronto, ON</font>",
"<font color='{col}' >\"I have been dreaming of becoming a successful country music songwriter for years. With Dan's coaching, I have produced results that I once believed would take years to produce.\" <br />&#8212; Dave, Oshawa, ON</font>",
"<font color='{col}' >\"Dan is to coaching and the transformation of humanity what Bill Gates is to computers and the transformation of technology. Dan connects people to powerful living with communication technology.\" <br />&#8212; Rafiq, Toronto, ON</font>"
);

var bgcolor = "#ACCBEA";
var fcolor = "#1C1E5F";
var steps = 20; // smoothness
var show = 10000; // 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);
}