<!-- $HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/apps/igeoportal-standard/branches/2.5_testing/menubartop.jsp $ -->
<%-- $Id: menubartop.jsp 25889 2010-08-16 05:43:37Z jwilden $ --%>
<%-- 
 This file is part of deegree, http://deegree.org/
 Copyright (C) 2001-2009 by:
 - Department of Geography, University of Bonn -
 and
 - lat/lon GmbH -

 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 (at your option)
 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

 Contact information:

 lat/lon GmbH
 Aennchenstr. 19, 53177 Bonn
 Germany
 http://lat-lon.de/

 Department of Geography, University of Bonn
 Prof. Dr. Klaus Greve
 Postfach 1147, 53001 Bonn
 Germany
 http://www.geographie.uni-bonn.de/deegree/

 e-mail: info@deegree.org
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="org.deegree.i18n.Messages" %>
<%@ page import="java.util.Locale" %>
<%
    Locale loc = request.getLocale();
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="author" content="lat/lon GmbH" />
        <meta name="KeyWords" content="deegree iGeoPortal lat/lon" />
        <title>deegree iGeoPortal</title>
        <link href="css/deegree.css" rel="stylesheet" type="text/css" />
        <script language="JavaScript1.2" type="text/javascript">
            function register() {
                if ( parent.controller == null ) {
                    parent.controller = new parent.Controller();
                    parent.controller.init();
                }
            }

            function initMenuBar() {
                parent.controller.initMenuBarTop(document);
            }

            function openHelp() {
                <%
                String lang = Locale.getDefault().getLanguage();
                // NOTE: if-branch needs to be adjusted as soon as other languages than "de" or "en" are supported
                if ( "".equals( lang ) || !"de".equals( lang ) ) {
                    lang = "en";
                }
                %>                
                var fiw = window.open( "./help/<%=lang%>/help.html", "Help",
                                       "width=925,height=775,left=100,top=100,resizable=no,scrollbars=yes");
                fiw.focus();
            }

            function gotoHome() {
                var fiw = window.open( "http://www.deegree.org", "Home",
                                       "width=600,height=400,left=100,top=100,scrollbars=yes");
                fiw.focus();
                //parent.controller.replace("http://www.deegree.org");
            }

            function openSaveContext() {
                var fiw = null;
                if ( parent.controller.vSessionKeeper != null && parent.controller.vSessionKeeper.id == null ) {
                    // the user has to login before saving a new context to the user's folder
                    fiw = window.open( "./missinglogin.jsp" ,"LoginInfo",
                                       "width=500,height=200,left=100,top=100,scrollbars=yes" );
                } else {
                    fiw = window.open( "./savecontext.jsp", "save",
                                       "width=500,height=200,left=100,top=100,scrollbars=yes" );
                }
                fiw.focus();
            }

            function openLoadContext() {
            	var fiw = null;
                if ( parent.controller.vSessionKeeper != null && parent.controller.vSessionKeeper.id == null ) {
                    /* the user has to login before loading a context from the user's folder */
                    fiw = window.open( "./missinglogin.jsp" ,"LoginInfo",
                                       "width=500,height=200,left=100,top=100,scrollbars=yes" );
                } else {
                    var sessionID = null;
                    if ( parent.controller.vSessionKeeper != null ) {
                        sessionID = parent.controller.vSessionKeeper.id;
                    }
                    var s = "control?rpc=<?xml version='1.0' encoding='UTF-8'?><methodCall>" +
                            "<methodName>mapClient:listContexts</methodName><params><param><value><struct>"+
                            "<member><name>sessionID</name><value><string>" + sessionID + "</string></value></member>" +
                            "</struct></value></param></params></methodCall>";
                    fiw = window.open( s, "load", "width=550,height=300,left=100,top=100,scrollbars=yes");
                }
                fiw.focus();
            }
            
            /* needed for wmc_testSecurity.xml */
            function openLogin() {
                if ( parent.controller.vSessionKeeper != null ) {
                    var fiw = parent.open( "login.jsp" ,"Login",
                                           "width=500,height=300,left=100,top=100,scrollbars=yes" );
                    fiw.focus();
                } else {
                    var msg = '<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_NO_LOGIN" ) %>';
                    fiw = window.open( "message.jsp?msg=" + encodeURIComponent( msg ), "Information", "width=400,height=250,left=100,top=100,scrollbars=yes");
                }
            }

            /* needed for wmc_testSecurity.xml */
            function performLogout() {
                if ( parent.controller.vSessionKeeper != null ) {
                    if ( parent.controller.vSessionKeeper.id != null ) {
                        var fiw = window.open( "logout.jsp", "logout",
                                               "width=500,height=300,left=100,top=100,scrollbars=yes" );
                        fiw.focus();
                    } else {
                        alert( '<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_MSG_NOUSER" ) %>' );
                    }
                } else {
                    var msg = '<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_NO_LOGOUT" ) %>';
                    alert(msg);
                    fiw = window.open( "message.jsp?msg=" + encodeURIComponent( msg ), "Information", "width=400,height=250,left=100,top=100,scrollbars=yes");
                }
            }

            /* needed for wmc_testCswClient.xml */
            function openMetadata() {
                if ( parent.controller.vCswModule != null ) {
                    var s = "control?rpc=<?xml version='1.0' encoding='UTF-8'?>"+
                            "<methodCall><methodName>cswClient:initClient</methodName></methodCall>";
                    fiw = window.open( s, "Search", "width=870,height=620,left=100,top=100,scrollbars=yes");
                    fiw.focus();
                } else {
                    var msg = '<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_NO_METADATA" ) %>';
                    fiw = window.open( "message.jsp?msg=" + encodeURIComponent( msg ), "Information", "width=400,height=250,left=100,top=100,scrollbars=yes");
                }
            }
        </script>
    </head>
    <body onload="register(); initMenuBar();" class="pMenubarTop">
        <table height="100%">
            <tbody>
	            <tr>
	                <td align="center"><div class="buttonIcon"><a href="javascript:openSaveContext()"><img src="./images/mt_save.gif" title='<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_TT_SAVE" ) %>' border="0" /></a></div>&nbsp;</td>
	                <td align="center"><div class="buttonIcon"><a href="javascript:openLoadContext()"><img src="./images/mt_load.gif" title='<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_TT_LOAD" ) %>' border="0" /></a></div>&nbsp;</td>
	                <td align="center"><div class="buttonIcon"><a href="javascript:openHelp()"><img src="./images/mt_help.gif" title='<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_TT_HELP" ) %>' border="0" /></a></div>&nbsp;</td>
	                <td align="center"><div class="buttonIcon"><a href="javascript:openMetadata()"><img src="./images/mt_metadata.gif" title='<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_TT_MDSEARCH" ) %>' border="0" /></a></div>&nbsp;</td>
	                <td align="center"><div class="buttonIcon"><a href="javascript:openLogin()"><img src="./images/mt_login.gif" title='<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_TT_LOGIN" ) %>' border="0" /></a></div>&nbsp;</td>
	                <td align="center"><div class="buttonIcon"><a href="javascript:performLogout()"><img src="./images/mt_logout.gif" title='<%=Messages.get( loc, "IGEO_STD_MENUBARTOP_TT_LOGOUT" ) %>' border="0" /></a></div>&nbsp;</td>
	            </tr>
            </tbody>
        </table>
    </body>
</html>
