<!-->
/**
  * Scrolling vertical de texte, avec arrêt si survol
  * JS. CONAN
  * Eskape © 11/2003
  *
  * nécessite DHTML Lib v1.0 (launcher.js)
  */

/* élément de scroll - encapsule l'élément à scroller
 * - width, height : dimensions de la boîte de scroll
 * - step          : pas d'avancement du scroll (en pixels)
 */
function TxtScrollItem(width,height,step,bgcolor,border,bordercolor) {
  this.ancestor=AncestorDHTML;
  this.ancestor(null,"TxtScrollItem");
  this.textwidth = width?width:320;
  this.textheight = height?height:200;
  this.step = step?step:2;
  this.textbgcolor=bgcolor?bgcolor:"";
  this.textborder=border?border:1;
  this.textbordercolor=bordercolor?bordercolor:"#FFFFFF";
  this.scrolling=true;
  this.idMarker = this.id+'Marker';
  this.idRoof = this.id+'Roof';
  this.idTicker = this.id+'Ticker';
  this.idTickerBg = this.id+'TickerBg';

  this.open = function() {
    if(IE || NS5) {
      document.write('<table cellpadding="0" cellspacing="0" border="0" height="'+this.textheight+'" width="'+this.textwidth+'"><tr><td>');
      document.write('<div id="'+this.idMarker+'" style="position:relative; width:'+this.textwidth+'; height:'+this.textheight+'"></div>');
      document.write('</td></tr></table>');
      if(NS5) {
        this.tablewidth=this.textwidth-2*this.textborder;
        this.tableheight=this.textheight-2*this.textborder;
      }
      else {
        this.tablewidth=this.textwidth;
        this.tableheight=this.textheight;
      }
      document.write('<div ID="'+this.idRoof+'" style="position:absolute;width:'+this.tablewidth+'px;height:'+this.tableheight+'px;border-style:solid;border-width:'+this.textborder+'px;border-color:'+this.textbordercolor+';background-color:'+this.textbgcolor+';overflow:hidden;visibility:hidden" onMouseOver="'+this.obj+'.stop()" onMouseOut="'+this.obj+'.start()">');
      document.write('<span ID="'+this.idTicker+'" style="position:absolute;top:0px;left:0px;visibility:hidden">');
    }

    if(NS4) {
      document.write('<table cellpadding="0" cellspacing="0" border="0" height="'+this.textheight+'" width="'+this.textwidth+'"><tr><td>');
      this.widthMinusTwoBorder=this.textwidth-2*this.textborder;
      this.heightMinusTwoBorder=this.textheight-2*this.textborder;
      this.widthMinusFourBorder=this.textwidth-4*this.textborder;
      this.heightMinusFourBorder=this.textheight-4*this.textborder;
      document.write('<ilayer name="'+this.idMarker+'" bgcolor="'+this.textbordercolor+'" width="'+this.textwidth+'" height="'+this.textheight+'"></ilayer>');
      document.write('<layer name="'+this.idTickerBg+'" left="'+this.textborder+'" top="'+this.textborder+'" width="'+this.widthMinusTwoBorder+'" height="'+this.heightMinusTwoBorder+'" bgcolor="'+this.textbgcolor+'" visibility="hide"></layer>');
      document.write('<layer name="'+this.idRoof+'" width="'+this.widthMinusTwoBorder+'" height="'+this.heightMinusFourBorder+'">');
      document.write('<layer name="'+this.idTicker+'" visibility="hide" width="'+this.widthMinusTwoBorder+'"  left="'+this.textborder+'" top="'+this.textborder+'" onMouseOver="'+this.obj+'.stop()" onMouseOut="'+this.obj+'.start()">');
    }
  }

  this.close = function() {
    if(NS4) {
      document.write('</layer></layer>');
      document.write('</td></tr></table>');
    }
    if(IE || NS5) {
      document.write('</span></div>');
    }
  }

  this.doScroll = function(){
    if(this.scrolling){
      if(NS4) {
        var ref = eval('document.'+this.idRoof+'.document.'+this.idTicker);
        ref.top+=-this.step;
        if(ref.top<-this.textcontentheight)ref.top=this.textheight;
      }
      if(IE) {
        var ref = document.getElementById(this.idTicker).style;
        ref.posTop+=-this.step;
        if(ref.posTop<-this.textcontentheight)ref.posTop=this.textheight;
      }
      if(NS5) {
        var ref = document.getElementById(this.idTicker).style;
        ref.top=parseInt(ref.top)-this.step;
        if(parseInt(ref.top)<-this.textcontentheight)ref.top=this.textheight;
      }
    }
  }

  this.init = function(){
    if(NS4) {
      var refTicker=eval('document.'+this.idRoof+'.document.'+this.idTicker);
      var refMarker=eval('document.'+this.idMarker);
      var refRoof=eval('document.'+this.idRoof);
      var refTickerBg=eval('document.'+this.idTickerBg);
      this.textcontentheight=refTicker.clip.bottom-refTicker.clip.top;
      refRoof.left=refMarker.pageX;
      refRoof.top=reMarker.pageY+1*this.textborder;
      refTickerBg.left=refMarker.pageX+1*this.textborder;
      refTickerBg.top=refMarker.pageY+1*this.textborder;
      refRoof.clip.width=this.textwidth;
      refRoof.clip.height=this.textheight-2*this.textborder;
      refTicker.top=this.textheight;
      refTicker.clip.width=this.textwidth;
      refTicker.clip.height=this.textcontentheight;
      refRoof.visibility="show";
      refTickerbg.visibility="show";
      refTicker.visibility="show";
    }
    if(IE || NS5) {
      var objTicker = new RefElement(this.idTicker);
      var objRoof = new RefElement(this.idRoof);
      var objMarker = new RefElement(this.idMarker);
      this.textcontentheight=getLayerHeight(objTicker);
      setLayerX(objRoof,getLayerPageX(objMarker));
      setLayerY(objRoof,getLayerPageY(objMarker));
      setLayerY(objTicker,this.textheight);
      clipLayer(objTicker, 0, 0, this.textwidth-4, this.textcontentheight);
      showLayer(objRoof);
      showLayer(objTicker);
    }
  }

  this.start = function(){this.scrolling=true;}
  this.stop = function(){this.scrolling=false;}
  addOnLoad(this.obj+'.init()');
  return this;
}

/* moteur de scroll - commande et centralise l'action du scrolling
 * - tempo : temps entre chaque déplacement du scroll (en millisecondes)
 */
function TxtScroller(tempo) {
  this.ancestor=AncestorDHTML;
  this.ancestor(null,"TxtScroller");
  this.tempo=tempo?tempo:50;
  this.items=new Array();
  this.cpt=-1;
  this.opened=false;
  this.addItem = function(width,height,step,bgcolor,border,bordercolor){return this.items[this.items.length]=new TxtScrollItem(width,height,step,bgcolor,border,bordercolor);}
  this.open = function(){if(!this.opened&&this.items[this.cpt+1]){this.items[++this.cpt].open();this.opened=true;}}
  this.close = function(){if(this.opened){this.items[this.cpt].close();this.opened=false;}}
  this.doScroll = function(){for(i=0; i<this.items.length;i++)if(this.items[i])this.items[i].doScroll();}
  addOnLoad("setInterval('"+this.obj+".doScroll()',"+this.tempo+")");
}

window.onresize=function(){history.go(0);}

// -->
