<?xml version="1.0"?>

<bindings id="textBindings"
   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="text-base">
    <implementation>
      <property name="disabled" onget="if (this.getAttribute('disabled') == 'true') return true; return false;"
                                onset="if (val) this.setAttribute('disabled', 'true');
                                       else this.removeAttribute('disabled'); 
                                       return val;"/>
      <property name="value" onget="return this.getAttribute('value');"
                             onset="this.setAttribute('value', val); return val;"/>
      <property name="crop" onget="return this.getAttribute('crop');"
                            onset="this.setAttribute('crop', val); return val;"/>
    </implementation>
  </binding>

  <binding id="text-label" extends="chrome://global/content/bindings/text.xml#text-base">
    <implementation>
      <property name="accessKey" onget="return this.getAttribute('accesskey');"
                                 onset="this.setAttribute('accesskey', val); return val;"/>
      <property name="control" onget="return this.getAttribute('control');"
                               onset="this.setAttribute('control', val); return val;"/>
    </implementation>
  </binding>

  <binding id="label-control" extends="chrome://global/content/bindings/text.xml#text-label">
    <handlers>
      <handler event="click" action="if (this.disabled) return;
                                     var forElementID = this.getAttribute('control');
                                     if (forElementID)
                                       var forElement = document.getElementById(forElementID);
                                     if(forElement)
                                       forElement.focus();
                                    "/>
    </handlers>
  </binding>

  <binding id="text-for" extends="chrome://global/content/bindings/text.xml#text-base">
    <handlers>
      <handler event="click" action="var forElementID = this.getAttribute('for');
                                     if (forElementID)
                                       var forElement = document.getElementById(forElementID);
                                     if(forElement)
                                       forElement.focus();
                                    "/>
    </handlers>
  </binding>
  
</bindings>

