/*****************************************
Script produced by Ben Fischer
Ben Solutions - Internetservices.
Bern, Switzerland
http://www.ben-solutions.ch
*****************************************/

// Insert the text to appear
var texts = new Array(
 "<font size='5' color='#000000' face='Helvetica'><br> <strong>Zfone lets you whisper <br>in someone's ear from <br> a thousand miles away.</strong><sup><font size='-1'>&trade;</font></sup></font> <br><br> <font size='4' color='{COLOR}' face='Times, serif'><br>Zfone can stop others from <br> intercepting your Internet phone calls.</font>"

,"<font size='5' color='#000000' face='Helvetica'><br> <strong>Zfone lets you whisper <br>in someone's ear from <br> a thousand miles away.</strong><sup><font size='-1'>&trade;</font></sup></font> <br><br> <font size='4' color='{COLOR}' face='Times, serif'><br>Zfone and its innovative encryption technology <br>sets the standard for securing VoIP phone calls.</font>"

,"<font size='5' color='#000000' face='Helvetica'><br> <strong>Zfone lets you whisper <br>in someone's ear from <br> a thousand miles away.</strong><sup><font size='-1'>&trade;</font></sup></font> <br><br> <font size='4' color='{COLOR}' face='Times, serif'><br>Zfone enables you to have a <em>private</em> conversation <br>any time you want with anyone, anywhere - <br>without buying a plane ticket.</font>"

,"<font size='5' color='#000000' face='Helvetica'><br> <strong>Zfone lets you whisper <br>in someone's ear from <br> a thousand miles away.</strong><sup><font size='-1'>&trade;</font></sup></font> <br><br> <font size='4' color='{COLOR}' face='Times, serif'><br>\"Think different. That's what Phil did when <br>he came up with a much better way, <br>the right way, to encrypt VoIP.\"<br><font size='2'> - Jeff Pulver</font>"

,"<font size='5' color='#000000' face='Helvetica'><br> <strong>Zfone lets you whisper <br>in someone's ear from <br> a thousand miles away.</strong><sup><font size='-1'>&trade;</font></sup></font> <br><br> <font size='4' color='{COLOR}' face='Times, serif'><br>\"Zfone brings badly needed VoIP encryption <br>to the masses, in an open, easy-to-use, <br>and secure way. It's about time.\"<br><font size='2'> - Bruce Schneier</font>"

,"<font size='5' color='#000000' face='Helvetica'><br> <strong>Zfone lets you whisper <br>in someone's ear from <br> a thousand miles away.</strong><sup><font size='-1'>&trade;</font></sup></font> <br><br> <font size='3' color='{COLOR}' face='Times, serif'><br>\"VoIP is a great advance for corporate and personal <br>communication, except VoIP conversations can be <br>intercepted by competitors and criminals with IT skills. <br>With Zfone such intercepts cannot take place.\"<br><font size='2'> - Richard A. Clarke</font>"

);

var bgcolor = "#FFFFFF"; // Hintergrundfarbe in Hexformat
var fcolor =  "#000000"; // Vordergrund- (Schrift-) farbe
// var show = 5000; // Anzeigedauer in Millisekunden pro Nachricht --> deprecated, see get_show_timeout()
var sleep = 50; // Pause in Millisekunden zwischen den Nachrichten
var steps = 20; // Anzahl Schritte des Fading- Vorgangs
var loop = true; // true = Endlosschleife, false = stop nach einem Zyklus

// ab hier nichts mehr ändern
//Browser Sniffer
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var mozup = (!document.all && document.getElementById) ? 1 : 0;

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

// get_show_timeout: returns timeout based on the length of displayed text
function get_show_timeout(txt){
	var timeout_per_symbol = 18; // timeout in msec
	return txt.length * timeout_per_symbol;
}

// fade: magic fader function
function fade() {

// insert fader color into message
var text_out = texts[text].replace("{COLOR}", colors[color]); // texts should be defined in user script, e.g.: var texts = new Array("<font color='{COLOR}' sized='+3' face='Arial'>Message goes here</font>");

// get "show" timeout
show = get_show_timeout(text_out);

// actually write message to document
if (ie4up) {
extracontainer1.innerHTML = text_out;
}
if (ns4up) {
document.extracontainer1.document.write(text_out); document.extracontainer1.document.close();
}
if (mozup) {
document.getElementById("extracontainer1").innerHTML = text_out;
}

// select next fader color
color += step;

// completely faded in?
if (color >= colors.length-1) {
step = -1; // traverse colors array backward to fade out

// stop at last message if loop=false
if (!loop && text >= texts.length-1) return; // loop should be defined in user script, e.g.: var loop=true;
}

// completely faded out?
if (color == 0) {
step = 1; // traverse colors array forward to fade in again

// select next message
text += 1;
if (text == texts.length) text = 0; // loop back to first message
}

// subtle timing logic...
setTimeout("fade()", (color == colors.length-2 && step == -1) ? show : ((color == 1 && step == 1) ? sleep : 50)); // sleep and show should be defined in user script, e.g.: var sleep=30; var show=500;
}
// getFadeColors: fills Colors (predefined Array)
// with color hex strings fading from ColorA to ColorB

// note: Colors.length equals the number of steps to fade
function getFadeColors(ColorA, ColorB, Colors) {
len = Colors.length;

// strip '#' signs if present
if (ColorA.charAt(0)=='#') ColorA = ColorA.substring(1);
if (ColorB.charAt(0)=='#') ColorB = ColorB.substring(1);

// substract rgb compents from hex string
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));

// calculate size of step for each color component
var rStep = Math.round((r2 - r) / len);
var gStep = Math.round((g2 - g) / len);
var bStep = Math.round((b2 - b) / len);


// fill Colors array with fader colors
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; // make sure we finish exactly at ColorB
}

// IntToHex: converts integers between 0-255 into a two digit hex string.
function IntToHex(n) {
var result = n.toString(16);
if (result.length==1) result = "0"+result;
return result;
}

// HexToInt: converts two digit hex strings into integer.
function HexToInt(hex) {
return parseInt(hex, 16);
}

// body tag must include: onload="fade()" bgcolor="#000000" where bgcolor equals bgcolor in javascript above