﻿//1. Partie paramétrable
//2. Partie commune toutes chartes
//3. Partie visuelle commune chartes semblables
//4. Partie visuelle spécifique

//////////////////////////////// 1. Partie paramétrable

var charte_nomSite='Info-Bible';
//var charte_baseHref='http://172.23.208.70/www/cours_web/';
//var charte_baseRep='D:\\document\\bureau\\www\\cours_web\\';
//var charte_emailHref='mai'+'lto:webmaster'+'&#64;'+'info-bible.org';
//var charte_emailText="Contact";


//Si pas d'onglets ne conserver que les 2 lignes ci-dessous (décommenter la première)
//var charte_dossiers=new Array();

charte_plan=new Array();
// Contenu de chaque onglet par paire d'éléments "fichier lié", "libellé")
// la première paire est celle du sommaire de l'onglet
// Si plusieurs paires: renseignera liens transversaux et plan du site
charte_plan['Epopée vaudoise']=new Array('epopee.vaudoise/index.htm','Sommaire','epopee.vaudoise/couverture.htm','Couverture','epopee.vaudoise/la-voix-parfaite.htm','La voix parfaite','epopee.vaudoise/merindol.htm','Mérindol','epopee.vaudoise/janavel.htm','Janavel','epopee.vaudoise/table-matieres.htm','Table des matières','epopee.vaudoise/dos-couverture.htm','Dos couverture','epopee.vaudoise/commander.htm','Commander','annexes.vaudois/index.htm','Annexes');
charte_plan['Annexes']=new Array('annexes.vaudois/index.htm','Sommaire','annexes.vaudois/1.catechisme-vaudois.htm','Catéchisme Vaudois','annexes.vaudois/2.noble-lecon.htm','noble lecon','annexes.vaudois/3.traite-antichrist.htm','traité antichrist','annexes.vaudois/4.origine-vaudois.htm','origine vaudois','annexes.vaudois/5.temoignage-inquisiteur-sacco.htm','témoignage inquisiteur Sacco','annexes.vaudois/6.preface-Ruben-Saillens.htm','préface Ruben Saillens','annexes.vaudois/7.sites-vaudois.htm','sites vaudois','annexes.vaudois/8.noms-famille-vaudois.htm','noms famille vaudois','annexes.vaudois/9.en-savoir-plus.htm','en savoir plus');




charte_plan['Histoire des Vaudois 1']=new Array('Histoire.Eglise.Vaudoise.1/index.htm','Sommaire');
for (i=1;i<=25 ;i++ ) //manque 01.htm
{
	charte_plan['Histoire des Vaudois 1'][2*i]='Histoire.Eglise.Vaudoise.1/'+(i<10?'0':'')+i+'.htm';
	charte_plan['Histoire des Vaudois 1'][2*i+1]='page '+(i-1);
};
charte_plan['Histoire des Vaudois 1'][2*i]='Histoire.Eglise.Vaudoise.2/index.htm';
charte_plan['Histoire des Vaudois 1'][2*i+1]='Tome 2';

charte_plan['Histoire des Vaudois 2']=new Array('Histoire.Eglise.Vaudoise.2/index.htm','Sommaire');
for (i=1;i<=18 ;i++ )
{
	charte_plan['Histoire des Vaudois 2'][2*i]='Histoire.Eglise.Vaudoise.2/'+(i<10?'0':'')+i+'.htm';
	charte_plan['Histoire des Vaudois 2'][2*i+1]='page '+(i-1);
};


////////////////////////////// 2. Partie commune toutes chartes

//Variables transmises par la page
var dossier; //onglet
var rubrique; // Texte associé au lien retour
var niveau;
var retour; // url proposée pour suite
var sommaire;

var charte_chemin=location.pathname; //sans le http:// et le ?search attention aux \ et au / ...
charte_chemin=charte_chemin.replace(/\\/g , "/"); 


if (charte_chemin.substring(charte_chemin.length-1,charte_chemin.length)=='/') location.href=charte_chemin+'index.htm';	

// Standardisation JavaScript

function charte_standard() {
	if (!document.styleSheets[0].addRule) {
		document.styleSheets[0].addRule = new Function('element','regle', 'this.insertRule(element +" {"+ regle +"}",this.cssRules.length )');
	}
}
if (!document.getElementById && document.all) document.getElementById = new Function('id', 'return document.all[id]') 

//permet de simuler l'objet event du W3C
function standardizeEvent(e) { 

	if (!e.stopPropagation) 
		e.stopPropagation = new Function('this.cancelBubble = true') 

	if (!e.preventDefault) 
		e.preventDefault = new Function('this.returnValue = true') 

	if (typeof e.layerX == 'undefined' && typeof e.offsetX == 'number') 
		{e.layerX = e.offsetX; e.layerY = e.offsetY } 

	if (typeof e.pageX == 'undefined' && typeof e.x == 'number') 
		{e.pageX = e.x+document.body.scrollLeft; e.pageY = e.y+document.body.scrollLeft } 

	if (!e.target && e.srcElement) { 
		e.target = e.srcElement 
		if (e.type == 'onmouseout')
			e.relatedTarget = e.toElement
		else if (e.type == 'onmouseover')
			e.relatedTarget = e.fromElement 
	} 

}

//Valeurs par défaut 

if (typeof (dossier)=="undefined" && (typeof (rubrique)=="undefined")) dossier=charte_nomSite;
if (typeof (rubrique)=="undefined") rubrique=dossier;
if (typeof (dossier)=="undefined") dossier=rubrique;
if (typeof (niveau)=="undefined") niveau='../';
if (typeof (sommaire)=="undefined") {
	if (charte_chemin.substring(charte_chemin.length-9,charte_chemin.length-4)=='index') sommaire=true;	
	else sommaire=false;
} 


////////////////////////////// 3. Partie commune chartes projection + livres

// Le dossier définit le titre du livre et les chapitres sont donnés par livre=charte_plan[dossier]
// livre=charte_plan['Internet']=new Array('internet.htm','Internet','web.htm','le Web','mail.htm','Le mail','virus.htm','Les virus');
var livre;
if (charte_plan[dossier])
	livre=charte_plan[dossier];
else livre=new Array();



//Détermination de l'indice de la page courante dans le livre (modulo 2)
var ind_page_courante=-2; //Si inconnu -> retour au sommaire
for (var i=0;i<livre.length ;i+=2)
	if (livre[i]==charte_chemin.substring(charte_chemin.length-livre[i].length)) ind_page_courante=i;




////////////////////////////// 4. Partie commune chartes projection


function page_sommaire()
{
		if (livre[0]) location=niveau+livre[0]+"#toc";
}

function page_suivante()
{
		if (ind_page_courante<livre.length-2) location=niveau+livre[ind_page_courante + 2];
}

function page_precedente()
{
		if (ind_page_courante>0) location=niveau+livre[ind_page_courante -2];
}



function init() {
	//document.onmousedown = mouseDown
	//document.onmousemove = mouseMove
	//document.onmouseup = mouseUp
	document.onclick = click
	document.onkeydown = keyDown
	if (navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP | Event.KEYDOWN)
}
init();


//Astuce pour mettre à jour indiceAncreCourante en cas de click sur lien interne
function click(event) {
	setTimeout('click2()',100);
}

function click2() {
		//alert(location.hash)
		if (location.hash.length>1) 
			indiceAncreCourante=determinerIndiceAncre(location.hash);
}



function keyDown(event) {
	event=document.all?window.event:event;
	standardizeEvent(event);
	//Attention: seul realkey identique entre NN et IE pour A-Z
	//Pavé numérique: IE: code=96+chiffre anciens NN: touche=chiffre
	keycode=event.keyCode;
	var realkey = (String.fromCharCode(keycode)).toUpperCase();
    if (keycode>95 && keycode<106) realkey=keycode-96;
	// your code goes here
	window.status='Touche='+realkey+' code='+keycode;
	//alert('Touche='+realkey+' code='+keycode);
	if (realkey=='0')
		if (indiceAncreCourante<document.anchors.length-1)
			{location="#"+document.anchors[++indiceAncreCourante].name;}
		else
			{page_suivante();}
	else if (realkey=='1' && indiceAncreCourante>0)
		{location="#"+document.anchors[--indiceAncreCourante].name;}
	else if (realkey=='2')
		{liste_ancres();}
	else if (realkey=='8')
		{liste_pages();}
	else if (realkey=='4')
		{page_precedente();}
	else if (realkey=='5')
		page_sommaire();
	else if (realkey=='6') 
		page_suivante();
	event.stopPropagation();
	return true;

}

function determinerIndiceAncre(nomAncre)
{
	for (i=0;i<document.anchors.length ; i++)
		if ('#'+document.anchors[i].name==nomAncre)
			return i;
	return 0;
}

indiceAncreCourante=0


function liste_ancres() {

l_table='';
//Table des matières dynamique

for (i=0;i<document.anchors.length ; i++)
{
	nom=document.anchors[i].name
	ancre='#'+nom;
	l_onclick="aller('"+ancre+"')";
	l_table+='<li><a href="'+ancre+'" onclick="'+l_onclick+'">'+nom+'</a>';
}

document.open()
document.writeln('<LINK href='+niveau+'charte/style.css type=text/css rel=STYLESHEET>');
document.writeln('<h1>Liens internes</h1>');
document.writeln('<ul class=carre>');
document.writeln(l_table);
document.writeln('</ul>');
document.close()
}


function aller(cible) {
	setTimeout('location="'+cible+'"',200);
	alert('timer positionne');
	history.back();
}



function liste_pages() {

l_table='';
//Table des matières dynamique

for (var i=0;i<livre.length ;i+=2)
{
	lien=livre[i]
	nom=livre[i+1]
	l_table+='<li><a href="'+niveau+lien+'">'+nom+'</a>';
}

document.open()
document.writeln('<LINK href='+niveau+'charte/style.css type=text/css rel=STYLESHEET>');
document.writeln('<h1>Table des matières</h1>');
document.writeln('<ul class=carre>');
document.writeln(l_table);
document.writeln('</ul>');
document.close()
}





////////////////////////////////////// Entete Barre de navigation

var html_precedent='';
var html_suivant='';
var html_arborescence='';

if (ind_page_courante>0) html_precedent='<a href="'+niveau+livre[ind_page_courante - 2]+'"><img src="'+niveau+'charte/gauche.gif" alt="'+(livre[ind_page_courante -1])+'" border="0"></a>&nbsp;';
if (ind_page_courante<livre.length-2) html_suivant='<a href="'+niveau+(livre[ind_page_courante + 2])+'"><img src="'+niveau+'charte/droite.gif" alt="'+(livre[ind_page_courante + 3])+'" border="0"></a>';


html_arborescence+='<A HREF="'+niveau+'index.htm">Livres</A>';
html_arborescence+=' &gt; ';
html_arborescence+='<A HREF="javascript:page_sommaire()">'+dossier+'</A>';



//Table qui contient le corps du ducument
document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
document.writeln('<table width=100%  style="table-layout:fixed" border=0 height=100% cellpading=5 cellspacing=0>');
document.writeln('<TR class=navigation height=20><TD>');
document.writeln('<A NAME="haut"></A>');
document.writeln(html_arborescence);
document.writeln('<TD ALIGN=RIGHT>');
document.write(html_precedent);
document.writeln(html_suivant);


document.writeln('<tr><TD valign=top colspan=2><hr>');
