<?xml version="1.0"?>
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?> 
<!DOCTYPE dialog SYSTEM "chrome://communicator/locale/permissions/cookieP3P.dtd">
<dialog id="privacySettings"
        buttons="accept,cancel"
        title="&windowtitle.label;"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        onload="init();"
        ondialogaccept="return onOK();"
        style="width: 45em;">
  <script type="application/x-javascript">
  <![CDATA[
  var pref;
  var low = 0;
  var medium = 1;
  var high = 2;
  var custom = 3;
  var p3pLength = 8;
  function init()
  {
    // get pref service
    pref = Components.classes['@mozilla.org/preferences-service;1'];
    pref = pref.getService();
    pref = pref.QueryInterface(Components.interfaces.nsIPrefBranch);
    var p3pLevel = medium;
    try {
      // set prefLevel radio button
      p3pLevel = pref.getIntPref("network.cookie.p3plevel");
      document.getElementById("p3pLevel").value = p3pLevel;
      // set custom settings
      if (p3pLevel == custom) {
        for (var i=0; i<p3pLength; i++) {
          document.getElementById("menulist_"+i).value =
            pref.getCharPref("network.cookie.p3p").charAt(i);
        }
      }
    } catch(e) {
    }
    // initialize the settings display
    settings(p3pLevel);
  }
  function onOK(){
    var p3pLevel = document.getElementById("p3pLevel").value;
    pref.setIntPref("network.cookie.p3plevel", p3pLevel);
    var value = "";
    for (var i=0; i<p3pLength; i++) {
      value += document.getElementById("menulist_"+i).value;
    }
    pref.setCharPref("network.cookie.p3p", value);
    return true;
  }
  function settings(level) {
    var settings = [];
    switch (level) {
      case low:
        settings = "afafaaaa";
        break;
      case medium:
        settings = "ffffaaaa";
        break;
      case high:
        settings = "frfradaa";
        break;
      case custom:
        break;
    }
    var hide = (level != custom);
    var menulist;
    for (var j=0; j<p3pLength; j++) {
      menulist = document.getElementById("menulist_" + j);
      menulist.disabled = hide;
      if (hide) {
        menulist.value = settings[j];
      }
    }
  }
  ]]>
  </script>
  <groupbox orient="vertical">
    <caption label="&privacyLevel.label;"/>
    <description>&p3pDetails;</description>
    <spacer/>
    <description>&choose;</description>
    <radiogroup id="p3pLevel" orient="horizontal" align="center">
      <radio group="p3pLevel" value="0" label="&low.label;"
             accesskey="&low.accesskey;" oncommand="settings(low);"/>
      <radio group="p3pLevel" value="1" label="&medium.label;"
             accesskey="&medium.accesskey;" oncommand="settings(medium);"/>
      <radio group="p3pLevel" value="2" label="&high.label;"
             accesskey="&high.accesskey;" oncommand="settings(high);"/>
      <radio group="p3pLevel" value="3" label="&custom.label;"
             accesskey="&custom.accesskey;" oncommand="settings(custom);"/>
    </radiogroup>
  </groupbox>
  <groupbox id="customSettingBox" orient="vertical">
    <caption label="&customSettings.label;"/>
    <grid>
      <columns>
        <column flex="1"/>
        <column width="120"/>
        <column width="120"/>
      </columns>
      <rows>
        <row align="center">
          <spacer/>
          <description>&firstParty.label;</description>
          <description>&thirdParty.label;</description>
        </row>
        <row align="center">
          <description>&noPolicy.label;</description>
          <menulist flex="1" id="menulist_0">
            <menupopup>
              <menuitem value="a" label="&accept.label;"/>
              <menuitem value="f" label="&flag.label;"/>
              <menuitem value="d" label="&downgrade.label;"/>
              <menuitem value="r" label="&reject.label;"/>
            </menupopup>
          </menulist>
          <menulist flex="1" id="menulist_1">
            <menupopup>
              <menuitem value="a" label="&accept.label;"/>
              <menuitem value="f" label="&flag.label;"/>
              <menuitem value="d" label="&downgrade.label;"/>
              <menuitem value="r" label="&reject.label;"/>
            </menupopup>
          </menulist>
        </row>
        <row align="center">
          <description>&noConsent.label;</description>
          <menulist flex="1" id="menulist_2">
            <menupopup>
              <menuitem value="a" label="&accept.label;"/>
              <menuitem value="f" label="&flag.label;"/>
              <menuitem value="d" label="&downgrade.label;"/>
              <menuitem value="r" label="&reject.label;"/>
            </menupopup>
          </menulist>
          <menulist flex="1" id="menulist_3">
            <menupopup>
              <menuitem value="a" label="&accept.label;"/>
              <menuitem value="f" label="&flag.label;"/>
              <menuitem value="d" label="&downgrade.label;"/>
              <menuitem value="r" label="&reject.label;"/>
            </menupopup>
          </menulist>
        </row>
        <row align="center">
          <description>&implicitConsent.label;</description>
          <menulist flex="1" id="menulist_4">
            <menupopup>
              <menuitem value="a" label="&accept.label;"/>
              <menuitem value="f" label="&flag.label;"/>
              <menuitem value="d" label="&downgrade.label;"/>
              <menuitem value="r" label="&reject.label;"/>
            </menupopup>
          </menulist>
          <menulist flex="1" id="menulist_5">
            <menupopup>
              <menuitem value="a" label="&accept.label;"/>
              <menuitem value="f" label="&flag.label;"/>
              <menuitem value="d" label="&downgrade.label;"/>
              <menuitem value="r" label="&reject.label;"/>
            </menupopup>
          </menulist>
        </row>
        <row align="center">
          <description>&explicitConsent.label;</description>
          <menulist flex="1" id="menulist_6">
            <menupopup>
              <menuitem value="a" label="&accept.label;"/>
              <menuitem value="f" label="&flag.label;"/>
              <menuitem value="d" label="&downgrade.label;"/>
              <menuitem value="r" label="&reject.label;"/>
            </menupopup>
          </menulist>
          <menulist flex="1" id="menulist_7">
            <menupopup>
              <menuitem value="a" label="&accept.label;"/>
              <menuitem value="f" label="&flag.label;"/>
              <menuitem value="d" label="&downgrade.label;"/>
              <menuitem value="r" label="&reject.label;"/>
            </menupopup>
          </menulist>
        </row>
      </rows>
    </grid>
  </groupbox>
</dialog>
