//1. Partie parametrable
//2. Partie commune toutes chartes
//3. Partie visuelle commune chartes semblables
//4. Partie visuelle specifique

//////////////////////////////// 1. Partie parametrable

var charte_nomSite='Audio-Gospel';
var charte_baseHref='http://www.audiogospel.ch/';
var charte_baseUtil='/util/';
if (location.host=='localhost') 
	var charte_racineServeurWeb='d:document'; 
else 
	var charte_racineServeurWeb='../..'; 
var charte_emailHref=niveau+'mailto:b.wampfler'+'@audiogospel.ch';
var charte_emailText='b.wampfler'+'@audiogospel.ch';
var charte_classeOutilsAdministration='cache'; // 'cache' => masques, '' => visibles

//Onglets

var charte_dossiers=new Array('Accueil','Pays','Langues','Mat\xE9riel','Ressources','Tour');

charte_plan=new Array();
charte_plan['Accueil']=new Array('index.htm','Accueil','outils/nouveau.htm','Nouveaut\xE9s','outils/plan.htm','Plan du site');
charte_plan['Pays']=new Array('pays/index.htm','Pays','pays/cameroun.htm','Cameroun','pays/canada.htm','Canada (Qu\xE9bec)','pays/france.htm','France','pays/gabon.htm','Gabon');
charte_plan['Langues']=new Array('linguistique/index.htm','Linguistique','langues/index.htm','Sommaire','bn/masters_bn.htm','Masters BN');
charte_plan['Ressources']=new Array( 'liens/index.htm', 'Ressources','liens/grn.htm', 'Site GRN', 'grid/grid.htm','GRID','liens/sites_web.htm','Sites web','liens/ressources.htm','Ressources multilingues');
charte_plan['Mat\xE9riel']=new Array('materiel/index.htm','Mat\xE9riel', 'scripts/index.htm','Scripts','bn/index.htm','Bonne Nouvelle','lll/index.htm','Regarde, \xE9coute et vis','lc/index.htm','Le Christ Vivant' );
charte_plan['Tour']=new Array('tour/index.htm','Tour','accueil/audio-gospel.htm','Pr\xE9sentation','tour/entites.htm','Entites','materiel/index.htm','Mat\xE9riel','tour/messages.htm','Messages','tour/masters.htm','masters');

charte_plan['Regarde, \xE9coute et vis']=new Array('lll/index.htm','Sommaire regarde, \xE9coute et vis');
charte_plan['Bonne Nouvelle']=new Array('bn/index.htm','Sommaire Bonne Nouvelle');
charte_plan['Le Christ Vivant']=new Array('lc/index.htm','Sommaire Christ Vivant');
charte_plan['Scripts']=new Array('scripts/index.htm','Scripts');

//Sous-dossiers

//Permet de retrouver l'onglet associe a un sous dossier 
//Pour chaque sous dossier on donne le nom du dossier parent
charte_parent=new Array();

charte_parent['Scripts']='Mat\xE9riel';
charte_parent['Bonne Nouvelle']='Mat\xE9riel';
charte_parent['Le Christ Vivant']='Mat\xE9riel';
charte_parent['Regarde, \xE9coute et vis']='Mat\xE9riel';




////////////////////////////// 2. Partie commune toutes chartes

//Variables transmises par la page
var dossier; //onglet
var rubrique; // Texte associe au lien retour
var niveau;
var retour; // url proposee pour suite
var sommaire;

//var charte_chemin=location.href; //sans le http:// et le ?search attention aux \ et au / ...
var charte_chemin=location.pathname; //sans le http:// et le ?search attention aux \ et au / ...
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]') 

//Valeurs par defaut 

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;
} 

//AJOUT
if (typeof (retour)=="undefined") {
	if (sommaire) retour='../index.htm';
	else retour='index.htm';
}

var charte_ongletCourant=dossier;

//tq on a affaire a un sous-dossier avec onglet<>dossier on remonte d'un cran
while (charte_parent[charte_ongletCourant]) {
	charte_ongletCourant=charte_parent[charte_ongletCourant];
}


var etat_revele=0;
function charte_revele() {
	charte_standard();
	if (etat_revele==0)
		document.styleSheets[0].addRule(".cache","display:inline");
	else 
		document.styleSheets[0].addRule(".cache","display:none");
	etat_revele=1-etat_revele;
}

var etat_aide=0;
function charte_aide() {
	charte_standard();
	if (etat_aide==0)
		document.styleSheets[0].addRule(".aide","display:inline");
	else 
		document.styleSheets[0].addRule(".aide","display:none");
	etat_aide=1-etat_aide;
}



charte_baseVisio=niveau+'../visio/';
function bible(p_ref,p_type,p_version) {
	var lb_dupliquerRef=true,lb_icone=true;
	if (p_type==null) p_type='';
	if (p_type.indexOf('i')!=-1) {lb_dupliquerRef=false;} //Seulement l'icône
	if (p_type.indexOf('r')!=-1) {lb_icone=false;} //Seulement la reference
	

if (location.protocol.substring(0,4)=='http') 
	document.write('<A href="http://visionneuse.free.fr/index.htm?xsl=on&ref='+escape(p_ref));
//		document.write('<A href="http://bible.gospelcom.net/passage/?version=32&search='+escape(p_ref));
else {
	document.write('<A href="'+charte_baseVisio+'index.htm?ref='+escape(p_ref));
	if (p_version!=null) document.write('&version='+p_version) ;
}
	document.write('" target="bible" CLASS="ref">');
	
	if (lb_dupliquerRef) document.write(p_ref);
	if (lb_icone) document.write('<IMG src="'+niveau+'charte/bible.gif" class="ref" align=middle border=0 ALT="'+p_ref+'">');
	document.write('</A>')
}




function charte_edit() {
	location.href=charte_baseUtil+"prive/fp2.php?fichier="+escape(charte_chemin);
}

function charte_editsource() {
	location.href=charte_baseUtil+"prive/edit2.php?fichier="+escape(charte_chemin);
}

function charte_upload() {
	l_repertoire=charte_chemin.substring(0,charte_chemin.lastIndexOf('/')+1);
	location.href=charte_baseUtil+"prive/upload.php?repertoire="+escape(l_repertoire);
}

function charte_creerPage() {
	l_repertoire=charte_chemin.substring(0,charte_chemin.lastIndexOf('/')+1);
	location.href=charte_baseUtil+"prive/creerpage.php?niveau="+escape(niveau)+'&repertoire='+escape(l_repertoire)+'&onglet='+dossier;
}

function charte_rep() {
	l_repertoire=charte_chemin.substring(0,charte_chemin.lastIndexOf('/')+1);
	location.href=charte_baseUtil+"prive/rep.php?repertoire="+escape(l_repertoire);
}


///////////// 3. Partie visuelle commune chartes semblables

//Ecrit les onglets
function charte_onglets() {
	var ls_classe;
	document.writeln ('<nofollow><table cellspacing=0 cellpadding=1 > ');
	document.writeln (' <tr align=center valign=middle> ');

	for (i=0;i<charte_dossiers.length;i++) {
		l_urlonglet=niveau+charte_plan[charte_dossiers[i]][0];
		if (charte_ongletCourant==charte_dossiers[i]) ls_classe='ongletactif'; else ls_classe='ongletinactif';
		document.write('<TD width=80 class="'+ls_classe+'" onclick="location.href=\''+l_urlonglet+'\';return false"><a class="'+ls_classe+'" TARGET=_TOP href="');
		document.write(l_urlonglet);
		document.write('">');
		document.write(charte_dossiers[i]);
		document.write('</a><td width=2>');
	}
	document.writeln (' <tr height=2>');
	for (i=0;i<charte_dossiers.length;i++) 
		document.writeln ('<td bgcolor=gray><td>');

	document.writeln (' </table></nofollow>'); 
}
//Ecrit les liens transversaux
function charte_liensTransversaux() {
	if (!charte_plan[dossier] || charte_plan[dossier].length<3 ) return;

	var ls_classe;

	document.write('<br><table cellpadding=0 cellspacing=2 >');
	for (j=0;j<charte_plan[dossier].length / 2 ; j++) {
	if (charte_chemin.substring(charte_chemin.length-charte_plan[dossier][2*j].length)==charte_plan[dossier][2*j]) 
		ls_classe='lientransversalactif'; 
	else ls_classe='lientransversalinactif';
		document.write('<tr><td align="right"><a class='+ls_classe+' href="'+niveau);
		document.write(charte_plan[dossier][2*j]);
		document.write('">');
		document.writeln(charte_plan[dossier][2*j+1]);
		document.write('</a>');
		document.write('<td width=25><img src="'+niveau+'charte/');
		if (ls_classe=='lientransversalactif')
			document.write('bt_lat0.gif">');
		else
			document.write('bt_lat1.gif">');
	}
	document.write('</table>');

}


function charte_entete() {

document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
document.writeln('<html><head><LINK REL="SHORTCUT ICON" href="'+charte_baseHref+'charte/favicon.ico">');


//Table qui contient tout le reste
document.writeln('<table width=100% border=0 height=100% cellpading=0 cellspacing=5>');
document.writeln('<tr><td class=navigation valign=top align=right width=127>'); //Marge de gauche


//logo
document.write('<H2 align=right><IMG  alt="Audio-Gospel" src="'+niveau+'charte/logo.gif"  border=0 ondblclick="charte_revele()"><BR>&nbsp; &nbsp;&nbsp; <IMG height=3 src="'+niveau+'charte/ligne.jpg" width=93 border=0><BR><FONT face=Arial size=4>'+charte_nomSite+'</FONT></H2>');


//Liens transversaux
charte_liensTransversaux();
charte_outils();

//On quitte la marge de gauche, =>table qui contient tout sauf marges
document.write('<td><table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr class=navigation>');
//Bandeau haut
document.write('<td valign=top height=50>');
document.writeln('<a name=haut />');

//Onglets
charte_onglets();

//rubrique
document.write('<P><BR></P> <P class=rubrique>'+rubrique+'</P><p>&nbsp;</p>'); 

//corps

document.writeln('<tr><TD valign=top>');
}


//Boutons
function charte_outils() {
	document.writeln('<P>&nbsp;</P>');
	document.writeln('<TABLE cellSpacing=0 cellPadding=0 width=100% border=0><TR>');
	//plan
	document.writeln('<TD align=middle width="50%"><A href="'+niveau+'outils/plan.htm"><IMG height=48 alt="plan du site" src="'+niveau+'charte/outils/out_plan.gif" width=40 border=0></A></TD>');
	//recherche
	document.writeln('<TD align=middle width="50%"><A href="'+niveau+'outils/recherche.htm"><IMG height=48 alt="recherche sur le site" src="'+niveau+'charte/outils/out_rchc.gif" width=40 border=0></A></TD>');
	document.writeln('</TR> <TR>');
	//aide
	document.writeln('<TD align=middle width="50%"><a href="javascript:charte_aide()"><IMG border=0 src="'+niveau+'charte/outils/out_aide.gif"></a></TD>');
	//Nouveau
	document.writeln('<TD align=middle width="50%"><A href="'+niveau+'outils/nouveau.htm"><IMG height=48 alt="Nouveau" src="'+niveau+'charte/outils/out_nouv.gif" width=40 border=0></A></TD>');
	document.writeln('</TR></TABLE>');

//Texte d'aide
	document.writeln('<br><br><div align=left class=aide>Le texte d\'aide pr\xE9sent dans la page est surlign\xE9</div>')

//Outils d'administration
	if (location.pathname.substring(location.pathname.length-4)=='.htm') {

		document.writeln('<p><div class='+charte_classeOutilsAdministration+'><a href="javascript:charte_edit()">Modifier</a>');
		document.writeln('<br><a href="javascript:charte_editsource()">Editer HTML</a>');
		document.writeln('<br><a href="javascript:charte_creerPage()">Nouvelle page</a>');
		document.writeln('<br><a href="javascript:charte_upload()">Poster fichier</a>');
		document.writeln('<br><a href="javascript:charte_rep()">Explorateur</a>');
		document.writeln('<br><a href="'+charte_baseHref+'index.htm">En ligne</a> ');
		//document.writeln('<br><a href="'+charte_baseRep+'index.htm">Developp</a> ');
		document.writeln('</div>');
		

	}
}

charte_entete();


//////////////////////////////// 4. Partie visuelle specifique
