var toc = new Array ();
toc[0]="la_voie";
toc[1]="le_bateau_aquarium";
toc[2]="la_cale";
toc[3]="le_triptyque";
toc[4]="le_chaudron";
toc[5]="la_naissance";
toc[6]="la_metamorphose";
toc[7]="le_repas";
toc[8]="la_constellation";
toc[9]="le_bain";
toc[10]="l_aveu";
toc[11]="la_combe";
toc[12]="le_pensionnat";
toc[13]="la_goelette";
toc[14]="la_nuit";
toc[15]="le_miracle";
toc[16]="l_equipage";
toc[17]="l_orchestre";
toc[18]="la_partition";
toc[19]="l_astrolabe";
toc[20]="la_derniere_lettre",
toc[21]="l_heure";
toc[22]="la_medaille";
toc[23]="le_capitaine";

var tocT= new Array
(
	"La Voie",
	"Le Bateau-Aquarium",
	"La Cale",
	"Le Triptyque",
	"Le Chaudron",
	"La Naissance",
	"La Métamorphose",
	"Le Repas",
	"La Constellation",
	"Le Bain",
	"L'Aveu",
	"La Combe",
	"Le Pensionnat",
	"La Goélette",
	"La Nuit",
	"Le Miracle",
	"L'Equipage",
	"L'Orchestre",
	"La Partition",
	"L'Astrolabe",
	"La Dernière Lettre",
	"L'Heure",
	"La Médaille",
	"Le Capitaine"
)
function goHome()
{
	window.location.replace("index.html");
}
function goFirst()
{
	s=eval("toc["+0+"]");
	s+=".html";
	window.location.replace(s);
}
function goPrevious()
{
	var cur = getCurrentIndex();
	if (cur == -1) {
		window.alert("error goPrevious");
		return;
	}
	if (cur == 0) {
		goHome();
		return;
	}
	prev=cur-1;
	s=eval("toc["+prev+"]");
	s+=".html";
	window.location.replace(s);
}
function goNext()
{
	var cur = getCurrentIndex();
	if (cur == -1) {
		window.alert("error goNext");
		return;
	}
	if (cur == (toc.length -1)) {
		goHome();
		return;
	}
	next=cur+1;
	s=eval("toc["+next+"]");
	s+=".html";
	window.location.replace(s);
}
function goTOC()
{
	window.location.replace("toc.html");
}
function getCurrentIndex()
{
	var loc= new String(document.location);
	for (var i=0; i < toc.length; i++){
		var pat = eval('/' + toc[i] +'/')
		result = loc.search(pat);
		if (result >= 0) {
			return i;
		}
	}
	return -1;
}
function writeChapterTitle()
{
	document.write(getChapterTitle());	
}
function getChapterTitle()
{
	var cur=getCurrentIndex();
	if (cur == -1) return "";
	return tocT[cur];
}
function initDocument()
{
	document.title="Zelsa - " +getChapterTitle(); 
}
function showToc()
{
	s="<table>";
	for (var i=0;i<toc.length;i++) {
		s+="<tr><td>"+eval("toc["+i+"]")+"</td></tr>";
	}
	s+="</table>";
	window.alert(s);
}
function openInWindow(url)
{
	myWin = window.open(url);
}
