<?xml version="1.0"?>

<bindings
  xmlns="http://www.mozilla.org/xbl"
  xmlns:xbl="http://www.mozilla.org/xbl"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <binding id="slideshow">
  <content>
    <xul:box orient="vertical" flex="1">
      <xul:deck index="1" flex="1">
        <children/>
      </xul:deck>
      <xul:box orient="horizontal">
        <xul:button xbl:inherits="value=previoustext"
                    onclick="parentNode.parentNode.parentNode.page--;"/>
        <xul:text flex="1"/>
        <xul:button xbl:inherits="value=nexttext"
                    onclick="parentNode.parentNode.parentNode.page++;"/>
      </xul:box>
    </xul:box>
  </content>

  <implementation>

    <property name="page"
          onget="return parseInt(document.getAnonymousNodes(this)[0].childNodes[0].getAttribute('index'));"
          onset="return setPage(val);"/>

    <method name="setPage">
      <parameter name="newidx"/>
      <body>
        <![CDATA[
          var thedeck=document.getAnonymousNodes(this)[0].childNodes[0];
          var totalpages=childNodes.length;  
          if (newidx<=0) return 0;
          if (newidx>totalpages) return totalpages;

          thedeck.setAttribute("index",newidx);
          document.getAnonymousNodes(this)[0].childNodes[1].childNodes[1]
                             .setAttribute("value",newidx+" of "+totalpages);
          return newidx;
        ]]>
      </body>
    </method>
  </implementation>

</binding>


</bindings>
