<%@ page language="java" buffer="100kb" %>
<%@ page import="vkc.view.*" %>

<%@ 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:init/>

<html:html locale="true">

<head>

    <meta http-equiv="content-type"  content="text/html; charset=iso-8859-1" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="pragma"        content="no-cache" />
    <meta http-equiv="expires"       content="0" />
    <meta http-equiv="robots"        content="index" />
    <meta http-equiv="robots"        content="follow" />

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

	<vkc:cssinclude />

	<style type="text/css">
	#logoutButton { position:absolute; top:24px; right:10px; z-index:1; }
	</style>

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

<body onload="init();" id="tabview" marginwidth="0" marginheight="0">
<logic:notPresent name="<%=WebShare.PREV_USER_KEY%>" scope="session">
<logic:equal name="user" property="guestUser" value="false">
<div id="logoutButton">
<table width="1" cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td><vkc:link page="/logout.do" target="MAINFRAMESET" onfocus="return window.status='';" onmouseover="return window.status='';"><vkc:img page="/templates/${template.name}/gfx/logoff.gif" width="16" height="16" border="0" hspace="5" alt=""/></vkc:link></td>
    <td nowrap="nowrap"><vkc:link page="/logout.do" target="MAINFRAMESET" onfocus="return window.status='';" onmouseover="return window.status='';"><vkc:message key="vkc.string.Logout"/></vkc:link></td>
  </tr>
</table>
</div>
</logic:equal>

<logic:equal name="user" property="guestUser" value="true">
<div id="logoutButton">
<table width="1" cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td><vkc:link page="/logout.do" target="MAINFRAMESET" onfocus="return window.status='';" onmouseover="return window.status='';"><vkc:img page="/templates/${template.name}/gfx/login.gif" width="16" height="16" border="0" hspace="5" alt=""/></vkc:link></td>
    <td nowrap="nowrap"><vkc:link page="/logout.do" target="MAINFRAMESET" onfocus="return window.status='';" onmouseover="return window.status='';"><vkc:message key="vkc.string.Login"/></vkc:link></td>
  </tr>
</table>
</div>
</logic:equal>
</logic:notPresent>

<logic:present name="<%=WebShare.PREV_USER_KEY%>" scope="session">
<div id="logoutButton">
<table width="1" cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td><vkc:link page="/restoreAccount.do" target="MAINFRAMESET" onfocus="return window.status='';" onmouseover="return window.status='';"><vkc:img page="/templates/${template.name}/gfx/button-restoreaccount.gif" width="16" height="16" border="0" hspace="5" alt=""/></vkc:link></td>
    <td nowrap="nowrap"><vkc:link page="/restoreAccount.do" target="MAINFRAMESET" onfocus="return window.status='';" onmouseover="return window.status='';"><vkc:message key="vkc.string.restoreAccount"/></vkc:link></td>
  </tr>
</table>
</div>
</logic:present>

<table width="100%" cellspacing="0" cellpadding="0" border="0">

  <html:form action="/vkcTabView" method="post">

  <bean:define id="form" name="vkcTabViewForm" type="vkc.view.form.TabViewForm" scope="request"/>
  <bean:define id="selectedTabId" name="form" type="java.lang.Integer" property="selectedTabId" />

  <html:hidden name="form" property="lastCategoryId" />
  <html:hidden name="form" property="lastFunctionalId" />
  <html:hidden name="form" property="lastProjectId" />
  <html:hidden name="form" property="viewId" />
  <html:hidden name="form" property="selectedAddTabId" />
  <html:hidden name="form" property="selectedTabId" />
  <html:hidden name="form" property="selectedViewId" />

  <tr>
    <td valign="bottom">
      <table align="left" cellpadding="0" cellspacing="0">
        <tr><td valign="middle" align="center"><vkc:img page="/templates/${template.name}/gfx/vkc-logo-blau.gif" alt="VKC" hspace="5" vspace="5"/></td></tr>
        <tr><td background="<vkc:rewrite page='/templates/${template.name}/gfx/grey-line.gif'/>"><vkc:img page="/templates/${template.name}/gfx/trans.gif" border="0" alt=""/></td></tr>
      </table>
    </td>

    <td valign="bottom" width="100%">
      <table align="left" cellpadding="0" cellspacing="0" width="100%">
    	<logic:equal name="form" property="allowSystemViewTypeSwitch" value="true">
        <tr>
          <td align="left" valign="top">
	        <table align="center" valign="top" cellpadding="0" cellspacing="0">
	          <tr>
                <bean:define id="selectedViewId" name="form" property="selectedViewId" type="java.lang.Integer"/>

				<td><vkc:img page="/templates/${template.name}/gfx/blue-tab-corner-left.gif" border="0" alt=""/></td>
				<td><vkc:img page="/templates/${template.name}/gfx/blue-tab-spacer.gif" width="5" height="17" border="0" alt=""/></td>
						        
		        <logic:iterate id="info" name="form" property="systemTabInfos" type="vkc.view.bean.TabInfo">
		        <logic:equal name="info" property="tabId" value="<%=String.valueOf(selectedViewId)%>">
		      	<td><vkc:img page="/templates/${template.name}/gfx/blue-tab-light-left.gif" border="0" alt=""/></td>
		        <td valign="bottom" nowrap="nowrap" background="<vkc:rewrite page='/templates/${template.name}/gfx/blue-tab-light-body.gif'/>"><font class="smallFont"><b><vkc:write name="info" property="tabName"/></b></font></td>
		        <td><vkc:img page="/templates/${template.name}/gfx/blue-tab-light-right.gif" border="0" alt=""/></td>
		        </logic:equal>

		        <logic:notEqual name="info" property="tabId" value="<%=String.valueOf(selectedViewId)%>">
		      	<td><vkc:img page="/templates/${template.name}/gfx/grey-tab-dark-left.gif" border="0" alt=""/></td>
		        <td valign="bottom" nowrap="nowrap" background="<vkc:rewrite page='/templates/${template.name}/gfx/grey-tab-dark-body.gif'/>"><vkc:link href='<%="javascript:changeSystemTabView(" + info.getTabId() + ");"%>' title="<%=info.getTabDescription()%>" style="color:#666666; text-decoration:none;"><font class="smallFont"><b><vkc:write name="info" property="tabName"/></b></font></vkc:link></td>
		        <td><vkc:img page="/templates/${template.name}/gfx/grey-tab-dark-right.gif" border="0" alt=""/></td>
		        </logic:notEqual>
		        
		        <td><vkc:img page="/templates/${template.name}/gfx/blue-tab-spacer.gif" width="5" height="17" border="0" alt=""/></td>

		        </logic:iterate>
		        <td><vkc:img page="/templates/${template.name}/gfx/blue-tab-corner-right.gif" border="0" alt=""/></td>
	          
	            <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" width="76" height="17" border="0"/></td>
	          </tr>
	        </table>
	      </td>
	    </tr>
		</logic:equal>

        <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" height="7" border="0" alt=""/></td></tr>
        <tr>
          <td valign="middle">
	        <table align="left" cellpadding="0" cellspacing="0">
	          <tr>
                <td width="214"><vkc:img page="/templates/${template.name}/gfx/vkc-banner.gif" alt="Virtual Knowledge Center"/></td>
              </tr>
	        </table>
	      </td>  
        </tr>
        <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" height="10" border="0" alt=""/></td></tr>
        <tr>
          <td>
	        <table align="center" cellpadding="0" cellspacing="0" width="100%">
	          <tr>
		        <logic:iterate id="info" name="form" property="visibleTabInfos" type="vkc.view.bean.TabInfo">
		        <logic:equal name="info" property="tabId" value="<%=String.valueOf( selectedTabId )%>">
		          <%-- selektiertes Tab --%>
		      	  <td><vkc:img page="/templates/${template.name}/gfx/tab-light-left.gif" border="0" alt=""/></td>
		      	  <logic:equal name="info" property="tabId" value="<%=String.valueOf( TabId.DOCUMENT_TAB )%>">
		      	  <td nowrap="nowrap" background="<vkc:rewrite page='/templates/${template.name}/gfx/tab-light-body.gif'/>"><b><vkc:write name="info" property="tabName"/></b></td>
		      	  </logic:equal>
		      	  <logic:notEqual name="info" property="tabId" value="<%=String.valueOf( TabId.DOCUMENT_TAB )%>">
		          <td nowrap="nowrap" background="<vkc:rewrite page='/templates/${template.name}/gfx/tab-light-body.gif'/>"><vkc:link page="<%=info.getTabLink()%>" title="<%=info.getTabLabel()%>" style="text-decoration:none;" target="MAINVIEW"><b><vkc:write name="info" property="tabName"/></b></vkc:link></td>
		          </logic:notEqual>
		          <td><vkc:img page="/templates/${template.name}/gfx/tab-light-right.gif" border="0" alt=""/></td>
		          <td><vkc:img page="/templates/${template.name}/gfx/borderline.gif" width="5" height="27" border="0" alt=""/></td>
		        </logic:equal>
		
		        <logic:notEqual name="info" property="tabId" value="<%=String.valueOf( selectedTabId )%>">
		      	  <%-- nicht selektiertes Tab --%>
		      	  <td><vkc:img page="/templates/${template.name}/gfx/tab-grey-left.gif" border="0" alt=""/></td>
		      	  <td nowrap="nowrap" background="<vkc:rewrite page='/templates/${template.name}/gfx/tab-grey-body.gif'/>"><vkc:link page="<%=info.getTabLink()%>" title="<%=info.getTabLabel()%>" style="color:#666666; text-decoration:none;" target="MAINVIEW"><vkc:write name="info" property="tabName"/></vkc:link></td>
		      	  <td><vkc:img page="/templates/${template.name}/gfx/tab-grey-right.gif" border="0" alt=""/></td>
		      	  <td><vkc:img page="/templates/${template.name}/gfx/borderline.gif" width="5" height="27" border="0" alt=""/></td>
		        </logic:notEqual>
		        </logic:iterate>
		      
			    <td valign="bottom" width="100%">
			      <table cellpadding="0" cellspacing="0" width="100%">
			        <tr><td background="<vkc:rewrite page='/templates/${template.name}/gfx/grey-line.gif'/>"><vkc:img page="/templates/${template.name}/gfx/trans.gif" width="10" height="1" border="0" alt=""/></td></tr>
			       </table>
			    </td>

                <bean:define id="selectedAddTabId" name="form" property="selectedAddTabId" type="java.lang.Integer"/>

		        <logic:iterate id="info" name="form" property="additionalTabInfos" type="vkc.view.bean.TabInfo">
		        <logic:equal name="info" property="tabId" value="<%=String.valueOf( selectedAddTabId )%>">
		      	  <td width="100%" align="right"><vkc:img page="/templates/${template.name}/gfx/tab-light-left.gif" border="0" alt=""/></td>
		          <td align="right" nowrap="nowrap" background="<vkc:rewrite page='/templates/${template.name}/gfx/tab-light-body.gif'/>"><vkc:link page="<%=info.getTabLink()%>" title="<%=info.getTabLabel()%>" style="text-decoration:none;" target="MAINVIEW" onclick='<%="javascript:changeAddTabView(" + info.getTabId() + ");"%>'><b><vkc:write name="info" property="tabName"/></b></vkc:link></td>
		          <td align="right"><vkc:img page="/templates/${template.name}/gfx/tab-light-right.gif" border="0" alt=""/></td>
		          <td align="right"><vkc:img page="/templates/${template.name}/gfx/borderline.gif" width="5" height="27" border="0" alt=""/></td>
		        </logic:equal>

		        <logic:notEqual name="info" property="tabId" value="<%=String.valueOf( selectedAddTabId )%>">
		      	  <td width="100%" align="right"><vkc:img page="/templates/${template.name}/gfx/tab-grey-left.gif" border="0" alt=""/></td>
		          <td align="right" nowrap="nowrap" background="<vkc:rewrite page='/templates/${template.name}/gfx/tab-grey-body.gif'/>"><vkc:link page="<%=info.getTabLink()%>" title="<%=info.getTabLabel()%>" style="color:#666666; text-decoration:none;" target="MAINVIEW" onclick='<%="javascript:changeAddTabView(" + info.getTabId() + ");"%>'><b><vkc:write name="info" property="tabName"/></b></vkc:link></td>
		          <td align="right"><vkc:img page="/templates/${template.name}/gfx/tab-grey-right.gif" border="0" alt=""/></td>
		          <td align="right"><vkc:img page="/templates/${template.name}/gfx/borderline.gif" width="5" height="27" border="0" alt=""/></td>
		        </logic:notEqual>
		        </logic:iterate>
			    <td valign="bottom" width="100%">
			      <table cellpadding="0" cellspacing="0" width="100%">
			        <tr><td background="<vkc:rewrite page='/templates/${template.name}/gfx/grey-line.gif'/>"><vkc:img page="/templates/${template.name}/gfx/trans.gif" width="10" height="1" border="0" alt=""/></td></tr>
			       </table>
			    </td>
		      </tr>
		    </table>
		  </td>
		</tr>
	  </table>
    </td>
  </tr>
  
  <script type="text/javascript">

    window.name = "TABVIEW";

	var selectedTabId = <vkc:write name="form" property="selectedTabId"/>;
    var viewId = <vkc:write name="form" property="viewId"/>;
	var lastCategoryId = <vkc:write name="form" property="lastCategoryId"/>;
    var systemviewtype = "categoryview";

    function init() {
        var main = getMainView();
        
        if (!main) {
            alert('Fehler: Fenster MAINVIEW nicht gefunden');
            
            return;
        }
        
        <logic:equal name="form" property="reloadMainview" value="true">
          parent.MAINVIEW.location.replace('<%=ctxPath%><vkc:write name="vkcTabViewForm" property="reloadPath"/>');
        </logic:equal>
    }

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

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

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

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

        form.submit();
    }

    function changeAddTabView(id) {
        var form = document.forms[0];
        form.selectedTabId.value = -1;
        form.selectedAddTabId.value = id;

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

        form.submit();
    }
  </script>

  </html:form>
</table>
</body>
</html:html>