// pop-up timer :
/*
Navigateur = navigator.appName;
if (Navigateur == 'Netscape')
{ 
//document.write("<img src='ent/logns.gif' width=88 height=31 alt='Logo Netscape'>"); 
}
if (Navigateur == 'Microsoft Internet Explorer')
{
//document.write("<img src='ent/logoie.jpg' width=30 alt='Logo Internet Explorer'>");
}

var skipcycle = false;

*/

function CheckDate(d) {
      // Cette fonction vérifie le format JJ/MM/AAAA saisi et la validité de la date.
      // Le séparateur est défini dans la variable separateur
      var amin=1999; // année mini
      var amax=2005; // année maxi
      var separateur="/"; // separateur entre jour/mois/annee
      var j=(d.substring(0,2));
      var m=(d.substring(3,5));
      var a=(d.substring(6));
      var ok=1;
      if ( ((isNaN(j))||(j<1)||(j>31)) && (ok==1) ) {
         alert("Le jour n'est pas correct."); ok=0;
      }
      if ( ((isNaN(m))||(m<1)||(m>12)) && (ok==1) ) {
         alert("Le mois n'est pas correct."); ok=0;
      }
      if ( ((isNaN(a))||(a<amin)||(a>amax)) && (ok==1) ) {
         alert("L'année n'est pas correcte."); ok=0;
      }
      if ( ((d.substring(2,3)!=separateur)||(d.substring(5,6)!=separateur)) && (ok==1) ) {
         alert("Les séparateurs doivent être des "+separateur); ok=0;
      }
      if (ok==1) {
         var d2=new Date(a,m-1,j);
         j2=d2.getDate();
         m2=d2.getMonth()+1;
         a2=d2.getFullYear();
         if (a2<=100) {a2=1900+a2}
         if ( (j!=j2)||(m!=m2)||(a!=a2) ) {
            alert("La date "+d+" n'existe pas !");
            ok=0;
         }
      }
      return ok;
   }
function fcsOnMe() {
  if (!skipcycle){
    window.focus();
  }
  mytimer = setTimeout('fcsOnMe()', 500);
}

var popupname = 'ENT_POPUP';

function openPopup(url_loc) {
	return openPopup(url_loc,200,200);
}

function openPopup(url_loc,width,height) {
	//alert('openPopup('+url_loc+','+width+','+height+')');
	if (width==null) {width=200;}
	if (height==null) {height=200;}
	window[popupname] = open(url_loc,popupname,'width='+width+',height='+height+',location=0,menubar=0,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=0,screenX=0,left=0,screenY=0,top=0');
	//alert('opened :'+window[popupname].name);
	return false;
}
	
function closePopup() {
	//alert('closePopup()');
	var popref;
	for (var prop in window) {
		//alert('win name = '+prop);
		if (prop == popupname) {
			popref = window[prop];
			if (popref.opener && popref.opener == self && !popref.closed) {
				popref.close();
			}
		}
	}
	return false;
}

function goThesaurus(url) {
    window.open(url,'THEPOPUP','width=800,height=400,location=0,menubar=0,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=0,screenX=0,left=0,screenY=0,top=0');
    return false;
}
function popup(fic)
// on ouvre dans une fenêtre le fichier passé en paramètre.
// cette ouverture peut être améliorée en passant d'autres
// paramètres que la taille et la position de la fenêtre.
{ wchoix=window.open(fic,'Choisir','width=400,height=250,top=50,left=50'); }

function choisir_coordonnateur(nom,prenom,id)
// on affecte la valeur (.value) dans :
// window.opener : la fenêtre appelante (celle qui a fait la demande)
// .document : son contenu
// .forms[0] : son premier formulaire
// .w_choix : son champ appelé w_choix
{ window.opener.document.forms[0].w_coord_nom.value = coordonnateur_nom;
 window.opener.document.forms[0].w_coord_prenom.value = coordonnateur_prenom;
 window.opener.document.forms[0].w_coord_id.value = coordonnateur_id;

// on se ferme
self.close(); }


function AffTitre(lavaleur)
{
//
//La position indiquée en argument permet de déterminer la position du caractère à partir duquel la recherche est effectué. L'argument position doit être compris entre 0 et n-1. Si cet argument est omis la recherche débutera à la position 0. 
//Lorsque la recherche est infructueuse, la méthode indexOf() renvoie la valeur -1. 
//Voici quelques exemples: 
//Chaine = 'Comment ça marche?'
//
//Sous_Chaine = 'mar'
//var Resultat = Chaine.indexOf(Sous_Chaine, 6)
//
//
    var Chaine = lavaleur;
    var Sous_Chaine = "\\";
		var Resultat = Chaine.lastIndexOf(Sous_Chaine);
    	//var Resultat = 'Je vous dis ';
		quiEst = Chaine.substring(Resultat+1, 300)

    //var domaine="lavaleur";
   //var lenom=domaine.substring(domaine.lastIndexOf("\\"));
if (Navigateur == 'Microsoft Internet Explorer')
{  
		window.document.laform.form_Titre.value=quiEst ;
		window.document.laform.form_Version.value=1;
		window.document.laform.form_Fichier.value=lavaleur;
}

if (Navigateur == 'Netscape')
{  
		window.document.laform.form_Titre.value=quiEst ;
		window.document.laform.form_Version.value=1;
		window.document.laform.form_Fichier.value=lavaleur;
}
}


function AffCategorie(lacategorie)
{
 //		window.opener.document.forms[0].form_w_coord_prenom.value = coordonnateur_prenom;
 //Onchange=javascript:window.location.reload()
		window.status = lacategorie ;
		
}

function on_y_va(categorie)
 {
 	//window.document.laform.lacategorie = categorie ;
  window.document.laform.submit();
 }
 
function test(nom)
{
 if (nom.value=="") {
 	alert("Un nom est requis :"); nom.focus(); return false
 	}
 	return true; // le formulaire peut partir mais cela ne marche pas (voir admin_classes_saisie.php

} 	
// PHP V5 debug 
//function selection(nom,prenom,id) {
//window.opener.document.forms[\"laform\"].elements[\"form_Coordonnateur_Nom\"].value=nom;
//window.opener.document.forms[\"laform\"].elements[\"form_Coordonnateur_Prenom\"].value=prenom;
//window.opener.document.forms[\"laform\"].elements[\"form_Coordonnateur_Id\"].value=id;
//self.close();
//}

function change(code){
	alert("Ok la case à cocher !!"); return false
        //var valeur = document.form.champ.value;
}

function leviewer(lerep,nom)
	{
		window.open("viewer.php?repid=" + lerep + "",'nom',"toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=680,height=550,top=50");
	}
 


function GetId(id)
{
return document.getElementById(id);
}
var i=false; // La variable i nous dit si la bulle est visible ou non
 
function move(e) {
  if(i) {  // Si la bulle est visible, on calcul en temps reel sa position ideale
    if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE
    GetId("curseur").style.left=e.pageX + 5+"px";
    GetId("curseur").style.top=e.pageY + 10+"px";
    }
    else { // Modif proposÃ© par TeDeum, merci Ã  lui
    if(document.documentElement.clientWidth>0) {
	GetId("curseur").style.left=20+event.x+document.documentElement.scrollLeft+"px";
	GetId("curseur").style.top=10+event.y+document.documentElement.scrollTop+"px";
    } else {
	GetId("curseur").style.left=20+event.x+document.body.scrollLeft+"px";
	GetId("curseur").style.top=10+event.y+document.body.scrollTop+"px";
	     }
    }
  }
}
 
function montre(text) {
  if(i==false) {
  GetId("curseur").style.visibility="visible"; // Si il est cacher (la verif n'est qu'une securitÃ©) on le rend visible.
  GetId("curseur").innerHTML = text; // Cette fonction est a amÃ©liorer, il parait qu'elle n'est pas valide (mais elle marche)
  i=true;
  }
}
function cache() {
if(i==true) {
GetId("curseur").style.visibility="hidden"; // Si la bulle etais visible on la cache
i=false;
}
}
document.onmousemove=move; // des que la souris bouge, on appelle la fonction move pour mettre a jour la position de la bulle.

var bt1=new Image(); 
bt1.src="logos/logoroue1.jpg"; 
var bt2=new Image(); 
bt2.src="logos/logoroue2.jpg"; 

function montre_new(){ 
  document.images.bt.src=bt2.src; 
} 

function cache_new(){ 
  document.images.bt.src=bt1.src; 
}


function maxlength_textarea(id, crid, max)
{
        var txtarea = document.getElementById(id);
        document.getElementById(crid).innerHTML=max-txtarea.value.length;
        txtarea.onkeypress=function(){eval('v_maxlength("'+id+'","'+crid+'",'+max+');')};
        txtarea.onblur=function(){eval('v_maxlength("'+id+'","'+crid+'",'+max+');')};
        txtarea.onkeyup=function(){eval('v_maxlength("'+id+'","'+crid+'",'+max+');')};
        txtarea.onkeydown=function(){eval('v_maxlength("'+id+'","'+crid+'",'+max+');')};
}
function v_maxlength(id, crid, max)
{
        var txtarea = document.getElementById(id);
        var crreste = document.getElementById(crid);
        var len = txtarea.value.length;
        if(len>max)
        {
                txtarea.value=txtarea.value.substr(0,max);
        }
        len = txtarea.value.length;
        crreste.innerHTML=max-len;
}



