<%-- $HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/apps/igeoportal-standard/branches/2.5_testing/modules/gazetteer/gaz_if.jsp $
 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
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="org.deegree.model.feature.FeatureCollection" %>
<%@ page import="org.deegree.model.feature.GMLFeatureCollectionDocument" %>
<%
    String message = "\u00A0";
	FeatureCollection fc = null;
	if ( request.getAttribute( "RESULT" ) instanceof GMLFeatureCollectionDocument ) {
	    GMLFeatureCollectionDocument gmlFcDoc = 
		    (GMLFeatureCollectionDocument) request.getAttribute( "RESULT" );
        fc = gmlFcDoc.parse();
	} else if ( request.getAttribute( "RESULT" ) instanceof FeatureCollection ) {
	    fc = (FeatureCollection) request.getAttribute( "RESULT" );
	}
	
	String featureTypeName = null;
	if ( fc != null && fc.size() > 0 ) {
	    //featureTypeName = fc.getFeature( 0 ).getFeatureType().getName().getAsString(); //app:MyFeatureType
	    featureTypeName = fc.getFeature( 0 ).getFeatureType().getName().getLocalName(); //MyFeatureType
	    //featureTypeName = fc.getFeature( 0 ).getFeatureType().getName().getFormattedString(); //{http://www.deegree.org/app}:MyFeatureType
	} else if ( fc != null && fc.size() == 0 ) {
        message = "NO HITS FOUND";
        //System.out.println( message );
    }
	//System.out.println("\n **gaz_if.jsp** featureTypeName = " + featureTypeName );
%>
<html>
    <head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="author" content="Judit Mays, lat/lon GmbH">
        <meta name="KeyWords" content="deegree iGeoPortal lat/lon" />
        <title>WFS Gazetteer</title>
        <link href="../../css/deegree.css" rel="stylesheet" type="text/css" />
        <script language="JavaScript1.2">
        <!--
            function performOnLoad() {
                parent.ifdocument = document;
                buildList();
            }
            
            function close() {
                parent.window.close();
            }
            
            function buildList() {
				<%
				if ( featureTypeName == null ){
				%>
				    parent.setMessage( '<%= message %>' );
				<%	   
				} else if ( "Counties".equals( featureTypeName ) ) {
				%>
					<jsp:include page="gaz_a_county.jsp" flush="true" />
				<%	   
				} else if ( "Municipalities".equals( featureTypeName ) ) {
				%> 
					<jsp:include page="gaz_a_municipality.jsp" flush="true" />
					
					
                // TODO: add the following block ("BEGIN" till "END") for each additional FeatureType
                //BEGIN	
				<%
                // TODO: "Municipalities_edited" has to be adapted to the name of the desired FeatureType
                } else if ( "Municipalities_edited".equals( featureTypeName ) ) {
                %>
                    // TODO: gaz_freeSearchResult.jsp needs to be adjusted as required
                    <jsp:include page="gaz_freeSearchResult.jsp" flush="true" />
                //END

                
                //TODO: add additional FeatureTypes HERE


                <%
                } else if ( "ZipCodes".equals( featureTypeName ) ) {
                %>
                    // TODO: gaz_freeSearchResult.jsp needs to be adjusted as required
                    <jsp:include page="gaz_d_zipcodes.jsp" flush="true" />    
				<%	   
				}
				%>
			}
        //-->
        </script>
    </head>
    <body onload="performOnLoad();">
        <form action="" id="form" method="post"></form>
   </body>
</html>
