<?xml version="1.0"?>  
<?xml-stylesheet href="../style/spaced-header.css" ?>
<bindings xmlns="http://www.mozilla.org/xbl">
  <binding id="fader">
    <implementation>

      <method name="fade">
        <body>
          this.fadeIn(0);
        </body>
      </method>

      <method name="fadeIn">
        <parameter name="index"/>
        <body>
          <![CDATA[
            if ((index < 0) || (index > this.steps)) {
              return;
            }
            this.style.fontSize = this.applyFraction(index, this.style.fontSize, this.inZoom);
            this.style.letterSpacing = this.applyFraction(index, this.style.letterSpacing, this.inSpace);
            this.style.mozOpacity += this.inOpacity / this.steps;
            if (index == this.steps) {
              setTimeout(this.length / this.steps, this.fadeOut(0));
            } else {
              setTimeout(this.length / this.steps, this.fadeIn(index+1));
            }
          ]]>
        </body>
      </method>

      <method name="fadeOut">
        <parameter name="index"/>
        <body>
          <![CDATA[
            if ((index < 0) || (index > this.steps)) {
              return;
            }
            this.style.fontSize = this.applyFraction(index, this.style.fontSize, this.outZoom);
            this.style.letterSpacing = this.applyFraction(index, this.style.letterSpacing, this.outSpace);
            this.style.mozOpacity += this.outOpacity / this.steps;
            if (index < this.steps) {
              setTimeout(this.length / this.steps, this.fadeOut(index+1));
            }
          ]]>
        </body>
      </method>

      <method name="applyFraction">
        <parameter name="index"/>
        <parameter name="currentValue"/>
        <parameter name="fraction"/>
        <body>
          return currentValue * ((fraction - 1) * index / this.steps + 1);
        </body>
      </method>

      <property name="inZoom">1.4</property>
      <property name="outZoom">1.4</property>
      <property name="inSpace">1</property>
      <property name="outSpace">1</property>
      <property name="inOpacity">1</property>
      <property name="outOpacity">-1</property>
      <property name="steps">20</property>
      <property name="length">20000</property>

    </implementation>
  </binding>
</bindings>
