// v-1.1
// valeurs et fonctions pour marquage Xiti

// Attention penser à modifier *ensemble* les 2 lignes suivantes pour conserver la correspondance URL/niveau
tableau = ['aucun','actu','arts','bio','cdi','ecjs','ecogest','eps','histgeo','langues','lettres','louvre','math','meteo','musique','obter','phy','pilotes','primaire','rnchimie','ses','sti','svt','theatre','TPE','technocol','securite','documentation','insee','B2i','res','histoire des arts','equip','dossier','superieur','inter','secondaire','orbito','juri','legamedia','localisation','musagora','nenuphar','annuaires','plan','planeto','recherche','tech','tv','eng','esp','ENS','espace','formation','greta','innovations','integration','listes_educnet','previl','actua','pratiques','banquise','aiedu','NiveauInexistant','clipperton','usages','EEDD','courrier','articles','textes','philo','competice','mathsciences','comptes','c2i','iufm','archives aef','ticedu']
//			00		01		02		03	04		05		06		07		08		09			10		11		12		13		14			15	16		17			18			19		20	21		22		23		24		25			26			27			28		29		30		31				32			33		34			35		36			37		38		39			40				41			42			43		44		45			46			47	48	49		50	51		52			53		54			55			56				57				58		59		60			61			62			63				64			65		66		67			68		69		70			71			72			73		74		75			76			77

// nom du répertoire principal de la page
function repertoire()  {
 var page = location.href;
 rep = page.substring(32);
 p = rep.indexOf("/");
 rep = rep.slice(0,p);
 num ="";
 for(i = 0; i<tableau.length; i++) {
   if(rep == tableau[i]) {
   num =  i;
   break;
   }
  }
 if(num =="") { num = 0; } 
 return num;
}

function marque()  {
 repertoire();
  hsh = new Date();
  hsd = document;
  hsi = '<img width="1" height="1" src="http://logp.xiti.com/hit.xiti?s=32109&s2='+ num;
  hsi += '&p=&hl=' + hsh.getHours() + 'x' + hsh.getMinutes() + 'x' + hsh.getSeconds();
  if(parseFloat(navigator.appVersion)>=4)
  {s=screen;hsi += '&r=' + s.width + 'x' + s.height + 'x' + s.pixelDepth + 'x' + s.colorDepth;}
  hsd.writeln(hsi + '&ref=' + hsd.referrer.replace('&', '$') + '" >');
}

//  fin marquage xiti

// ------ Classe fenestre -----------

function fenestre(url,nom,optdef,lardef,haudef) {
  this.url=url;
  this.nom=nom;
  if (! this.nom ) this.nom = "nomdef";
  this.optdef = optdef;

  if (! this.optdef) // options par defaut, sauf hauteur et largeur et redim définies séparément
        this.optdef = "toolbar=1,menuBar=0,scrollbars=1,resizable=1,status=1,location=1,left=1,top=50" ;
  if (lardef)
       this.opts = this.optdef + ',width=' + lardef + ',height=' + haudef;
  else
       this.opts = this.optdef + ',width=620,height=420';
  this.fen;
  this.ouvrir = ouvrir_fen;
  this.fermer = fermer_fen;
  this.ouverte = fen_ouverte
}

function ouvrir_fen(url,largeur,hauteur) {
    // nurl indique s'il s'agit d'une nouvelle url;
        var nf;
        if (url && (url != this.url)) nurl = this.url = url;
        if (! this.url)  return 0;
        if (largeur){
          this.opts = this.optdef + ',width=' + largeur + ',height=' + hauteur;
          this.fermer();// obligatoire pour forcer la fenêtre à s'ouvrir avec la nouvelle taille
        }
        if (! this.ouverte()|| nurl)this.fen = window.open (this.url,this.nom,this.opts);
        this.fen.focus();
        return false;
  }

function fermer_fen() {
    if (this.ouverte()) this.fen.close()
}

  function fen_ouverte() {
    return this.fen && ! this.fen.closed
}

// instanciations par défaut (noms de variable réservés )
var objfen= new fenestre('','nomdef2');
var fen_impri = new fenestre("","nom_def3","toolbar=0,menuBar=1,scrollbars=1,resizable=1,left=10,top=10",600,500 );

// -------- fin de la classe fenestre------------------

// surlignage des lignes de tableau

function surligne(r,ids) {
    if (typeof(r.style) == 'undefined' || typeof(r.cells) == 'undefined') {
        return false;
    }
    var nb = r.cells.length;
    for (var i = 0; i < nb; i++) { r.cells[i].id = ids;}
    return true;
} // end of the 'setPointer()' function


// Fonction ouverture de fenêtres secondaires - Définie pour compatibilité avec les anciennes pages
// Utiliser plutôt des instances de la classe fenestre
 
 var newWindow = null;

 function openWin (Url, Nom) {
 var MinWin, winOpts="width=620,height=420,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,location=yes"; 
  if (newWindow != null&& !newWindow.closed)
  { newWindow.close()}

  newWindow = window.open('',Nom,winOpts);
 if (newWindow != null) {
  if (newWindow.opener == null)
    { newWindow.opener = self}
    newWindow.location.href = Url;
    if (newWindow.focus) newWindow.focus();
  }

}

   function Monter(form) {
        var num_ligne = form.liste.options.selectedIndex;
        if (num_ligne >= 0) {
                var o=new Option(form.liste.options[num_ligne].text,form.liste.options[num_ligne].value);
                var p=new Option(form.liste.options[num_ligne-1].text,form.liste.options[num_ligne-1].value);
                form.liste.options[num_ligne]=p;
                form.liste.options[num_ligne-1]=o;
                form.liste.options.selectedIndex = num_ligne-1;
        }
   }

   function Descendre(form) {
        var num_ligne = form.liste.options.selectedIndex;
        if (num_ligne < form.liste.options.length) {
                var o=new Option(form.liste.options[num_ligne].text,form.liste.options[num_ligne].value);
                var p=new Option(form.liste.options[num_ligne+1].text,form.liste.options[num_ligne+1].value);
                form.liste.options[num_ligne]=p;
                form.liste.options[num_ligne+1]=o;
                form.liste.options.selectedIndex = num_ligne+1;
        }

   }
   
   function Concatener(form) {
        chaine = "";
	if (form.liste)
   	  for (i=0;i<form.liste.options.length;i++) {
		if (chaine == "")
		    chaine = form.liste.options[i].value;
		else
		    chaine += "::" + form.liste.options[i].value;
	  }
	return form.elements['sn_edulevel_footer_text:text'].value + '///' + chaine;
   }
   

function getElBy(tag,attr,val) {
  var dbRes = [];
  var dbEl = document.body.getElementsByTagName(tag);
  for (e = 0; e < dbEl.length; e++) {
    if (attr == 'class') {
      if (dbEl[e].className == val) {
        dbRes.push(dbEl[e]);
      }			
    }
    else {
      chaine = dbEl[e].getAttribute(attr);
      if (chaine){
        if (chaine.substring(0,val.length) == val)
          dbRes.push(dbEl[e]);
      }  
    }	
  }
  return dbRes;
}

function changeVisibility(pere){
  var trTest = getElBy('tr','id',pere);
  for (var db = 0; db < trTest.length; db++) {
    if (trTest[db].style.display == '')
      trTest[db].style.display = 'none';
    else
      trTest[db].style.display = '';
  }
}

function toggleVisibility(elt){
  var tr =  document.body.getElementById(elt);
  tr.style.display = 'compact';
}

