/*
*/
//yyyy
//with(elems[i]){ //this
//}
//alert(xx);
//--------------------------------//
//ajout d'une méthode Trim à l'objet String
String.prototype.trim=function(){
  return this.replace(/^\s+/,'').replace(/\s+$/,'');
}
//--------------------------------//
function f0(){
  //var a=new Array();
  //return a;
}
//--------------------------------//
function f1(p1,p2,p3,p4){
  //var a=new Array();
  //return a;
  this.sec=p1; //section
  this.rub=p2; //rubrique
  this.tit=p3; //titre
  this.url=p4; //url
}
//--------------------------------//
function f2(p1,p2,p3,p4,p5,p6,p7,p8){
  //var a=new Array();
  //return a;
  this.sec=p1; //section
  this.n1=p2;  //nom1
  this.n2=p3;  //nom2
  this.mot=p4;   //mot-clé
  this.strict=p5; //strict
  this.ndoc=p6; //nb de documents
  this.nocc=p7; //nb de d'occurrences
  this.docs=p8; //liste des (document:occurrences)
}
//--------------------------------//
function f3(p1,p2){
  //var a=new Array();
  //return a;
  this.doc=p1; //réf. document
  this.nocc=p2; //nb de d'occurrences
}
//--------------------------------//
function findPosX(obj){
  var curleft=0;
  if(obj.offsetParent){
    while(obj.offsetParent){
      curleft+=obj.offsetLeft;
      obj=obj.offsetParent;
    }
  }else{
    //alert('x:'+obj.x);
    if(obj.x){
      curleft+=obj.x;
    }
  }
  return curleft;
}
//--------------------------------//
function findPosY(obj){
  var curtop=0;
  if(obj.offsetParent){
    while(obj.offsetParent){
      curtop+=obj.offsetTop
      obj=obj.offsetParent;
    }
  }else{
    //alert('y:'+obj.y);
    if(obj.y){
      curtop+=obj.y;
    }
  }
  return curtop;
}
//--------------------------------//
function tt_Style(obj){ //yyyy
  return obj.offsetParent; //previousSibling, offsetParent
}
//--------------------------------//
function evMouseClick(e){
  if(!e){
    var e=window.event;
    elem=e.srcElement; //mzz: IE
  }else{
    elem=e.target; //mzz: FF
  }
  //alert(elem);
  with(elem){
    if(window.name=='frR' && id && nodeName){ //MZZ: frR
      switch(nodeName){
      case 'A': //liens
        //MZZ: on continue !
        break;
      default:
        //alert('evMouseClick:'+nodeName);
        return; //MZZ
        //break;
      }
    }else{
      return; //MZZ
    }
    
    var kMot=parentNode.id; //kMot
  }
  
  var vMot='';
  var vStrict=false;
  
  with(aIMot[kMot]){
    if(mot!=''){
      vMot=mot;
    }else{
      vMot=n1;
    }
    vStrict=strict;
  }
  
  with(parent.frT.document.forms['find']){ //MZZ: frT
    txt.value=vMot; //mzz: txt
    chk1.checked=true; //mzz: chk1
    chk2.checked=vStrict; //mzz: chk2
  }
  //alert(kMot+','+vMot+','+vStrict);
}
//--------------------------------//
function evMouseOver(e){
  if(!e){
    var e=window.event;
    elem=e.srcElement; //mzz: IE
  }else{
    elem=e.target; //mzz: FF
  }
  //alert(elem);
  with(elem){
    if(window.name=='frR' && id && nodeName){ //MZZ: frR
      switch(nodeName){
      case 'A': //liens
        //MZZ: on continue !
        break;
      default:
        //alert('evMouseOver:'+nodeName);
        return; //MZZ
        //break;
      }
    }else{
      return; //MZZ
    }
    
    var kDoc=id; //kDoc
  }
  
  var posX=0, posY=0;
  var div_pw=0, div_ph=0;
  
/*
  var node=tt_Style(pThis); //previousSibling //yyyy
  with(node.style){
    Style='background-color: lightgrey;';
  }
*/
  
  with(iDiv.style){
    width='';
    height='';
    visibility='visible'; //mzz
  }
  
  posX=findPosX(elem);
  posY=findPosY(elem);
  //alert('evMouseOver:'+posX+','+posY);
  
  with(aDoc[kDoc]){
    td1.innerHTML=aSec[sec];
    td2.innerHTML=aRub[rub];
    td3.innerHTML='<b>'+tit+'</b>';
    //var vdoc=tit;
    //var vsec=aSec[sec];
    //var vrub=aRub[rub];
  }
  //td4.innerHTML=posX+','+posY+' '+div_pw+','+div_ph;
  //iDiv.innerHTML=pThis.name.replace(/\\x/g,'<br>'); //mzz
  
  with(iDiv){
    div_pw=offsetWidth; //offsetWidth
    div_ph=offsetHeight; //offsetHeight
    //alert('evMouseOver:'+offsetWidth+','+offsetHeight);
  }
  
  //td4.innerHTML=posX+','+posY+' '+div_pw+','+div_ph;
  //alert('show: '+pThis.name);
  with(iDiv.style){
    //if((top==''||top==0)&&(left==''||left==0)){
    //}
    //left='';top='';width='';height='';
    //need to fixe default size (MSIE problem)
/*
    //if tooltip is too wide, shift left to be within parent
    if(posX+div_pw>pThis.offsetWidth){
      posX=pThis.offsetWidth-div_pw;
    }
    if(posX<0){
      posX=0;
    }
*/
    posY-=(div_ph+1);
    //posY-=1;
    left=posX+'px';
    top=posY+'px';
    //width=div_pw+'px';
    //height=div_ph+'px';
  }
  //alert('evMouseOver:'+div_pw+','+div_ph+','+td1.innerHTML);
}
//--------------------------------//
function evMouseOut(e){
  if(!e){
    var e=window.event;
    elem=e.srcElement; //mzz: IE
  }else{
    elem=e.target; //mzz: FF
  }
  //alert(elem);
  with(elem){
    if(window.name=='frR' && id && nodeName){ //MZZ: frR
      switch(nodeName){
      case 'A': //liens
        //MZZ: on continue !
        break;
      default:
        //alert('evMouseOut:'+nodeName);
        return; //MZZ
        //break;
      }
    }else{
      return; //MZZ
    }
  }
  
  with(iDiv.style){
    width='';
    height='';
    visibility='hidden'; //mzz: hidden,visible
  }
  //alert('evMouseOut');
}
//--------------------------------//
function htm_Init(){
  var vTit='';
  var vUrl='';
  var elem=null;
  var elems=null;
  
  elems=document.getElementsByTagName('p'); //p
  for(var i=0;i<elems.length;i++){
    elem=elems[i];
    with(elem){
      if(id!=''){
        vTit=aISec[id]; //aISec
        className='p1'; //mzz
        innerHTML=vTit;
      }
    }
  }
  
  elems=document.getElementsByTagName('span'); //span
  for(var i=0;i<elems.length;i++){
    elem=elems[i];
    with(elem){
      with(aIMot[id]){ //aIMot
        if(n2){
          vTit=n1+' ('+n2+')';
        }else{
          vTit=n1;
        }
      }
      className='s1'; //mzz
      innerHTML=vTit;
    }
  }
  
  elems=document.getElementsByTagName('a'); //a
  for(var i=0;i<elems.length;i++){
    elem=elems[i];
    with(elem){
      with(aDoc[id]){ //aDoc
        vUrl=url;
      }
      href=vUrl;
      //className='a1'; //mzz
      innerHTML='&#8226;';
    }
  }
}
//--------------------------------//
//
function tt_Init(){
/*
  htm_Init();
  return;
*/
  
  var elem=null;
  var elems=document.getElementsByTagName('a'); //span, a, p
  for(var i=0,j=elems.length;i<j;i++){
    //elem=elems[i];
    with(elems[i]){ //elems[i].
      onmouseover=evMouseOver;
      onmouseout=evMouseOut;
    }
    //with(elems[i]){ //elems[i].
    //}
  }
}
//alert('hide');
//alert(''+elems.length);
//--------------------------------//
//
function Init(){
  document.onclick=evMouseClick;
  document.onmouseover=evMouseOver;
  document.onmouseout=evMouseOut;
  //alert('Init');
  return;
  
  var cMaxDocs=35; //MZZ
  var vHtml='';
  var vTit='';
  var vArr=null;
  var kDoc=0;
  var vLen=0; //nombre de documents
  
  var vStart=new Date().getTime()
  
  var eContent=document.getElementById('content')
  with(eContent){
    if(innerHTML.trim()!=''){
      alert('Init');
      return; //MZZ
    }
  }
  
  //alert('(vide)');
  //alert(aIMot.length);
  //for(var iA=1,itemA;itemA=aIMot[iA];iA++){ //MZZ: iA=1
  for(var iA=1,jA=aIMot.length;iA<jA;iA++){ //MZZ: iA=1
    with(aIMot[iA]){ //aIMot
      if(n2!=''){
        vTit=n1+' ('+n2+')';
      }else{
        vTit=n1;
      }
      vHtml+='<p id="'+iA+'"><span>'+vTit+'</span> '; //</p>
      
      if(docs!=''){
        vArr=docs.split(',');
        vLen=vArr.length;
        if(vLen<=cMaxDocs){
          for(var iB=0,jB=vLen;iB<jB;iB++){ //MZZ
            kDoc=vArr[iB].split(':')[0];
            with(aDoc[kDoc]){ //aIMot
              //vHtml+='<a href="'+url+'" id="'+kDoc+'" onClick="evMouseClick();" onMouseOver="evMouseOver(this);" onMouseOut="evMouseOut(this);">&#8226;</a>';
              vHtml+='<a href="'+url+'" id="'+kDoc+'">&#8226;</a>';
            }
          }
        }else{
          vHtml+='<span class="s3"><b>trop de documents</b> ('+vLen+'>'+cMaxDocs+')</span>'; //MZZ
        }
        vArr=null;
      }else{
        vHtml+='<span class="s3">pas de documents</span>'; //MZZ
      }
    }
    vHtml+='</p>'; //</p>
  }
  //alert(vHtml.length);
  //var eContent=document.getElementById('content')
  with(eContent){
    innerHTML=vHtml;
  }
  
  document.onclick=evMouseClick;
  document.onmouseover=evMouseOver;
  document.onmouseout=evMouseOut;
  
  //alert(Math.round((new Date().getTime()-vStart)/10)/100+' sec')
}
//--------------------------------//
window.onload=Init; //mzz
//--------------------------------//
