var isLayers = 0;
var isAll = 0;
var isDHTML = 0;
var dom = null;

if (document.layers) {
	isLayers = 1;
	isDHTML = 1;
}

if (document.all) {
	isAll = 1;
	isDHTML = 1;
} 

docObj = (isLayers) ? 'document' : 'document.all'; 
styleObj = (isLayers) ? '' : '.style';
var fadeTimer = null;
var fadeInterval = 60;
var fadeColorStep = 5;
var fadeFontMin = 8;
var fadeFontMax = 48;
var fadeFontStep = 2;
var arrText = new Array();

arrText[0] = "";
arrText[1] = "Alness 1437	1269	1240	1033";
arrText[2] = "Applecross 2892	2861	2709	2239";
arrText[3] = "Avoch 1956	1931	2029	1691";
arrText[4] = "Contin 2023	1770	2562	1422";
arrText[5] = "Cromarty 2900	2662	2727	2009";
arrText[6] = "Dingwall 1159	2100	2364	2220";
arrText[7] = "Edderton 1023 975 890 431";
arrText[8] = "Fearn 1695	1914	2122	2135";
arrText[9] = "Fodderty 2232	2437	2342	2047";
arrText[10] = "Gairloch 4445	4880	5186	4594";
arrText[11] = "Glenshiel 715 745 573 424";
arrText[12] = "Killearnan 1479	1643	1794	1059";
arrText[13] = "Kilmuir-Easter 1556	1486	1437	1146";
arrText[14] = "Kiltearn 1605	1436	1538	1182";
arrText[15] = "Kincardine 1887	2108	1896	1472";
arrText[16] = "Kintail 1240	1186	1009 688";
arrText[17] = "Knockbain 2139	2565	3005	1866";
arrText[18] = "Lochalsh 2433	2597	2299	2050";
arrText[19] = "Lochbroom 4615	4799	4813	4191";
arrText[20] = "Lochcarron 2136	1960	1612	1456";
arrText[21] = "Logie-Easter 934	1015 965 827";
arrText[22] = "Nigg 1404	1426	1457	1000";
arrText[23] = "Resolis (Kirkmichael) 1470	1549	1551	1424";
arrText[24] = "Rosemarkie 1799	1719	1776	1357";
arrText[25] = "Rosskeen 2916	3222	3699	3773";
arrText[26] = "Tain 3078	3128	3754	3009";
arrText[27] = "Tarbat 1809	1826	2151	1878";
arrText[28] = "Urquhart and Logie-Wester	2864	2997	3153	2525";
arrText[29] = "Urray 2768	2716	2621	2474";
arrText[30] = "Barvas 3011	3850	4189	5325";
arrText[31] = "Lochs 3067	3653	4256	6284";
arrText[32] = "Stornoway 5491	6218	8057	10389";
arrText[33] = "Uig 3041	3316	3209	3489";
arrText[34] = "Assynt 3161	3178	2989	2781";
arrText[35] = "Clyne 1711	1765	1933	1812";
arrText[36] = "Creich 2562	2852	2714	2223";
arrText[37] = "Dornoch 3380	2714	2981	2525";
arrText[38] = "Durness 1153	1109	1152 987";
arrText[39] = "Eddrachillis 1965	1699	1576	1525";
arrText[40] = "Farr 2073	2217	2403	1930";
arrText[41] = "Golspie 1149	1214	1529	1556";
arrText[42] = "Kildonan 257 256	2288	1942";
arrText[43] = "Lairg 1045 913	1162	1355";
arrText[44] = "Loth 2234	2281 640 584";
arrText[45] = "Reay 2881	2811	2506	2191";
arrText[46] = "Rogart 1805	1501	1535	1227";
arrText[47] = "Tongue 2030	2041	2018	1929";

function setPosition(elemid) {
	// Select a random position, based on screen width/height
	xmax = 40;		// should get from window size
	ymax = 500;
	x = Math.ceil(Math.random()*xmax);
	y = Math.ceil(Math.random()*ymax);
	st = document.getElementById(elemid).style; 
	st.left = x;
	st.top = y;
}

function stepText(elemid, size, color, step, maxcolor, mincolor) {
	// Changes the size, colour and position of a text object
	dom = document.getElementById(elemid).style; 
	if (step > 0) {
		if (color >= maxcolor) {
			step = -step;	 
		}
	} else {
		if (size < fadeFontMax) {
			size += fadeFontStep;
		} 
		if (color <= mincolor) {
			// Done, do another
			dom.visibility = "hidden";
			fadeText();
			return;
		}
	}
	dom.color = color;
	dom.fontSize = size + 'pt';

	color += step;
	func = "stepText('" + elemid + "', " + size + ", " +
		color + ", " + step + ", " + maxcolor + ", " + mincolor + ")";
	fadeTimer = setTimeout(func, fadeInterval);
}

function fadeText() {
	// Move, fade in and enlarge, then fade out
	elemid = 'fadeText';
	dom = document.getElementById(elemid).style; 
	elem = document.getElementById(elemid);
	setPosition(elemid);
	elem.innerHTML = arrText[Math.ceil(Math.random()*arrText.length)];  
	dom.visibility = "visible";
	color = 0;
	step = (fadeColorStep*256*256) + (fadeColorStep*256) + fadeColorStep;
	size = fadeFontMin;
	dom.color = color;
	dom.fontSize = size + 'pt';
	color += step;
	func = "stepText('" + elemid + "', " + size + ", " +
		color + ", " + step + ", 0xFFFFFF, 0x000000)";
	fadeTimer = setTimeout(func, fadeInterval);
}

