<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%Links::Newsletter::browse%>
<html>
<head>
  <title><%site_title%>: Newsletter</title>
<%include include_common_head.html%>
  <script type="text/javascript" src="<%config.build_static_url%>/utils.js"></script>
  <script type="text/javascript">
    //<![CDATA[
function disableChildrenInit() {
    var formElements = document.getElementById('update').elements;
    var sub = formElements.subscribed || [];
    var unsub = formElements.unsubscribed || [];
    if (sub.length == undefined)
        sub = [sub];
    if (unsub.length == undefined)
        unsub = [unsub];
    for (var i = 0; i < sub.length; i++) {
        var subscribed = formElements['S' + sub[i].value];
        registerEvent(subscribed, 'onclick', _disableChildren);
        if (subscribed.checked) {
            subscribed.temp = _disableChildren;
            subscribed.temp();
            subscribed.temp = null;
        }
    }
    for (var i = 0; i < unsub.length; i++)
        registerEvent(formElements['S' + unsub[i].value], 'onclick', _disableChildren);
}

function _disableChildren() {
    var children = this.value.split(',');
    children.splice(0, 1);
    if (!children.length)
        return;

    var formElements = this.form.elements;
    for (var i = 0; i < children.length; i++) {
        formElements['S' + children[i]].checked = this.checked;
        formElements['S' + children[i]].disabled = this.checked;
    }
}

function checkSubscribedParent() {
    if (<%if parent_subscribed%>false<%else%>true<%endif%>)
        return;
    var formElements = document.getElementById('update').elements;
    var unsub = formElements.unsubscribed || [];
    if (unsub.length == undefined)
        unsub = [unsub];
    for (var i = 0; i < unsub.length; i++) {
        formElements['S' + unsub[i].value].checked = true;
        formElements['S' + unsub[i].value].disabled = true;
    }
}

registerEvent(window, 'onload', disableChildrenInit);
registerEvent(window, 'onload', checkSubscribedParent);
    //!]]>
  </script>
</head>
<body id="newsletter_browse">
<%include include_accessibility.html%>
  <div id="wrapper">
<%include include_header.html%>
<%include include_contentheader.html%>
    <div id="ocwrapper" class="clear">
      <div id="icwrapper" class="clear">
<%include include_leftsidebar.html%>
        <div id="contentwrapper" class="shadowleft">
<%include include_contentwrapper_top.html%>
          <div class="shadowtop"><div class="shadowtopleft"></div><div class="shadowtopright"></div></div>
          <div class="shadowright">
            <div id="content">
<%include include_content_top.html%>

<div class="crumb"><%Links::Utils::format_title($main_title_loop, separator => $crumb_separator, no_escape_separator => $no_escape_crumb_separator, include_home => 1, link_type => 2)%></div>
<h2>Newsletter</h2>

<p>
  Check the boxes of categories you'd like to subscribe to and click "Update Subscriptions."
  Click on a category's name to see subcategories.  Periodically, you'll
  receive an e-mail informing you of updates to your subscribed categories.
  You can <a href="<%config.db_cgi_url%>/subscribe.cgi?action=list">Unsubscribe</a>
  from any or all categories at any time.
</p>

<%if PPID ne ''%><a href="<%config.db_cgi_url%>/subscribe.cgi?root=<%PPID%>">Back to <%PPName%></a><br /><%endif%>

<form id="update" action="<%config.db_cgi_url%>/subscribe.cgi" method="post">
  <input type="hidden" name="action" value="update" />
  <%if root%><input type="hidden" name="root" value="<%escape_html root%>" /><%endif%>
<%~loop category%>
  <input type="checkbox" name="S<%ID%>" value="<%escape_html ID%><%if Children.length%>,<%endif%><%loop Children%><%loop_value%><%unless last%>,<%endunless%><%endloop%>"<%if Subscribed%> checked="checked"<%endif%> class="indent<%CatDepth%>" /><input type="hidden" name="<%if Subscribed%>subscribed<%else%>unsubscribed<%endif%>" value="<%escape_html ID%>" /><%if HasMoreChildren%><a href="<%config.db_cgi_url%>/subscribe.cgi?action=browse;root=<%ID%>"><%endif%><%Name%><%if HasMoreChildren%></a><%endif%><br />
<%~endloop%>
  <input type="submit" value="Update Subscriptions" class="submit" />
</form>

<%include include_content_bottom.html%>
            </div>
          </div>
          <div class="shadowbottom"><div class="shadowbottomleft"></div><div class="shadowbottomright"></div></div>
<%include include_contentwrapper_bottom.html%>
        </div>
<%include include_rightsidebar.html%>
      </div>
    </div>
<%include include_contentfooter.html%>
<%include include_footer.html%>
  </div>
</body>
</html>
