<%-- 
/**
  * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  * USA
  *
  * Component of: Red Hat Application Server
  * 
  * Initial Developers: Aizaz Ahmed
  *                     Vivek Lakshmanan
  *                     Andrew Overholt
  *                     Matthew Wringe
  *
  */
--%>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@ page contentType="text/html"
         import="olstore.entity.TypeLocalHome"
         import="olstore.entity.TypeLocal"
         import="olstore.entity.UserLocal"
         import="olstore.session.*"
         import="olstore.framework.EJBHomeFactory"
         import="java.util.Iterator"
         import="java.util.Collection"
%>

<div id="navcontainer">
<ul>

    <html:link action="/views/index.do"> Home </html:link>
    <html:link action="/create/ModUser.do"> Profile </html:link>
    <html:link action="/views/MyAccount.do"> My Account </html:link>
    <html:link action="/views/MyItems.do"> My Items </html:link>
    <html:link action="/views/index.do"> Products </html:link>

<%
    // this page should only be called from a protected context, so this is legal
    ShoppingCartLocal cart = (ShoppingCartLocal) session.getAttribute ( "shoppingCart" );
    UserLocal user = cart.getUser ();

    EJBHomeFactory factory=EJBHomeFactory.getInstance();
    TypeLocalHome typeHome = (TypeLocalHome)factory.getLocalHome (EJBHomeFactory.TYPE);
    Collection types = typeHome.findAll();
    Iterator it = types.iterator();
%>  <ul>  <%
    while ( it.hasNext() ) {
        TypeLocal type = (TypeLocal) it.next();
 	pageContext.setAttribute("typeQS", type, PageContext.REQUEST_SCOPE);

%>
	<html:link action="/views/index.do" paramName="typeQS" paramProperty="name" paramId="type"> <%=type.getName()%>
 	</html:link>
<%  } %>

    </ul>
    <html:link action="/checkout/Checkout.do"> Checkout </html:link>
    <html:link action="/login/Logout.do"> Logout </html:link>

<%
    if ( user.isAdmin() ) {
%>
        <li> <a href="#"> Admin</a> </li>
            <ul>
	        <html:link action="/admin/createItem.do"> Create Item </html:link>
		<html:link action="/admin/CreateType.do"> Create Type </html:link>
		<html:link action="/admin/EditStatus.do"> Update Orders </html:link>

            </ul>
<%
    }
%>
</ul>
</div>
