

// ---------- script properties ----------

var include_num = 1;
var bold = 0;

// ---------- sites ----------


var s = new Array();

s[0] = "Global Environment Quiz^index#quiz^Test your knowlegde of the environment with the Global Environment Quiz. There are 20 questions in total.^questions, quiz, global environment quiz, test";
s[1] = "Tell a friend about the this website^index#tell^Do you like this website and want to tell someone about it? Do you want to get them involved in helping to protect the environment?^ tell a friend, e-mail, friends";
s[2] = "News - GM crops 'will help wildlife'^News.htm^The Global Environment - News. <br><br>Wednesday, 15 January, 2003.GM crops 'will help wildlife'.<br><br>Genetically modified crops could be a key way to help endangered species, according to research funded in part by a biotechnology company.^News, genetics, genetically modified, GM crops, wildlife";
s[3] = "News - Climate changes disrupt birds^News1.htm^The Global Environment - News. <br><br>Wednesday, 15 January, 2003. Climate changes disrupt birds.<br><br>Shifts in spring temperatures in central Europe may be having a significant effect on the ability of birds to breed successfully.^News, bireds, climate change";
s[4] = "Biodiversity^Biodiversity.htm^The Global Environment - Biodiversity.<br><br> Biodiversity is the ...^Biodiversity";
s[5] = "News - 'Corruption' in Indonesia logging war^News2.htm^The Global Environment - News. <br><br>Saturday, 11 January, 2003.'Corruption' in Indonesia logging war<br><br>Rampant corruption in Indonesia is hampering attempts to tackle illegal logging, according to an environmental group.^News, logging, corruptoion, deforestation, Indonesia";
s[6] = "News - Rare birds fall prey to botulism ^News3.htm^The Global Environment - News. <br><br>Saturday, 11 January, 2003.Rare birds fall prey to botulism <br><br>Avian botulism in Taiwan has killed more than 7% of the world's black-faced spoonbills in the last month.^News, rare birds, botulism, avian, Taiwan, spoonbills, black-faced spoonbills";
s[7]= "Latest News - Red alert over rare species^LatestNews.htm^The Global Environment - News.<br><br>Thursday, 16 January, 2003.Red alert over rare species.<br><br>The well-known Red List that details which species are threatened with extinction is inaccurate, according to a new assessment. It concludes the list fails to reflect the true threat to species, by not taking full account of the threat posed by people.^red list, rare species, news, extinction, species threat";

// ---------- end of script properties and sites ----------


var cookies = document.cookie;
var p = cookies.indexOf("d=");

if (p != -1) {
	var st = p + 2;
	var en = cookies.indexOf(";", st);
	if (en == -1) {
		en = cookies.length;
	}
	var d = cookies.substring(st, en);
	d = unescape(d);
}
var od = d;
var m = 0;
if (d.charAt(0) == '"' && d.charAt(d.length - 1) == '"') {
	m = 1;
}

var r = new Array();
var co = 0;

if (m == 0) {
	var woin = new Array();
	var w = d.split(" ");
	for (var a = 0; a < w.length; a++) {
		woin[a] = 0;
		if (w[a].charAt(0) == '-') {
			woin[a] = 1;
		}
	}
	for (var a = 0; a < w.length; a++) {
		w[a] = w[a].replace(/^\-|^\+/gi, "");
	}
	a = 0;
	for (var c = 0; c < s.length; c++) {
		pa = 0;
		nh = 0;
		for (var i = 0; i < woin.length; i++) {
			if (woin[i] == 0) {
				nh++;
				var pat = new RegExp(w[i], "i");
				var rn = s[c].search(pat);
				if (rn >= 0) {
					pa++;
				} else {
					pa = 0;
				}
			}
			if (woin[i] == 1) {
				var pat = new RegExp(w[i], "i");
				var rn = s[c].search(pat);
				if (rn >= 0) {
					pa = 0;
				}
			}
		}
		if (pa == nh) {
			r[a] = s[c];
			a++;
		}
	}
	co = a;
}

if (m == 1) {
	d = d.replace(/"/gi, "");
	var a = 0;
	var pat = new RegExp(d, "i");
	for (var c = 0; c < s.length; c++) {
		var rn = s[c].search(pat);
		if (rn >= 0) {
			r[a] = s[c];
			a++;
		}
	}
	co = a;

}


function return_query() {
	document.Form1.d.value = od;
}

function num_jse() {
	document.write(co);
}

function out_jse() {
	if (co == 0) {
		document.write('Your search did not match any documents.<p>Make sure all keywords are spelt correctly.<br>Try different or more general keywords.');
		return;
	}
	for (var a = 0; a < r.length; a++) {
		var os = r[a].split("^");
		if (bold == 1 && m == 1) {
			var br = "<b>" + d + "</b>";
			os[2] = os[2].replace(pat, br);
		}
		if (include_num == 1) {
			document.write(a + 1, '. <a href="', os[1], '">', os[0], '</a><br>', os[2], '<p>');
		} else {
			document.write('<a href="', os[1], '">', os[0], '</a><br>', os[2], '<p>');
		}
	}

}
