<%@ page language="java" buffer="100kb" errorPage="/common/error.jsp"%>

<%@ page import="vkc.administration.form.*" %>
<%@ page import="vkc.view.TabId" %>

<%@ taglib uri="struts-html" 	prefix="html" %>
<%@ taglib uri="struts-bean" 	prefix="bean" %>
<%@ taglib uri="struts-logic" 	prefix="logic" %>
<%@ taglib uri="vkc-taglib" 	prefix="vkc" %>

<vkc:checkLogin />
<vkc:init/>
<html:html locale="true">
<head>

    <vkc:cssinclude />

    <meta http-equiv="content-type"  content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="<vkc:rewrite page='/common/utils.js'/>"></script>

    <script type="text/javascript">
    window.name = "MAINVIEW";
    var associatedTabId = <%=TabId.ADMIN_SYSTEMDEFAULTS_TAB%>;
    	
    function init() {
      	var tabView = getTabView();
        var tabViewForm = tabView.document.forms[0];

        if (tabView && tabView.systemviewtype == "administrationview" && tabView.selectedTabId != associatedTabId) {
          	tabView.location.replace("<%=ctxPath%>/adminTabView.do?selectedTabId=<%=TabId.ADMIN_SYSTEMDEFAULTS_TAB%>"
          						   + "&lastCategoryId=" + tabViewForm.lastCategoryId.value
          						   + "&lastFunctionalId=" + tabViewForm.lastFunctionalId.value
          						   + "&lastProjectId=" + tabViewForm.lastProjectId.value);
        }

		setAnchor();
    }

	function setAnchor() {
		<logic:present parameter="anchor">
	      <bean:parameter id="anchor2" name="anchor"/>
		  this.location.hash = '<%=anchor2%>';
		</logic:present>
	}

    function showFile(id) {
        var form = document.forms[0];
        form.selectedParamterId.value = id;

        if (form.action.indexOf('?') == -1) {
          form.action = form.action + "?action.show.file=true";
        } else {
          form.action = form.action + "&action.show.file=true";
        }

        form.submit();
    }

    </script>

</head>
<body onload="init();" topmargin="0" marginheight="0">
<html:form action="/systemDefaults" method="post">

<bean:define id="form" name="systemDefaultsForm" type="vkc.administration.form.SystemDefaultsForm" toScope="request"/>

<html:hidden property="selectedContext"/>

<table width="100%" align="left" cellspacing="0" cellpadding="0" border="0">
  <logic:present name="<%=org.apache.struts.Globals.ERROR_KEY%>">
  <html:messages id="error" message="false">
    <tr><td align="left" nowrap="nowrap" colspan="5"><span class="error"><b><vkc:write name="error"/></b></span></td></tr>
  </html:messages>
  <vkc:hline colspan="5" lineClass="hline" lineHeight="1" topSpace="5" bottomSpace="5"/>
  </logic:present>

  <tr><td colspan="5" nowrap="nowrap" align="right">&nbsp;<vkc:message key="mandatory.field1"/>&nbsp;<vkc:img page="/templates/${template.name}/gfx/mandatoryField.gif" alt="*" border="0"/>&nbsp;<vkc:message key="mandatory.field2"/></td></tr>

  <vkc:hline colspan="5" lineClass="hline" lineHeight="1" topSpace="5" bottomSpace="5"/>

  <tr>
	<td valign="top"><!-- Systemdefault Contexts -->
	  <table width="100%" cellpadding="2" cellspacing="0" border="0">
		<logic:iterate id="context" type="java.lang.String" name="form" property="contextNames">
		<tr>
          <logic:equal name="form" property="selectedContext" value="<%=context%>">
          <td nowrap="nowrap"><vkc:img page="/templates/${template.name}/gfx/arrow-right.gif" alt=""/></td>
          <td nowrap="nowrap"><vkc:link page="/systemDefaults.do" paramId="selectedContext" paramName="context" style="font-weight:bold;text-decoration:none;"><vkc:write name="form" property='<%= "contextName(" + context + ")" %>'/></vkc:link></td>
          </logic:equal>
            
          <logic:notEqual name="form" property="selectedContext" value="<%=context%>">
          <td nowrap="nowrap"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="1" height="1"/></td>
          <td nowrap="nowrap"><vkc:link page="/systemDefaults.do" paramId="selectedContext" paramName="context" style="font-weight:normal;text-decoration:none;"><vkc:write name="form" property='<%= "contextName(" + context + ")" %>'/></vkc:link></td>
          </logic:notEqual>
        </tr>
	    </logic:iterate>
  	  </table>
	</td>

    <td width="5" valign="top"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="5" height="1"/></td>
    <td width="1" valign="top" class="hline"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="1" height="1"/></td>
    <td width="5" valign="top"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="5" height="1"/></td>

	<td width="100%" align="left" valign="top"><!-- Systemdefaults of the selected context -->
      <logic:equal name="form" property="selectedContext" value='<%= SystemDefaultsForm.DEFAULTLANGUAGES %>'>
        <jsp:include page="defaultLanguages.jsp" flush="true" />
      </logic:equal>

      <logic:equal name="form" property="selectedContext" value='<%= SystemDefaultsForm.TABVIEWSETTINGS %>'>
        <jsp:include page="tabViewSettings.jsp" flush="true" />
      </logic:equal>

      <logic:equal name="form" property="selectedContext" value='<%= SystemDefaultsForm.DOCUMENTVIEWFIELDS %>'>
        <jsp:include page="documentViewFields.jsp" flush="true" />
      </logic:equal>

      <logic:equal name="form" property="selectedContext" value='<%= SystemDefaultsForm.ADDCATATTRIBUTES %>'>
        <jsp:include page="addCatAttributes.jsp" flush="true" />
      </logic:equal>

      <logic:equal name="form" property="selectedContext" value='<%= SystemDefaultsForm.ADDDOCATTRIBUTES %>'>
        <jsp:include page="addDocAttributes.jsp" flush="true" />
      </logic:equal>
	</td>
</tr>
</table>
</html:form>
</body>
</html:html>
