<script type="text/javascript">
/* <![CDATA[ */
var multiBlogRebuilds = new Array();
<mt:loop name="rebuilds_loop">
multiBlogRebuilds[multiBlogRebuilds.length] = new Array ("<mt:var name="action_name" escape="html">", "<mt:var name="action_value">", "<mt:var name="blog_name" escape="html">", "<mt:var name="blog_id">", "<mt:var name="trigger_name">", "<mt:var name="trigger_value">");
</mt:loop>

function rebuildMultiBlogTriggerTable() {
    DOM.addClassName(getByID('multiblog_blog_list_zero_state'), 'hidden');
    DOM.removeClassName(getByID('multiblog_blog_list'), 'hidden');
    getByID('multiblog_blog_list').innerHTML = "";
    getByID('rebuild_triggers').value = "";
    if (multiBlogRebuilds.length > 0) {
        var values = new Array();
        var str = "";
        for (var i = 0; i < multiBlogRebuilds.length; i++) {
            str += "<tr class=\"" + ((i + 1) % 2 == 0 ? "even" : "odd") + "\">";
            str += "<td class=\"col\"> <__trans phrase="When"> "
                + multiBlogRebuilds[i][2]
                + "</td><td class='col'>"
                + multiBlogRebuilds[i][4]
                + "</td>";
            str += "<td class='col'>" + multiBlogRebuilds[i][0] + "</td>";
            str += "<td class='col si'><a href='javascript:void(0)' onclick='removeMultiBlogTrigger(" + i + ")'><img alt='<__trans phrase="Remove">' src='<mt:var NAME='STATIC_URI'>images/nav_icons/mini/delete.gif' /></a></td>";
            str += "</tr>\n";
            values[i] = multiBlogRebuilds[i][1];
            values[i] += ":";
            values[i] += multiBlogRebuilds[i][3];
            values[i] += ":";
            values[i] += multiBlogRebuilds[i][5];
        }
        str = "<table class='legacy listing-table'><thead><tr><th class='col head primary'><span class='col-label'><__trans phrase="Website/Blog" escape="js"></span></th><th class='col head primary'><span class='col-label'><__trans phrase="Trigger" escape="js"></span></th><th class='col head primary'><span class='col-label'><__trans phrase="Action" escape="js"></span></th><th class='col head si'><img alt='<__trans phrase="Remove">' src='<mt:var name='static_uri'>images/nav_icons/mini/delete.gif' /></th></tr></thead><tfoot><tr><th class='col head primary'><span class='col-label'><__trans phrase="Weblog" escape="js"></span></th><th class='col head primary'><span class='col-label'><__trans phrase="Trigger" escape="js"></span></th><th class='col head primary'><span class='col-label'><__trans phrase="Action" escape="js"></span></th><th class='col head si'><img alt='<__trans phrase="Remove">' src='<mt:var name="static_uri">images/nav_icons/mini/delete.gif' /></th></tr></tfoot>\n" + str + "</table>";
        getByID('multiblog_blog_list').innerHTML = str;
        getByID('rebuild_triggers').value = values.join('|');
    }
}

function removeMultiBlogTrigger(index) {
    multiBlogRebuilds.splice(index, 1);
    rebuildMultiBlogTriggerTable();
}

function addMultiBlogTrigger(actionName, actionValue, blogName, blogId, triggerName, triggerValue) {
    multiBlogRebuilds[multiBlogRebuilds.length] = [actionName, actionValue, blogName, blogId, triggerName, triggerValue];
    rebuildMultiBlogTriggerTable();
}
/* ]]> */
</script>

<mtapp:setting
   id="blog_content_accessible"
   label="<__trans phrase="Content Privacy">"
   hint="<__trans phrase="Specify whether other blogs in the installation may publish content from this blog. This setting takes precedence over the default system aggregation policy found in the system-level MultiBlog configuration.">"
   show_hint="0">
  <select name="blog_content_accessible" id="blog_content_accessible">
    <option value="0"><__trans phrase="Use system default"></option>
    <option value="2"<mt:if name="blog_content_accessible_2"> selected="selected"</mt:if>><__trans phrase="Allow"></option>
    <option value="1"<mt:if name="blog_content_accessible_1"> selected="selected"</mt:if>><__trans phrase="Disallow"></option>
  </select>
</mtapp:setting>

<mtapp:setting
   id="default_mtmultiblog_action"
   label="<__trans phrase="MTMultiBlog tag default arguments">"
   hint="<__trans phrase="Enables use of the MTMultiBlog tag without include_blogs/exclude_blogs attributes. Comma-separated BlogIDs or 'all' (include_blogs only) are acceptable values.">"
   show_hint="1">
  <select name="default_mtmultiblog_action" id="default_mtmultiblog_action">
    <option value="1"<mt:if name="default_mtmultiblog_action_1"> selected="selected"</mt:if>><__trans phrase="Include blogs"></option>
    <option value="0"<mt:if name="default_mtmultiblog_action_0"> selected="selected"</mt:if>><__trans phrase="Exclude blogs"></option>
  </select>
  <input name="default_mtmulitblog_blogs" type="text" value="<mt:var name="default_mtmulitblog_blogs">" />
</mtapp:setting>

<mtapp:setting
   id="rebuild_triggers"
   label="<__trans phrase="Rebuild Triggers">"
   hint=""
   show_hint="0">
  <input type="hidden" name="rebuild_triggers" id="rebuild_triggers" value="<mt:var name="rebuild_triggers">" />
  <input type="hidden" name="old_rebuild_triggers" id="old_rebuild_triggers" value="<mt:var name="rebuild_triggers">" />
  <p><a href="<mt:var name="script_url">?__mode=multiblog_add_trigger&amp;blog_id=<mt:var name="blog_id">" class="icon-left icon-create mt-open-dialog"><__trans phrase="Create Rebuild Trigger"></a></p>
  <mt:unless name="rebuilds_loop">
    <mtapp:statusmsg
       id="info"
       class="info"
       can_close="0">
      <__trans phrase="You have not defined any rebuild triggers.">
    </mtapp:statusmsg>
  </mt:unless>
  <div id="multiblog_blog_list" class="listing hide_actions<mt:unless name="rebuilds_loop"> hidden</mt:unless>"></div>
</mtapp:setting>

<mt:if name="rebuilds_loop">
<script type="text/javascript">
<!--
rebuildMultiBlogTriggerTable();
// -->
</script>
</mt:if>
