var idx = -2;
var t1 = 80;
var r = 255;
var g = 255;
var b = 255;

function fade_in(fx,fy) {
	if (r>107) {
		r-=10; 
		if (r<115) { r=107; }
		g-=10;
		if (g<135) { g=132; }
		b-=10;
		if (b<155) { b=150; }

		document.getElementById(fx).style.color="rgb("+r+","+g+","+b+")";
		document.getElementById(fy).style.color="rgb("+r+","+g+","+b+")";

		setTimeout("fade_in(fx,fy)", t1);	
	} 
}

function fade_out(fx,fy) {
	if (r<255) {
		r+=10;
		if (r<118) { r=115; }
		g+=10;
		if (g<143) { g=135; }
		b+=10;
		if (b<161) { b=155; }

		document.getElementById(fx).style.color="rgb("+r+","+g+","+b+")";
		document.getElementById(fy).style.color="rgb("+r+","+g+","+b+")";
			
		setTimeout("fade_out(fx,fy)", t1);
	}
}

function init_rand(N) {
	// range set by # of quotes
	if (Math.random) {
		idx = Math.floor(Math.random()*N);
	}
	else {
		var now = new Date();
		idx = (now.getTime() / 1000) % N;
	}
}

function changetext(which){
	if (!document.getElementById) return;

	whichid = "fader" + "0";
	fx = "a1";
	fy = "a2";
	var frst = 0;
	num_qts = 19;
	if (idx<-1) { init_rand(num_qts); frst=1; }

switch (idx) {
case 0:
	q = "ProxyPass is a  system admin's dream come true ... reduced overall BW & increased server performance";
	s = "ClubJenna Inc.";
	break;
case 1:
	q = "Best of all, I've never called support and gotten a 'tech' just returning from a 4:20 break";
	s = "Cyberheat Inc. / TopBucks";
	break;
case 2:
	q = "Seconds after installing, our site was faster, more responsive & blocking compromised accounts";
	s = "Penthouse";
	break;
case 3:
	q = "Our load-balanced cluster is secured by ProxyPass & we can happily say we don't have any problems";
	s = "Platinum Bucks";
	break;
case 4:
	q = "Overwhelmingly successful in protecting our sites ... we couldn't live without it";
	s = "Lightspeed Cash";
	break;
case 5:
	q = "Top product of its kind on the market ... stops attacks and traders before they cause slowdowns";
	s = "SIC Cash / ExecutiveStats";
	break;
case 6:
	q = "Support staff is prompt, friendly & VERY knowedgeable ... amazed to report ZERO problems";
	s = "Twistys";
	break;
case 7:
	q = "Our monthly bandwidth bill went down by thousands of $$ and our sites perform much more efficiently";
	s = "LFP / Hustler";
	break;
case 8:
	q = "A \"remarkable\" piece of software ... saved us a tremendous amount of $$ in BW and time";
	s = "MediumPimpin";
	break;
case 9:
	q = "Prevents hack attacks, improves performance & lowers costs ... highly recommend this software";
	s = "Hegre Archives";
	break;
case 10:
	q = "Thanks for the quick service you always give us -- it is much appreciated";
	s = "Cavecreek / CWIE LLC";
	break;
case 11:
	q = "ProxyPass was the best solution ... I know their support team is there to help me";
	s = "FTV Cash";
	break;
case 12:
	q = "Operating flawlessly on our servers ... strong reputation for very high customer satisfaction";
	s = "Reliablehosting";
	break;
case 13:
	q = "Save BW costs, increase revenue & never worry about trading or brute force attacks again";
	s = "Jason & Alex";
	break;
case 14:
	q = "ProxyPass allowed us to protect clients' content, entice new members & increase conversions";
	s = "Adult Branding";
	break;
case 15:
	q = "Proxigence customer service is first rate, and their knowledge of web infrastructure is unparalleled";
	s = "LFP / Hustler";
	break;
case 16:
	q = "Truly excellent!  Increased performance & reduced bandwidth ... a must for any serious business";
	s = "Panchodog";
	break;
case 17:
	q = "Quick installs, timely support & great products ... thank you for taking care of your clients so well";
	s = "Mojohost";
	break;
case 18:
	q = "You are sure fast & efficient -- and superb in all your help.  Many thanks!";
	s = "Ron Harris";
	idx=-1;
	break;
}

	idx++;

	q = "<div id=" + fx + " class=\"RefQt\">\"" + q + "\"</div>";
	s = "<div id=" + fy + " class=\"RefSrc\">" + s + "</div>";

	if (frst==1) {
		t2 = num_qts*t1;
		delay_fade_in();
	}
	else {
		t2 = 2*num_qts*t1;
		fade_out(fx,fy); 
		setTimeout("delay_fade_in()",num_qts*t1);
	}

	// Javascript setTimeout does not halt execution, so important that t2 > (2*N*t1), where N is from the # of fading iterations/quotes.
	t2 += 5000;
	setTimeout("changetext("+which+")", t2);
}

function delay_fade_in() {
	document.getElementById(whichid).innerHTML= q + s;
	fade_in(fx,fy);
}

//	If we want to change rotation time based on quote string length
//	var newQuote = document.getElementById(whichid).innerHTML;
//	var t = 1000 * .02 * newQuote.length;
//	if (t < 8000) { t = 8000; }
