<%@ page language="java" %>
<%@ taglib uri="struts-bean"  prefix="bean"  %>
<%@ taglib uri="struts-html"  prefix="html"  %>
<%@ taglib uri="struts-logic" prefix="logic" %>
<%@ taglib uri="vkc-taglib"   prefix="vkc"   %>
<%@ page import="vkc.view.WebShare" %>
<%@ page import="vkc.view.form.SysLinkForm" %>
<%@ page import="vkc.db.entities.VKCCategory" %>
<%@ page import="vkc.view.PageId" %>
<%@ page import="vkc.view.TabId" %>

<%
	String categoryId = request.getParameter("categoryId");
	String documentId = request.getParameter("documentId");
	String subfolderId = request.getParameter("subfolderId");
	String anchor = request.getParameter("anchor");
	String pfad = WebShare.getLoginPage();
	Integer cid = null;
	Integer did = null;
	Integer sid = null;
	Integer aid = null;
	
	
	try {
		cid = Integer.valueOf(categoryId);
	} catch (NumberFormatException e) {
		cid = null;
	}

	try {
		did = Integer.valueOf(documentId);
	} catch (NumberFormatException e) {
		did = null;
	}

	try {
		sid = Integer.valueOf(subfolderId);
	} catch (NumberFormatException e) {
		sid = null;
	}

	try {
		if (anchor != null && anchor.startsWith("doc")) {
			aid = Integer.valueOf(anchor.substring("doc".length(), anchor.length()));
		}
	} catch (NumberFormatException e) {
		aid = null;
	}

	if (did != null) {
		pfad += "?linkType=documentLink&objectId=" + did;
	} else if (aid != null) {
		pfad += "?linkType=documentLink&objectId=" + aid;
	} else if (sid != null) {
		pfad += "?linkType=categoryLink&objectId=" + sid;
	} else if (cid != null) {
		pfad += "?linkType=categoryLink&objectId=" + cid;
	} else {
		pfad += "?linkType=categoryLink&objectId=" + VKCCategory.ROOT_CATEGORY_ID;
	}
	
	Integer viewId = (Integer)request.getSession().getAttribute(WebShare.SYSTEMVIEWTYPEID_KEY);
	
	if (PageId.CATEGORY_VIEW.equals(viewId)) {
		request.setAttribute("showExplorer", "true");
	}
%>

<vkc:init/>
<html:html locale="true">
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

    <title><vkc:message key="vkc.info"/></title>

	<vkc:cssinclude />
    <script type="text/javascript" src="<vkc:rewrite page='/common/utils.js'/>"></script>

	<script type="text/javascript">
    window.name = "MAINVIEW";
    
    function showLens() {
    	var showLens = false;
	    var treeview = getTreeView();
	
		if (treeview) {
	        if (document.getElementById) {
	            var cols = parent.document.getElementsByTagName('frameset')[0].cols;
	            var rows = parent.document.getElementsByTagName('frameset')[1].rows;
	
	        	if (cols.charAt(0) == '0' && rows.charAt(0) == '0') {
	        		showLens = true;
	        	}
	        } else if (document.all) {
	            var cols = parent.document.all('frameset')[0].cols;
	            var rows = parent.document.all('frameset')[1].rows;
	
	        	if (cols.charAt(0) == '0' && rows.charAt(0) == '0') {
	        		showLens = true;
	        	}
	        } else if (document.layers) {
	            var cols = parent.document.layers('frameset')[0].cols;
	            var rows = parent.document.layers('frameset')[1].rows;
	
	        	if (cols.charAt(0) == '0' && rows.charAt(0) == '0') {
	        		showLens = true;
	        	}
	        }
		} else {
			showLens = true;
		}
		
		return showLens;
	}    

    function toggleNavigator() {
        var mainView = getMainView()

        if (!mainView) {
            return;
        }
		
		<logic:present parameter="anchor">                             
            mainView.location.replace('<%=ctxPath%>/templates/<%=template%>/common/NavigatorFrameset.jsp?categoryId=<%=cid%>&anchor=<%=request.getParameter("anchor")%>');
        </logic:present>
        <%-- Navigator einblenden --%>
        <logic:notPresent parameter="anchor">
            mainView.location.replace('<%=ctxPath%>/templates/<%=template%>/common/NavigatorFrameset.jsp?categoryId=<%=cid%>');
    	</logic:notPresent>

        this.document.images['navigatorImage'].src = '<%=ctxPath + "/templates/" + template + "/gfx/trans.gif"%>';
    }
	</script>
</head>

<body marginwidth="5" marginheight="0" topmargin="0" bottommargin="5" leftmargin="5" rightmargin="5">
<basefont style="font-family:sans-serif; font-size:10pt;">
<table cellspacing=0 cellpadding=0 width="100%" border=0 bgcolor="#666666">
  <tr>
    <td width="100%" height=30>
	  <table cellSpacing=0 cellPadding=0 width="100%" border=0>
        <tr>
		  <td bgColor="dddddd" align=left width=100%>
            <table cellspacing=0 cellpadding=3 width=100% border=0>
              <tr>
                <td>
                  <font style="font-family:sans-serif; font-size:12pt;"><b><i><vkc:message key="vkc.info"/></i></b></font></td><td align=right><font style="font-family:sans-serif; font-size:10pt;"> </font>
                </td>
              </tr>
            </table>
          </td>
        </tr>
		<tr>
		  <td bgcolor="f2f2f2" width="100%">
            <table cellpadding=0 cellspacing=0 width="100%" border=0>
              <tr>
                <td align=center>
                  <table width="100%" cellpadding="5" cellspacing="2">
                    <tr><td>&nbsp;</td></tr>
                    <tr>
                      <td>
                        <p>
                        <logic:present name="vkcinfo">
                          <logic:present name="quota">
                             <vkc:message name="vkcinfo" arg0='<%=request.getAttribute("quota").toString()%>'/>
                          </logic:present>
                          <logic:notPresent name="quota"> 
                             <vkc:message name="vkcinfo"/>
                          </logic:notPresent>    
                          <logic:equal name="vkcinfo" value="vkc.info.access_denied">
                            <br/><br/>
                            <vkc:link page='<%=pfad%>'>
                              <u><vkc:message key="vkc.string.LoginAgain"/></u>
                              <logic:equal name="showExplorer" value="true">
                              <script type="text/javascript">
  							  var associatedTabId = <%=TabId.DOCUMENT_TAB%>;
        					  var tabView = getTabView();
                              	  
        					  if (tabView && tabView.systemviewtype == "categoryview" && tabView.selectedTabId == associatedTabId) {
                              	  var showLens = showLens();

								  if (showLens) {
								      document.write( '<vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="10" border="0"/>' );
								      document.write( '<vkc:link href="javascript:toggleNavigator();"><vkc:img page="/templates/${template.name}/gfx/navigator.gif" style="vertical-align:middle" border="0" alt="toggle navigator" imageName="navigatorImage" titleKey="vkc.string.show.explorer"/></vkc:link>' );
							      } else {
								      document.write( '<vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="10" border="0"/>' );
							          document.write( '<vkc:link href="javascript:toggleNavigator();"><vkc:img page="/templates/${template.name}/gfx/trans.gif" style="vertical-align:middle" border="0" alt="toggle navigator" imageName="navigatorImage" titleKey="vkc.string.show.explorer"/></vkc:link>' );
							      }
                              }
						      </script>
                              </logic:equal>
                            </vkc:link>
                          </logic:equal>
                        </logic:present>
	                    </p>
                      </td>
                    </tr>
                    <tr><td align="center"><hr size="1" noshade="noshade" width="100%" /></td></tr>
                    <tr>
                      <td align=center>
                        <vkc:button property="action.back" onclick="javascript:disableAllButtons(this);history.back();">
                          <vkc:message key="button.back"/>
                        </vkc:button>
                      </td>
                    </tr>
                    <tr><td>&nbsp;</td></tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html:html>