
var Captions = new Array();
var URLs = new Array();

Captions.push('Introduction');
URLs.push('index.htm');
Captions.push('Sequitur Example 1');
URLs.push('sqeg1.htm');
Captions.push('Rhubarb Example 1');
URLs.push('rheg1.htm');
Captions.push('Making a Rhubarb exercise');
URLs.push('makingrh.htm');
Captions.push('Making a Sequitur exercise');
URLs.push('makingsq.htm');
Captions.push('Sequitur Example 2');
URLs.push('sqeg2.htm');
Captions.push('Rhubarb Example 2');
URLs.push('rheg2.htm');
Captions.push('Using Unicode');
URLs.push('unicode.htm');
Captions.push('Summary');
URLs.push('summary.htm');

function WriteMenu(){
	var Output = '<h3>Contents</h3><ul>';
	var CurrPage = false;
	var NextButton = '';
	for (var i=0; i<Captions.length; i++){
 		if (CurrPage==true){ //last one was current
			NextButton = CreateItem('Next', 'Next=&gt;', URLs[i]);
		}
		CurrPage = IsCurrentPage(URLs[i]);
		if (CurrPage == true){
			Output += CreateItem('Current', Captions[i], URLs[i]);
		}
		else{
			Output += CreateItem('Normal', Captions[i], URLs[i]);
		}
	}
	Output += NextButton;
	Output += '</ul>';
	if (document.getElementById('TheMenu') != null){
		document.getElementById('TheMenu').innerHTML = Output;
	}
}

function CreateItem(Type, Caption, URL){
	var Output = '<li';
	if (Type == 'Current'){
		Output += ' class="CurrentMenuItem"';
	}
	if (Type == 'Next'){
		Output += ' class="NextMenuItem"';
	}
	Output += ' onmouseover="MenuEnter(this)" onfocus="MenuEnter(this)" onmouseout="MenuLeave(this)" onblur="MenuLeave(this)" onclick="location=\'' + URL + '\'" title="' + Caption + '"><a href="' + URL + '">' + Caption + '</a></li>\n';
	return Output;
}

function IsCurrentPage(URL){
	var Pos = document.location.href.indexOf(URL);
	if (Pos == document.location.href.length - (URL.length)){
		return true;
	}
	else{
		return false;
	}
}

function MenuEnter(El){
	El.style.borderColor = '#ffffff';
}

function MenuLeave(El){
		El.style.borderColor = '#000000';
}