<%@ 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_SYSTEMMAINTENANCE_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_SYSTEMMAINTENANCE_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();
    }
    
    function checkAll( mForm ) {			
		for(var i=0 ; i<mForm.elements.length ; i++){ 
			var elem = mForm.elements[i];
			if(elem.name=='selectedIds') {
			    elem.checked=mForm.allItems.checked;
			}
		}
	}
	function setCategoryId( id ) {
        var form = document.forms[ 0 ];      
        form.categoryId.value = id;
        if (form.action.indexOf('?') == -1) {
          form.action = form.action + "?action.change.category=true";
        } else {
          form.action = form.action + "&action.change.category=true";
        }
        windowOpen = null;
        form.submit();
    }
	function showExplorer() {
        var w = 200;
        var h = 600;
        var leftPosition = screen.width/2  - w/2;
        var topPosition  = screen.height/2 - h/2;
        var settings ='height=' + h + ', width=' + w + ', top=' + topPosition + ', left=' + leftPosition;
        settings += ',scrollbars=yes,resizable';
        settings += ',toolbar=no, location=no, directories=no, status=true, menubar=no';
        windowOpen = window.open( '<vkc:rewrite page="/explorerTreeView.do"/>', 'EXPLORER_MAINVIEW', settings );
        windowOpen.focus();
        return false;
    }
    	
	function checkAllDocTypes( mForm ) {			
		for(var i=0 ; i<mForm.elements.length ; i++){ 
			var elem = mForm.elements[i];
			if(elem.name=='selectedDocTypeIds') {
			    elem.checked=mForm.allDocTypeItems.checked;
			}
		}
	}
	
	function doAction(elem) {
		var form = document.forms[0];
		var field = form.selectedCmdAction.value;

		if ( field == "noaction" || field == "noaction1" ) {
       		alert( '<vkc:message javascript="true" filter="false" key="error.noaction_choosen"/>' );
       		return;
		}
		

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

        disableAllButtons(elem);
       	form.submit();
	}

	function sort( mode ) {
        var form = document.forms[ 0 ];
        form.sortMode.value   = mode;
        form.submit();
    }
    
    function submitForm() {
        var form = document.forms[ 0 ];
        form.submit();
    }

    function gotoFirstPage() {
        var form   = document.forms[ 0 ];
        var field  = form.listIndex;
    
        if ( field.selectedIndex==0 )
            return;
    
        field.selectedIndex = 0;
        submitForm();
    }
    
    function gotoPrevPage() {
        var form   = document.forms[ 0 ];
        var field  = form.listIndex;
        var index  = field.selectedIndex;
    
        if ( index-1 < 0 )
            return;
    
        field.selectedIndex = index-1;
        submitForm();
    }
    
    function gotoNextPage() {
        var form   = document.forms[ 0 ];
        var field  = form.listIndex;
        var index  = field.selectedIndex;
    
        index = index + 1;
        if ( index>=field.options.length )
            return;
    
        field.selectedIndex = index;
        submitForm();
    }
    
    function gotoLastPage() {
        var form   = document.forms[ 0 ];
        var field  = form.listIndex;
        var length = field.options.length;
    
        if ( field.selectedIndex==length - 1 )
            return;
    
        field.selectedIndex = length - 1;
        submitForm();
    }
    
    function changeCatId(){
    var form = document.forms[ 0 ];	
    form.submit();
    
    }
  
    </script>

</head>
<body onload="init();" topmargin="0" marginheight="0">
<vkc:define id="form" nameSuffix="MaintenanceForm" type="vkc.administration.form.SystemMaintenanceForm" scope="request" toScope="request"/>

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

<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr><td align="right" nowrap="nowrap" colspan="5">&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"><!-- Systemmaintenance 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="/systemMaintenance.do" paramId="selectedContext" paramName="context" style="font-weight:normal;text-decoration:none;"><b><vkc:write name="form" property='<%= "contextName(" + context + ")" %>'/></b></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="/systemMaintenance.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"><!-- Systemmaintenance of the selected context -->
      <logic:equal name="form" property="selectedContext" value='<%= SystemMaintenanceForm.SEARCHCLASSIFYINDEX %>'>
        <jsp:include page="rebuildSearchIndex.jsp" flush="true" />
      </logic:equal>
      <logic:equal name="form" property="selectedContext" value='<%= SystemMaintenanceForm.CONVERTER %>'>
        <jsp:include page="converter.jsp" flush="true" />
      </logic:equal>
      <logic:equal name="form" property="selectedContext" value='<%= SystemMaintenanceForm.CONVERSIONS %>'>
        <jsp:include page="conversions.jsp" flush="true" />
      </logic:equal>
      <logic:equal name="form" property="selectedContext" value='<%= SystemMaintenanceForm.LOSTFOLDERS %>'>
        <jsp:include page="lostFolders.jsp" flush="true" />
      </logic:equal>
      <logic:equal name="form" property="selectedContext" value='<%= SystemMaintenanceForm.EXPORT %>'>
        <jsp:include page="export.jsp" flush="true" />
      </logic:equal>
      <logic:equal name="form" property="selectedContext" value='<%= SystemMaintenanceForm.IMPORT %>'>
        <jsp:include page="import.jsp" flush="true" />
      </logic:equal>
	</td>
</tr>
</table>
</body>
</html:html>