
//********************************************************/
// Fonction  : switchDisplay
// Rle       : Affiche/cache un objet id 
// Param in  : ID zone a adeployer
//********************************************************/
function switchDisplayZone(id){
	//alert("switchDisplayZone("+id+")");
	if(this.document.getElementById(id).style.display=='none'){
		this.document.getElementById(id).style.display='inline';
	}else{
		this.document.getElementById(id).style.display='none';
	}
}
function setDisplayZone(id,state){
		this.document.getElementById(id).style.display=state;
}
//********************************************************/
// Fonction  : f_page_enCours
// Rle      : extrait de l'adresse URL le nom de la page courante
// Param in  : nant
// Param OUT : Nom de la page en cours
//********************************************************/
function f_NomPage(){
	var tab = document.URL.split("/"); /* decoupe en f(sparateur) */
	var nom_page=tab[tab.length-1];
	tab = nom_page.split("."); 
	nom_page=tab[0];
	if (nom_page=="") nom_page="index";
	return nom_page;
}// fin sfonc


//********************************************************/
// Fonction  	: UserCtrl
// Rôle      	: Contrôle type utilisateur
// Param in  	: Néant
// Param OUT 	: si ADMIN.nomDomaine booleen VRAI
//********************************************************/
function isAdmin() {
	var url=document.location;

   	if (url == "") return false;
 	var exp = new RegExp(/(admin)+/); 
	var admin = exp.test(url);
//	if (admin) alert("ADMIN : "+url); else alert("No ADMIN : "+url);
	return exp.test(url);
}
//********************************************************/
// Rle   : Initialisation des variables Diaporama
// 			INIT noms & nombre images diaporama
// 			emplacement :  ../images/nom-page/0.jpg 1.jpg etc
//********************************************************/
var page,i,nbr_img,prefix;
var soufix=".jpg";
var timing=1500;
var img_enCours="";
var enCours=false;
imgdiapo=new Array();

//********************************************************/
// Fonction  : aff_img_central
// Rle      : affichage image centrale sur certaines pages 
//********************************************************/
function img_central(page,rub,nbr_img,lang){
	var soufix=".jpg";
	var nbr_img;
	var rub;
	
	var prefix="img/"+page+"/";
	if(lang=="en"){
		var	title="Click to start / stop slideshow";
	}else{
		var	title="Cliquez pour lancer / arrter la diaporama";
	}
	
	if(rub!=""){prefix="img/"+page+"/"+rub+"/";}
	var nom_img_central=prefix+"0.jpg";
	if (nbr_img==0){
		document.writeln("<img name='img_central' src='"+nom_img_central+"'>");
	}else{
	 	document.write("<img name='img_central' src='"+nom_img_central+"' title='"+title+"' alt='"+title+"' onClick='javascript:lancement_diaporama();'>");
		for (i = 0; i < nbr_img; i++){imgdiapo[i]=prefix+i+soufix;}
		i=0;/* obligatoirement ici !!!!!!!!!!!!!!*/
		 }
}/* fin Fonc */

/*-------------------------------------------------------------------------
 Fonction   : diaporama
 Rle		: fait dfiler les images 
 --------------------------------------------------------------------------*/
  function diaporama(){
  if(i<imgdiapo.length){
  img_enCours=imgdiapo[i];
  	document.img_central.src=imgdiapo[i];
	i++;
	if(i==imgdiapo.length){
		  Stopp();
			i=0;
		enCours=false; }	
	 }
  }
    
/*-------------------------------------------------------------------------
 Fonction   : Stopp
 Rle		: Arrte l'excution d'un traitement  intervalle rgulier
 --------------------------------------------------------------------------*/
function Stopp(){window.clearInterval(id);}

/*-------------------------------------------------------------------------
 Fonction   : Depart
 Rle		: Lance un traitement  intervalle rgulier
 Entre		: (1)Function qui lance le defilement des images
         	: (2)Tempo en MiliSec
 --------------------------------------------------------------------------*/
function Depart(){id=setInterval("diaporama()",timing);}
/*-------------------------------------------------------------------------
 Fonction   : Gestion FLASH
 Rle		: Lance/ Arrte la Diaporama
 --------------------------------------------------------------------------*/
//alert("txt_flash="+txt_flash);
	var txt_flash_ini=txt_flash;
 	var lg_flash=txt_flash.length;
 	var n=0; 
	var k=0;
	
function DepartFlash(){id=setInterval("displayTexte()",400);}
function ModeModif(){
	setDisplayZone("flash_display_div","none");// zone affichage invisible
	setDisplayZone("flash_update_bt","none");// bt Modifier  invisible
	switchDisplayZone("flash_input_div");// zone modification visible
	document.form_flash.flash_input.value=txt_flash_ini;// zoen de saisie initialisée avec texte initiale
}
function ModeNormal(){
//alert("ModeNormal")	;
	setDisplayZone("flash_display_div","inline");// zone visible
	setDisplayZone("flash_update_bt","inline");// bt visible
	switchDisplayZone("flash_input_div");// zone modification invisible
	DepartFlash();// relance défilement
}

 //********************************************************/
// Fonction  : displayTexte
// Role      : fait défiler le texte
//********************************************************/
  function displayTexte(){
	 // taille de la zone Input de Defilement
 	lg_zone=document.form_flash.flash_display.size;

	 // initialisation des variables si le texte a été affiché en totalité 
	 if(n>lg_flash){
  		n=0;
 		k=0;
 		document.form_flash.flash_display.value="";
		txt_flash=txt_flash_ini;
		txt_flash=txt_flash_ini.substring(n,n+lg_zone);
	 }else{
	 // passage à une partie suivante du texte si la zone d'affichage est remplie 
	     if(k==lg_zone){
			txt_flash=txt_flash_ini.substring(n,n+lg_zone);
		   	k=-1;
 			document.form_flash.flash_display.value="";
		 }else{
		// affichage caractère suivant
			document.form_flash.flash_display.value+=txt_flash.charAt(k);
		 }
		k++;
		n++;
	}
 }
/*-------------------------------------------------------------------------
 Fonction   : Gestion Diaporama
 Rle		: Lance/ Arrte la Diaporama
 --------------------------------------------------------------------------*/
function lancement_diaporama(){
	if(enCours){	
		Stopp();
		document.img_central.src=img_enCours;
		enCours=false;
 	}else{
		Depart();
  		enCours=true;
  	}
 	 return enCours;
}


/********************************************************/
// Rle     :Ouvre Fenetre Externe centre
/********************************************************/
function OuvreFenetreCentree(url,NomFenetre,l,h){
	var url;
	var NomFenetre;
	var l,h,largeur,hauteur;
	hauteur=Math.round((screen.availHeight-h)/2);
	largeur=Math.round((screen.availWidth-l)/2);
	window.open(url, NomFenetre, "resizable=no,dependent=yes, toolbar=no,location=no,directories=0,status=0, scrollbars=no,menubar=no,top="+hauteur+",left="+largeur+",width="+l+",height="+h);
}


