/////////////////////////////////////// BOOKMARKING /////////////////////////////////////// 
//This function bookmarks the page or issues a message of how to do it
function BookmarkPage (url, title) {
	var ver = navigator.appName;
	var num = parseInt(navigator.appVersion);
	if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) window.external.AddFavorite(location.href,document.title);
	else alert ("Please press Ctrl-D to bookmark this page");
} 

/////////////////////////////////////// CONTENTS MENU /////////////////////////////////////// 
//This function is used in the contents menu to open and close a section. It stores the currently
//open top level section as well, so it can be closed when we move to a new top level section.
// modified by Chris 10.10.05
var TOPSECTION = null; //the currently open main section
function ToggleContents (id) {
	var section = document.getElementById ("section" + id); //the newly opened section
	section.className = (section.className == "opensection") ? "section" : "opensection"; //set my class
	var top = section.parentNode;
	for(var i in top.childNodes) {
		if(top.childNodes[i]!=section) top.childNodes[i].className = "section";
	}
}

//FAQ list functions
function showFaq(n) {
	var question = document.getElementById("a"+n);
	question.className = question.className=="a" ? "aopen" : "a";
	for(var i=1;i<20;i++) {
		if(i!=n && document.getElementById("a"+i)) document.getElementById("a"+i).className = "a";
	}
}

// History popup functions
function showHistory() {
	document.getElementById('history').style.display="block";
	historyActive = 1;
}
function hideHistory() {
	document.getElementById('history').style.display="none";
	historyActive = 0;
}

/////////////////////////////////////// KEYWORDS PAGE /////////////////////////////////////// 
//These functions are for dealing with the keywords list. The page must have a keywordform with elements
//keywordbox and a drop down keywordlist.
//Initialise the keywords page
function InitialiseKeywords (f, val) {
	f.keywordbox.value = val ? val : "Start typing to search for a word";
	f.keywordbox.select();
	f.keywordlist.selectedIndex = 0;
}
//Remember the key pressed in Firefox
var KEYCODE=0; function RememberKey (event) {KEYCODE = event.which;}
//Reset the key word in the box when the selected changes
function ResetKeyword (box, list) {box.value = list.options[list.selectedIndex].text; box.focus();}
//Find a keyword whenever a key is typed into the keyword box
function FindKeyword (box) {
	var key = window.event ? window.event.keyCode : KEYCODE; //get the key code in IE and Firefox
	var list = box.form.keywordlist; //the keyword list element
	if (key == 40) {list.selectedIndex = list.selectedIndex+1; ResetKeyword (box, list);}
	else if (key == 38) {list.selectedIndex = list.selectedIndex-1; ResetKeyword (box, list);}
	else if (box.value) {
		for (var i=0; i<list.options.length; i++) {
			var to = list.options[i].text.toUpperCase();
			if (to.indexOf (box.value.toUpperCase())==0) {list.selectedIndex = i; break;}
		}
	}
	else InitialiseKeywords (box.form);
}

// history variables 
historyActive = 0;
document.onclick = function () { if(historyActive) hideHistory(); }

