<?xml version="1.0"?>

<bindings id ="testwidget" 
     xmlns="http://www.mozilla.org/xbl"
     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     xmlns:html="http://www.w3.org/TR/REC-html40"
     xmlns:xbl="http://www.mozilla.org/xbl">	  
   
  <binding id="VtestWidget">
    <content>
      <xul:vbox flex="0">
      <xul:label value="Hi from XBL"/>
      <xul:button label="collapse/expand"/>
      <html:textarea name="area1" wrap="virtual" cols="18" rows="3"/>
      <xul:editor src="about:blank"/>
      </xul:vbox>
      <children/>
    </content>

    <implementation>
      <method name="killWindow">
        <body>
         <![CDATA[
           alert("Closing window");
           var temp = document.getElementById("browser").getAttribute('collapsed');
          if (temp != "true"){
           document.getElementById("browser").setAttribute('collapsed', 'true');
          } else {
           document.getElementById("browser").setAttribute('collapsed', 'false');
          }
           //window.close();
         ]]>
        </body>
       </method>
       <method name="changeOrientation">
         <body>
           <![CDATA[
             if (document.getElementById("TestSidebar").getAttribute("orient") == "horizontal") {
              document.getElementById("TestSidebar")
                 .setAttribute("orient", "vertical")
              document.getElementById("main_app_window")
                 .setAttribute("orient", "horizontal")
             } else {
                 document.getElementById("TestSidebar")
                   .setAttribute("orient", "horizontal")
              document.getElementById("main_app_window")
                   .setAttribute("orient", "vertical")
             }
           ]]>
         </body>
       </method>
    </implementation>

    <handlers>
     <handler event="command">
      <![CDATA[
        //this.killWindow();
        this.changeOrientation();
      ]]>
     </handler>
    </handlers>
  </binding>

 <binding id="HtestWidget">
    <content>
      <xul:hbox flex="0">
      <xul:label value="Hi from XBL"/>
      <xul:button label="collapse/expand sidebar"/>
      </xul:hbox>
      <children/>
    </content>

 <implementation>
      <method name="killSidebar">
        <body>
         <![CDATA[
           //alert("Closing Sidebar");
           var tempID = document.getElementById("TestSidebar");
           var temp = tempID.getAttribute('collapsed');
          if (temp != "true"){
           tempID.setAttribute('collapsed', 'true');
          } else {
           tempID.setAttribute('collapsed', 'false');
          }
           //window.close();
         ]]>
        </body>
       </method>
    </implementation>

   <method name="returnNode">
        <parameter name="aNodeA"/>
        <parameter name="aNodeB"/>
        <body>
        <![CDATA[
          var node = this.parentNode;
          while (node && node.localName != "window" && 
                 (node.localName != aNodeA && (node.localName != aNodeB)))  {
            node = node.parentNode;
          }
          return node;
        ]]>
        </body>
      </method>

 <handlers>
  <handler event="command">
    <![CDATA[
     //var temp = this.returnNode("VtestWidget"); 
//alert(document.browser.chromeURL);

     this.killSidebar();
     //temp.killWindow();
    ]]>
  </handler>
 </handlers>
 </binding>

</bindings>
