// You can edit this bit

var texts = new Array(
"<font color='{COLOR}'>\"Sex is like Pringles - once you pop you can\'t stop.\"</font>",
"<font color='{COLOR}'>\"I regret some of the things I did before the RA, especially about sex and relationships.\"</font>",
"<font color='{COLOR}'>\"It will change you as a person. The focus is on sex and relationships but you have chance to re-evaluate your life.\"</font>",
"<font color='{COLOR}'>\"During RA I learnt to value who I am and believe that that is enough.\"</font>",
"<font color='{COLOR}'>\"Everyone who took part changed for the better.\"</font>",
"<font color='{COLOR}'>\"There was a balance of people, different opinions, different backgrounds, different personalities.\"</font>",
"<font color='{COLOR}'>\"The leaders ... never told us what we had to think; they just asked us the questions and gave us space to talk.\"</font>",
"<font color='{COLOR}'>\"I gained so much. Just go for it!\"</font>");


var bgcolor = "#FFFFFF"; // background color, must be valid browser hex color (not color names)
var fcolor = "#999999";  // foreground or font color
var steps = 20; // number of steps to fade
var show = 5000; // milliseconds to display message
var sleep = 1000; // milliseconds to pause inbetween messages
var loop = true; // true = continue to display messages, false = stop at last message

// up to here

var colors = new Array(steps);
getFadeColors(bgcolor,fcolor,colors);
var color = 0;
var text = 0;
var step = 1;

function fade() {
var text_out = texts[text].replace("{COLOR}", colors[color]);

if (document.getElementById) document.getElementById('fader').innerHTML = text_out;
else if (document.all) fader.innerHTML = text_out; // document.all = IE only
if (document.layers) { document.fader.document.write(text_out); 
document.fader.document.close(); }

color += step;

if (color >= colors.length-1) {
step = -1; // traverse colors array backward to fade out
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);
}






