<?xml version="1.0"?>
<!DOCTYPE window [
<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd" >
%textcontextDTD;
]>

<bindings id="xulBindings"
   xmlns="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="thumb" extends="xul:box">
    <content>
      <xul:spring flex="1"/>
		  <xul:image inherits="src"/>
		  <xul:spring flex="1"/>
    </content>
  </binding>

  <binding id="scrollbar">
    <content>
      <xul:scrollbarbutton type="decrement">
	      <xul:image inherits="src"/>
	    </xul:scrollbarbutton>
      <xul:slider flex="1" inherits="curpos,maxpos,pageincrement,increment">
	      <xul:thumb inherits="align,src" flex="1"/>
      </xul:slider>
      <xul:scrollbarbutton type="increment">
	    <xul:image inherits="src"/>
	  </xul:scrollbarbutton>
    </content>
  </binding>

  <binding id="slider">
    <content>
	  <xul:button align="horizontal"/>
	</content>
  </binding>

  <binding id="tab">
    <content>
      <xul:image inherits="src" class="tab-left"/>
      <xul:text flex="1" inherits="value,crop,accesskey" crop="right" class="tab-text"/>
    </content>
  </binding>


  <binding id="menu-menubar">
    <content includes="menupopup">
      <xul:text class="menubar-text" inherits="value,accesskey,crop" crop="right"/>
    </content>
  </binding>

  <binding id="menu-menubar-iconic">
    <content includes="menupopup">
      <xul:image class="menubar-left"/>
      <xul:text class="menubar-text" inherits="value,accesskey,crop" crop="right"/>
    </content>
  </binding>

  <binding id="menu">
    <content autostretch="never" includes="menupopup">
      <xul:text class="menu-text" flex="1" align="left" inherits="value,accesskey,crop" crop="right"/>
      <xul:text class="menu-accel" inherits="acceltext:value"/>
      <xul:box autostretch="never" class="menu-right" inherits="menuactive,disabled">
        <xul:image/>
      </xul:box>
    </content>
    <implementation>
      <property name="data" onset="this.setAttribute('data',val); return val;"
                            onget="return this.getAttribute('data');"/>
    </implementation>  
  </binding>

  <binding id="menuitem">
    <content autostretch="never" includes="menupopup">
      <xul:text class="menu-text" flex="1" align="left" inherits="value,accesskey,crop" crop="right"/>
      <xul:text class="menu-accel" inherits="value=acceltext"/>
    </content>
    <implementation>
      <property name="data" onset="this.setAttribute('data',val); return val;"
                            onget="return this.getAttribute('data');"/>
    </implementation>  
  </binding>

  <binding id="menuitem-iconic">
    <content includes="menupopup">
      <xul:box class="menu-iconic-left" orient="vertical" autostretch="never" inherits="selected,menuactive,disabled,checked">
        <xul:image/>
      </xul:box>
      <xul:text class="menu-iconic-text" flex="1" align="left" inherits="value,accesskey,crop" crop="right"/>
      <xul:text class="menu-iconic-accel" inherits="value=acceltext"/>
    </content>
    <implementation>
      <property name="data" onset="this.setAttribute('data',val); return val;"
                            onget="return this.getAttribute('data');"/>
    </implementation>  
  </binding>

  <binding id="menu-iconic">
    <content autostretch="never" includes="menupopup">
      <xul:box class="menu-iconic-left" orient="vertical" autostretch="never">
        <xul:image/>
      </xul:box>
      <xul:text class="menu-iconic-text" flex="1" align="left" inherits="value,accesskey,crop" crop="right"/>
      <xul:text class="menu-iconic-accel" inherits="value=acceltext"/>
      <xul:box orient="vertical" autostretch="never" class="menu-right" inherits="menuactive,disabled">
        <xul:image/>
      </xul:box>
    </content>
    <implementation>
      <property name="data" onset="this.setAttribute('data',val); return val;"
                            onget="return this.getAttribute('data');"/>
    </implementation>  
  </binding>
  
  <binding id="basetext">
    <implementation>
      <!-- public implementation -->
      <property name="value"      onset="return this.setAttribute('value',val);"
                                  onget="return this.getAttribute('value');"/>
      <property name="crop"       onset="return this.setAttribute('crop',val);"
                                  onget="return this.getAttribute('crop');"/>
      <property name="disabled"   onset="if (val) this.setAttribute('disabled', 'true');
                                         else this.removeAttribute('disabled');
                                         return val;"
                                  onget="var v = this.getAttribute('disabled');
                                         if (v == 'true') return true; return false;"/>                                  
      <property name="src"        onset="return this.setAttribute('src',val);"
                                  onget="return this.getAttribute('src');"/>
      <property name="accesskey"  onset="return this.setAttribute('accesskey',val);"
                                  onget="return this.getAttribute('accesskey');"/>
      <property name="imgalign"   onset="return this.setAttribute('imgalign',val);"
                                  onget="return this.getAttribute('imgalign');"/>
    </implementation>      
  </binding>
  
  <binding id="checkbox" extends="chrome://global/content/xulBindings.xml#basetext">
    <content>
      <xul:box flex="1" class="internal-box" autostretch="never" valign="top">
        <xul:box class="checkmark-box" autostretch="never">
          <xul:image class="checkbox-check"/>
        </xul:box>
        <xul:image class="checkbox-icon" inherits="src"/>
        <xul:html inherits="value,accesskey,crop" flex="1">
          <children/>
        </xul:html>
      </xul:box>
    </content>
    <implementation>
      <!-- public implementation -->
      <property name="checked"    onset="if (val) this.setAttribute('checked', 'true');
                                         else this.removeAttribute('checked');
                                         return val;"
                                  onget="var v = this.getAttribute('checked');
                                         if (v == 'true') return true; return false;"/>
    </implementation>
    <handlers>
      <handler event="click">
      <![CDATA[
        if (!this.disabled) this.checked = !this.checked; 
      ]]>
      </handler>
      <handler event="keypress" key=" " action="if (!this.disabled) this.checked = !this.checked;"/>
    </handlers>
  </binding>

  <!-- XUL <button>s -->
  <binding id="buttonleft" extends="chrome://global/content/xulBindings.xml#basetext">
    <content>
  	  <xul:box class="button-internal-box" autostretch="never" flex="1">
        <xul:image class="button-icon" inherits="src"/>
        <xul:box orient="vertical" class="button-text-container" autostretch="never" flex="1">
          <xul:text class="button-text" inherits="value,accesskey,crop,dragover-top"/>
        </xul:box>
      </xul:box>
    </content>
  </binding>

  <binding id="buttontop" extends="chrome://global/content/xulBindings.xml#basetext">
    <content>
  	  <xul:box class="button-internal-box" orient="vertical" autostretch="never" flex="1">
        <xul:image class="button-icon" inherits="src"/>
        <xul:box orient="vertical" class="button-text-container" autostretch="never" flex="1">
          <xul:text class="button-text" inherits="value,accesskey,crop,dragover-top"/>
        </xul:box>
      </xul:box>
    </content>
  </binding>
  
  <binding id="buttonright" extends="chrome://global/content/xulBindings.xml#basetext">
    <content>
  	  <xul:box class="button-internal-box" inherits="orient" autostretch="never" flex="1">
        <xul:box orient="vertical" class="button-text-container" autostretch="never" flex="1">
          <xul:text class="button-text" inherits="value,accesskey,crop,dragover-top"/>
        </xul:box>
        <xul:image class="button-icon" inherits="src"/>
      </xul:box>
    </content>
  </binding>

  <binding id="buttonbottom" extends="chrome://global/content/xulBindings.xml#basetext">
    <content>
  	  <xul:box class="button-internal-box" orient="vertical" autostretch="never" flex="1">
        <xul:box orient="vertical" class="button-text-container" autostretch="never" flex="1">
          <xul:text class="button-text" inherits="value,accesskey,crop,dragover-top"/>
        </xul:box>
        <xul:image class="button-icon" inherits="src"/>
      </xul:box>
    </content>
  </binding>
  
  <binding id="separator" extends="xul:spring"/>

  <!-- appending to the end so we don't make hyatt cry -->
  <binding id="progressmeter" extends="xul:box">
    <content>
      <xul:box class="progressmeter-internal-box" flex="1">
        <xul:stack class="progressmeter-stack" flex="1">
          <xul:progressbar class="progressmeter-progressbar" inherits="value,statusbar">
            <xul:box class="progress-bar"/>
            <xul:box class="progress-remainder"/>
          </xul:progressbar>
          <xul:box>
            <xul:spring flex="1"/>
            <xul:text class="progress-text" inherits="progresstext:value"/>
            <xul:spring flex="1"/>
          </xul:box>
        </xul:stack>
      </xul:box>
    </content>
    <implementation>
      <property name="progresstext"   onset="this.setAttribute('progresstext',val); return val;"
                                      onget="return this.getAttribute('progresstext');"/>
      <property name="value"          onset="this.setAttribute('value',val); return val;"
                                      onget="return this.getAttribute('value');"/>
      <property name="mode"           onset="this.setAttribute('mode', val); return val;"
                                      onget="return this.getAttribute('mode');"/>
    </implementation>
  </binding>

  <binding id="textfield" extends="xul:box">
    <content context="_child">
      <xul:box class="textfield-internal-box" flex="1">
        <html:input class="textfield-input" flex="1" inherits="onfocus,onblur,value,type,maxlength,disabled,size,readonly"/>
      </xul:box>
      <xul:popupset>
        <xul:popup oncreate="this.focus()">
          <xul:menuitem value="&undoCmd.label;" accesskey="&undoCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_undo');              
            controller.doCommand('cmd_undo');"/>
          <xul:menuseparator/>
          <xul:menuitem value="&cutCmd.label;" accesskey="&cutCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_cut');
            controller.doCommand('cmd_cut');"/>
          <xul:menuitem value="&copyCmd.label;" accesskey="&copyCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_copy');
            controller.doCommand('cmd_copy');"/>
          <xul:menuitem value="&pasteCmd.label;" accesskey="&pasteCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_paste');
            controller.doCommand('cmd_paste');"/>
          <xul:menuitem value="&deleteCmd.label;" accesskey="&deleteCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_cut');
            controller.doCommand('cmd_delete');"/>
           <xul:menuseparator/>
          <xul:menuitem value="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_selectAll');
            controller.doCommand('cmd_selectAll');"/>
        </xul:popup>
      </xul:popupset>
    </content>
    <implementation>
      <property name="inputField" readonly="true">
       <![CDATA[
        var v = document.getAnonymousNodes(this);
        var input = null;
        for (var i = 0; i < v.length; i++) {
          try {
            var l = v[i].getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "input");
            if (l.length > 0) {
              input = l[0];
              break;
            }
          } catch (e) {} 
        }
        input;
      ]]>
      </property>
      <property name="value"      onset="this.inputField.value = val; return val;"
                                  onget="return this.inputField.value;"/>
      <property name="type"       onset="this.inputField.type = val; return val;"
                                  onget="return this.inputField.type;"/>
      <property name="maxlength"  onset="this.inputField.maxlength = val; return val;"
                                  onget="return this.inputField.maxlength;"/>
      <property name="disabled"   onset="this.inputField.disabled = val; return val;"
                                  onget="return this.inputField.disabled;"/>
      <property name="size"       onset="this.inputField.size = val; return val;"
                                  onget="return this.inputField.size;"/>
      <property name="readonly"   onset="this.inputField.readonly = val; return val;"
                                  onget="return this.inputField.readonly;"/>

      <method name="select">
        <body>
          this.inputField.select();
        </body>
      </method>
      
      <property name="controllers"    readonly="true" onget="return this.inputField.controllers"/>
      <property name="textLength"     readonly="true" onget="return this.inputField.textLength;"/>
      <property name="selectionStart" onset="this.inputField.selectionStart = val; return val;"
                                      onget="return this.inputField.selectionStart;"/>
      <property name="selectionEnd"   onset="this.inputField.selectionEnd = val; return val;"
                                      onget="return this.inputField.selectionEnd;"/>
     
      <property name="suppressFocusBlur">
        false
      </property>

      <method name="setSelectionRange">
        <parameter name="aSelectionStart"/>
        <parameter name="aSelectionEnd"/>
        <body>
          this.inputField.setSelectionRange( aSelectionStart, aSelectionEnd );
        </body>
      </method>

    </implementation>
    <handlers>
      <handler event="focus" phase="capturing">
      <![CDATA[
        if (this.getAttribute('focused') != 'true') {
          this.setAttribute('focused','true');
          this.suppressFocusBlur = true;
          if (document.commandDispatcher.focusedElement != this.inputField) 
            this.inputField.focus();
          this.suppressFocusBlur = false;
        }
      ]]>
      </handler>
      <handler event="blur" phase="capturing">
      <![CDATA[
        if (!this.suppressFocusBlur && this.getAttribute('focused') == 'true') {
          this.removeAttribute('focused');
        }
      ]]>
      </handler>
      <!-- Ensure that our state gets saved/restored across skin switches. -->
       <handler event="bindingattached" action="var str = this.boxObject.getProperty('value'); 
                                                if (str) {
                                                  this.inputField.value=str;
                                                  this.boxObject.removeProperty('value');
                                                }"/>
       <handler event="bindingdetached" action="if (this.inputField.value) this.boxObject.setProperty('value', this.inputField.value);"/>
   </handlers>    
  </binding>

  <binding id="textarea" extends="chrome://global/content/xulBindings.xml#textfield">
    <content context="_child">
      <xul:box class="textarea-internal-box" flex="1">
        <html:textarea class="textfield-textarea" flex="1" inherits="onfocus,onblur,value,disabled,rows,cols,readonly"/>
      </xul:box>
      <xul:popupset>
        <xul:popup oncreate="this.focus()">
          <xul:menuitem value="&undoCmd.label;" accesskey="&undoCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_undo');              
            controller.doCommand('cmd_undo');"/>
          <xul:menuseparator/>
          <xul:menuitem value="&cutCmd.label;" accesskey="&cutCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_cut');
            controller.doCommand('cmd_cut');"/>
          <xul:menuitem value="&copyCmd.label;" accesskey="&copyCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_copy');
            controller.doCommand('cmd_copy');"/>
          <xul:menuitem value="&pasteCmd.label;" accesskey="&pasteCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_paste');
            controller.doCommand('cmd_paste');"/>
          <xul:menuitem value="&deleteCmd.label;" accesskey="&deleteCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_cut');
            controller.doCommand('cmd_delete');"/>
           <xul:menuseparator/>
          <xul:menuitem value="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" oncommand="
            var controller = document.commandDispatcher.getControllerForCommand('cmd_selectAll');
            controller.doCommand('cmd_selectAll');"/>
        </xul:popup>
      </xul:popupset>
    </content>
    <implementation>
      <property name="inputField" readonly="true">
       <![CDATA[
        var v = document.getAnonymousNodes(this);
        var input = null;
        for (var i = 0; i < v.length; i++) {
          try {
            var l = v[i].getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "textarea");
            if (l.length > 0) {
              input = l[0];
              break;
            }
          } catch (e) {} 
        }
        input;
      ]]>
      </property>
    </implementation>
  </binding>

  <binding id="text-label">
    <handlers>
      <handler event="click" action="var forElementID = this.getAttribute('for'); if(forElementID) var forElement = document.getElementById(forElementID); if(forElement) forElement.focus();"/>
    </handlers>
  </binding>
  
  <binding id="text-editable-display" extends="chrome://global/content/xulBindings.xml#text"/>
  
  <binding id="text-editable-edit" extends="xul:box">
    <content>
      <xul:box flex="1">
        <html:input type="text" inherits="value,type,maxlength,disabled,size,readonly"/>
      </xul:box>
    </content>
    <handlers>
      <handler event="blur" action="this.setAttribute('mode','display');"/>
    </handlers>
  </binding>

  <binding id="tooltips" extends="chrome://global/content/xulBindings.xml#popups">
    <content>
      <xul:box class="popup-internal-box" orient="vertical" flex="1">
        <children/>
      </xul:box>
    </content>
  </binding>

  <binding id="popups">
    <content>
      <!--xul:box class="popup-internal-box" orient="vertical" flex="1" style="overflow: auto">
        <children/>
      </xul:box-->

      <xul:arrowscrollbox class="popup-internal-box" flex="1" orient="vertical">
		  <!--xul:box class="popup-internal-box" orient="vertical"-->
			<children/>
		  <!--/xul:box-->
      </xul:arrowscrollbox>

    </content>
    <implementation>
      <method name="openPopup">
        <parameter name="element"/>
        <parameter name="xpos"/>
        <parameter name="ypos"/>
        <parameter name="popuptype"/>
        <parameter name="anchoralignment"/>
        <parameter name="popupalignment"/>
        <body>
        <![CDATA[
          try {
            var popupSetBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIPopupSetBoxObject);
            var menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
          } catch(e) {}
          if (popupSetBox)
            popupSetBox.createPopup(element, this, xpos, ypos, popuptype, anchoralignment, popupalignment);
          else if (menuBox)
            menuBox.openMenu(true);
        ]]>
        </body>
      </method>
      <method name="closePopup">
        <body>
        <![CDATA[
          try {
            var popupSetBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIPopupSetBoxObject);
            var menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
          } catch(e) {}
          if (popupSetBox)
            popupSetBox.destroyPopup();
          else if (menuBox)
            menuBox.openMenu(false);
        ]]>
        </body>
      </method>
      <property name="activeChild">
        <getter>
          <![CDATA[
            try {
              var popupSetBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIPopupSetBoxObject);
              var menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
            } catch(e) {}
            if (popupSetBox)
              return popupSetBox.activeChild;
            else if (menuBox)
              return menuBox.activeChild;
            throw Components.results.NS_ERROR_FAILURE;
          ]]>
        </getter>
        <setter>
          <![CDATA[
            try {
              var popupSetBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIPopupSetBoxObject);
              var menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
            } catch(e) {}
            if (popupSetBox)
              return popupSetBox.activeChild = val;
            else if (menuBox)
              return menuBox.activeChild = val;
            throw Components.results.NS_ERROR_FAILURE;
          ]]>
        </setter>
      </property>
    </implementation>     
  </binding>
  
  <binding id="colorpicker" extends="xul:box">
    <implementation>
      <property name="color" onset="return this.setAttribute('color', val);"
                             onget="return this.getAttribute('color');"/>
      <property name="selectedItem"/>
    </implementation>
    <content>

      <xul:box flex="1" orient="vertical" onclick="parentNode.color = event.target.getAttribute('color');
                                                   try { parentNode.selectedItem.removeAttribute('selected'); } catch(e) { }
                                                   parentNode.selectedItem = event.target;
                                                   event.target.setAttribute('selected', 'true');">

      <xul:box align="horizontal">
        <xul:spring class="colorpickertile" style="background-color: #FFFFFF" color="#FFFFFF"/>
        <xul:spring class="colorpickertile" style="background-color: #FFCCCC" color="#FFCCCC"/>
        <xul:spring class="colorpickertile" style="background-color: #FFCC99" color="#FFCC99"/>
        <xul:spring class="colorpickertile" style="background-color: #FFFF99" color="#FFFF99"/>
        <xul:spring class="colorpickertile" style="background-color: #FFFFCC" color="#FFFFCC"/>
        <xul:spring class="colorpickertile" style="background-color: #99FF99" color="#99FF99"/>
        <xul:spring class="colorpickertile" style="background-color: #99FFFF" color="#99FFFF"/>
        <xul:spring class="colorpickertile" style="background-color: #CCFFFF" color="#CCFFFF"/>
        <xul:spring class="colorpickertile" style="background-color: #CCCCFF" color="#CCCCFF"/>
        <xul:spring class="colorpickertile" style="background-color: #FFCCFF" color="#FFCCFF"/>
      </xul:box>
      <xul:box align="horizontal">
        <xul:spring class="colorpickertile" style="background-color: #CCCCCC" color="#CCCCCC"/>
        <xul:spring class="colorpickertile" style="background-color: #FF6666" color="#FF6666"/>
        <xul:spring class="colorpickertile" style="background-color: #FFCC33" color="#FFCC33"/>
        <xul:spring class="colorpickertile" style="background-color: #FFFF66" color="#FFFF66"/>
        <xul:spring class="colorpickertile" style="background-color: #FFFF99" color="#FFFF99"/>
        <xul:spring class="colorpickertile" style="background-color: #66FF99" color="#66FF99"/>
        <xul:spring class="colorpickertile" style="background-color: #33FFFF" color="#33FFFF"/>
        <xul:spring class="colorpickertile" style="background-color: #66FFFF" color="#66FFFF"/>
        <xul:spring class="colorpickertile" style="background-color: #9999FF" color="#9999FF"/>
        <xul:spring class="colorpickertile" style="background-color: #FF99FF" color="#FF99FF"/>
      </xul:box>
      <xul:box align="horizontal">
        <xul:spring class="colorpickertile" style="background-color: #C0C0C0" color="#C0C0C0"/>
        <xul:spring class="colorpickertile" style="background-color: #FF0000" color="#FF0000"/>
        <xul:spring class="colorpickertile" style="background-color: #FF9900" color="#FF9900"/>
        <xul:spring class="colorpickertile" style="background-color: #FFCC66" color="#FFCC66"/>
        <xul:spring class="colorpickertile" style="background-color: #FFFF00" color="#FFFF00"/>
        <xul:spring class="colorpickertile" style="background-color: #33FF33" color="#33FF33"/>
        <xul:spring class="colorpickertile" style="background-color: #66CCCC" color="#66CCCC"/>
        <xul:spring class="colorpickertile" style="background-color: #33CCFF" color="#33CCFF"/>
        <xul:spring class="colorpickertile" style="background-color: #6666CC" color="#6666CC"/>
        <xul:spring class="colorpickertile" style="background-color: #CC66CC" color="#CC66CC"/>
      </xul:box>
      <xul:box align="horizontal">
        <xul:spring class="colorpickertile" style="background-color: #999999" color="#999999"/>
        <xul:spring class="colorpickertile" style="background-color: #CC0000" color="#CC0000"/>
        <xul:spring class="colorpickertile" style="background-color: #FF6600" color="#FF6600"/>
        <xul:spring class="colorpickertile" style="background-color: #FFCC33" color="#FFCC33"/>
        <xul:spring class="colorpickertile" style="background-color: #FFCC00" color="#FFCC00"/>
        <xul:spring class="colorpickertile" style="background-color: #33CC00" color="#33CC00"/>
        <xul:spring class="colorpickertile" style="background-color: #00CCCC" color="#00CCCC"/>
        <xul:spring class="colorpickertile" style="background-color: #3366FF" color="#3366FF"/>
        <xul:spring class="colorpickertile" style="background-color: #6633FF" color="#6633FF"/>
        <xul:spring class="colorpickertile" style="background-color: #CC33CC" color="#CC33CC"/>
      </xul:box>
      <xul:box align="horizontal">
        <xul:spring class="colorpickertile" style="background-color: #666666" color="#666666"/>
        <xul:spring class="colorpickertile" style="background-color: #990000" color="#990000"/>
        <xul:spring class="colorpickertile" style="background-color: #CC6600" color="#CC6600"/>
        <xul:spring class="colorpickertile" style="background-color: #CC9933" color="#CC9933"/>
        <xul:spring class="colorpickertile" style="background-color: #999900" color="#999900"/>
        <xul:spring class="colorpickertile" style="background-color: #009900" color="#009900"/>
        <xul:spring class="colorpickertile" style="background-color: #339999" color="#339999"/>
        <xul:spring class="colorpickertile" style="background-color: #3333FF" color="#3333FF"/>
        <xul:spring class="colorpickertile" style="background-color: #6600CC" color="#6600CC"/>
        <xul:spring class="colorpickertile" style="background-color: #993399" color="#993399"/>
      </xul:box>
      <xul:box align="horizontal">
        <xul:spring class="colorpickertile" style="background-color: #333333" color="#333333"/>
        <xul:spring class="colorpickertile" style="background-color: #660000" color="#660000"/>
        <xul:spring class="colorpickertile" style="background-color: #993300" color="#993300"/>
        <xul:spring class="colorpickertile" style="background-color: #996633" color="#996633"/>
        <xul:spring class="colorpickertile" style="background-color: #666600" color="#666600"/>
        <xul:spring class="colorpickertile" style="background-color: #006600" color="#006600"/>
        <xul:spring class="colorpickertile" style="background-color: #336666" color="#336666"/>
        <xul:spring class="colorpickertile" style="background-color: #000099" color="#000099"/>
        <xul:spring class="colorpickertile" style="background-color: #333399" color="#333399"/>
        <xul:spring class="colorpickertile" style="background-color: #663366" color="#663366"/>
      </xul:box>
      <xul:box align="horizontal">
        <xul:spring class="colorpickertile" style="background-color: #000000" color="#000000"/>
        <xul:spring class="colorpickertile" style="background-color: #330000" color="#330000"/>
        <xul:spring class="colorpickertile" style="background-color: #663300" color="#663300"/>
        <xul:spring class="colorpickertile" style="background-color: #663333" color="#663333"/>
        <xul:spring class="colorpickertile" style="background-color: #333300" color="#333300"/>
        <xul:spring class="colorpickertile" style="background-color: #003300" color="#003300"/>
        <xul:spring class="colorpickertile" style="background-color: #003333" color="#003333"/>
        <xul:spring class="colorpickertile" style="background-color: #000066" color="#000066"/>
        <xul:spring class="colorpickertile" style="background-color: #330099" color="#330099"/>
        <xul:spring class="colorpickertile" style="background-color: #330033" color="#330033"/>
      </xul:box>
      </xul:box>
    </content>
  </binding>

 <!-- NOTE: this should really extend menu, but doing this causes the menupopup to be ignored (bug) -->
  <binding id="colorpickerButton" extends="xul:box">
    <content>
      <xul:menu class="colorpicker-button-menu" allowevents="true" flex="1">
        <xul:box class="colorpicker-button-colorbox" flex="1"/>
        <xul:menupopup class="colorpicker-button-menupopup"
          oncreate="this.parentNode.parentNode.setAttribute('menuactive', 'true')"
          ondestroy="this.parentNode.parentNode.setAttribute('menuactive', 'false')">
          <xul:colorpicker inherits="palettename" allowevents="true"
           onclick="this.parentNode.parentNode.parentNode.pickerClicked(event)"/>
        </xul:menupopup>
      </xul:menu>
    </content>
    
    <implementation>
      <property name="onchange"/>
      
      <property name="color">
        <getter>
          return this.getAttribute("color");
        </getter>
        <setter>
          this.mColorBox.setAttribute("style", "background-color: " + val);
          return this.setAttribute("color", val);
        </setter>
      </property>
      <method name="initialize">
        <body><![CDATA[
          var change = this.getAttribute("onchange");
          if (change) this.onchange = new Function("event", change);
          
          var menu = document.getAnonymousNodes(this)[0];
          this.mPicker = menu.childNodes[1].childNodes[0];
          this.mColorBox = menu.childNodes[0];
        ]]></body>
      </method>
      <method name="pickerClicked">
        <parameter name="aEvent"/>
        <body><![CDATA[
          this.color = this.mPicker.color;
          this.mPicker.parentNode.closePopup();
          if (this.onchange) this.onchange(aEvent);
        ]]></body>
      </method>
    </implementation>
    <handlers>
      <handler event="bindingattached">this.initialize()</handler>
    </handlers>
  </binding>
  
  <!-- XUL <statusbar> -->
  <binding id="statusbar" extends="xul:box"/>
    
  <binding id="statusbar-panel" extends="xul:button">
    <content autostretch="never" valign="middle">
      <xul:image class="statusbar-panel-icon" inherits="src"/>
      <xul:text class="statusbar-panel-text" inherits="value,crop" crop="right" flex="1"/>
    </content>
    <implementation>
      <property name="value"
                onget="return this.getAttribute('value');"
                onset="this.setAttribute('value',val); return val;"/>
      <property name="src"
                onget="return this.getAttribute('src');"
                onset="this.setAttribute('src',val); return val;"/>
    </implementation>
  </binding>
  
  <binding id="browser">
    <implementation>
      <property name="docShell"
                readonly="true"
                onget="return this.boxObject.QueryInterface(Components.interfaces.nsIBrowserBoxObject).docShell;"/>
      <property name="webNavigation"
                readonly="true"
                onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"/>
      <property name="markupDocumentViewer"
                readonly="true"
                onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer);"/>
      <property name="contentViewerEdit"
                readonly="true"
                onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerEdit);"/>
      <property name="contentViewerFile"
                readonly="true"
                onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerFile);"/>
      <property name="documentCharsetInfo"
                readonly="true"
                onget="return this.docShell.documentCharsetInfo;"/>
    </implementation>
  </binding>

  <binding id="editor">
    <implementation>
      <property name="editorShell"
                readonly="true"
                onget="return this.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).editorShell"/>
    </implementation>
  </binding>

  <binding id="iframe">
    <implementation>
      <property name="docShell"
                readonly="true"
                onget="return this.boxObject.QueryInterface(Components.interfaces.nsIIFrameBoxObject).docShell"/>
    </implementation>
  </binding>

  <binding id="titledbox">
    <content>
      <xul:box class="titledbox-title" autostretch="never" orient="vertical">
        <children includes="title"/>
      </xul:box>
      <xul:box flex="1" class="titledbox-body" inherits="orient,autostretch,align,valign">
        <children/>
      </xul:box>
    </content>    
  </binding>
  
  <binding id="titledboxvalue">
    <content>
      <xul:box class="titledbox-title" autostretch="never" orient="vertical">
        <xul:title inherits="value"/>
      </xul:box>
      <xul:box flex="1" class="titledbox-body" inherits="orient,autostretch,align,valign">
        <children/>
      </xul:box>
    </content>    
  </binding>
  
  <binding id="title" extends="xul:box">
    <content>
      <xul:text inherits="value"/>
    </content>
  </binding>

  <binding id="autorepeatbutton-up">
     <content>
	    <xul:image class="autorepeatbutton-up"/>
	 </content>
  </binding>

  <binding id="autorepeatbutton-down">
     <content>
	    <xul:image class="autorepeatbutton-down"/>
	 </content>
  </binding>

  <binding id="scrollbox">
    <content>
	  <xul:box class="scrollbox-innerbox" inherits="orient,autostretch,align,valign">
	    <children/>
	  </xul:box>
	</content>
  </binding>

  <binding id="arrowscrollbox" extends="xul:stack">
    <content>
	  <xul:vbox 
	  onunderflow="
		  var button1 = this.firstChild;
		  var button2 = this.childNodes[2];
 		  button1.setAttribute('collapsed', 'true');
		  button2.setAttribute('collapsed', 'true');
      " 
	  onoverflow="
		  var button1 = this.firstChild;
		  var button2 = this.childNodes[2];
 		  button1.removeAttribute('collapsed');
		  button2.removeAttribute('collapsed');
      ">
	  <xul:autorepeatbutton autostretch="never" class="up" collapsed="true" 
	      oncommand="parentNode.childNodes[1].boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject).scrollByIndex(-1);"/>
	  <xul:scrollbox orient="vertical" flex="1">
		 <children/>
	  </xul:scrollbox>
	  <xul:autorepeatbutton autostretch="never" class="down" collapsed="true" 
	      oncommand="parentNode.childNodes[1].boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject).scrollByIndex(1);"/>
	  </xul:vbox>
    </content>
  </binding>

</bindings>

