//script chargé par tous les documents de cvf

//fonction
var liens = false;

function ecritCookie(nom, valeur, expire) {
  if (expire==null) expiration="";
  else expiration = ';expires=' + expire.toGMTString();
  document.cookie = nom + "=" + escape(valeur) + expiration;

}

function litCookie(nom){
  cok = document.cookie;
  re = new RegExp(nom + '=([^;]*)', 'i');
  if (cok.search(re) != -1){
    tab = re.exec(cok);
  }
  else{
    tab = new Array();
    tab[1] = "";
  }
  return tab[1];
}

//modifie le tableau "links" afin que les liens des appels de notes ne soient pas suivis.
function desactLiens () {
  
  for (i=0; i < document.links.length; i++) {
    sig=document.links[i].hash;
    if (sig.indexOf('#fn') != -1) {
      document.links[i].href = 'javascript:void(0)';
    } 
    sig=document.links[i].pathname;
    qs=document.links[i].search;
    if ((sig.indexOf('bibliogr.') != -1) && (qs.indexOf('item') == -1)) {

      document.links[i].href = 'javascript:void(0)';

    }
  }  
  liens = true;
}

function appelBibl(bibl) {
  if (location.protocol=='http:'){
    if (liens==false) desactLiens();
    if (typeof(nt) != 'undefined' && ! nt.closed){nt.close()}
    nt=window.open("biblitem.php?id=" + bibl, "bibliographie", "width=500,height=100,scrollbars=yes,resizable=yes");
    nt.moveTo(25, 25);
  }



}

function appelNote(note) {
  if (location.protocol=='http:'){
    //ecritCookie('cvf_note', location.pathname + "+" + note)
    if (liens==false) desactLiens();
    if (typeof(nt) != 'undefined' && ! nt.closed){nt.close()}
    nt=window.open("note.php?fich=" + location.pathname + "&id=" + note, "notes",
                   "width=500,height=100,scrollbars=yes,resizable=yes");
    nt.moveTo(10, 10);
  }
  
}  

//Fait basculer (on-off) l'affichage des caractères API unicode)
function basculeAPI(){
  api = litCookie('api');
  if (api == '1'){
    api = '0';
  }
  else {
    api = '1';
  }
  dd = new Date();
  dde = new Date(dd.getFullYear() + 1, dd.getMonth(), dd.getDate());
  ecritCookie('api', api, dde);
  document.location.reload();
}

//code exécuté à l'ouverture du document
/*
if(navigator.appVersion.substring(0,1) >3){
  if((parent.frames.length==0) ||  (location.pathname.indexOf('cvf')==-1) ){
    nomCadre='rien';
  }
  else {
    nomCadre=parent.frames[0].name;
  }

  if((nomCadre!='navigation') && (window.name!='sansCadres') && (window.name!='notes')) {
      ecritCookie('cvf_doc', location);
      window.location = 'index.php';
  }
}
*/
