﻿var hex = 220;
var i = 0;
function fadetext(){ 
if(hex>50) { //If color is not black yet
	hex-=5; // increase color darkness
	document.getElementById("dynTxt_txt").style.color="rgb("+hex+","+hex+","+hex+")";
	document.getElementById("dynTxt_loc").style.color="rgb("+hex+","+hex+","+hex+")";
	setTimeout("fadetext()",50);}
else{// get a random number for i
	var z = Math.floor(Math.random()*(arFacilityName.length))
	if (i == z){i++;} // not so random
	else{i = z;}
	hex=220 //reset hex value
	// check if we're past the end of the list
	if (i >= arFacilityName.length){i = 0;} // reset loop
	setTimeout("changeElement(i)", 3000);}
}

function changeElement(y){
	if (arFacilityName[y].length > 23){document.getElementById("dynTxt_txt").className = "dynTxt_smtxt";}
	else {document.getElementById("dynTxt_txt").className = "dynTxt_txt";}
	document.getElementById("dynTxt_txt").innerHTML = arFacilityName[y];
	document.getElementById("dynTxt_txt").href = arFacilityURL[y];
	document.getElementById("dynTxt_loc").innerHTML = arFacilityLoc[y];
	document.getElementById("dynTxt_loc").href = arFacilityURL[y];
	fadetext();
}