

<%@ page language="java" import="iDSS.*,iDSS.utils.*,iDSS.webBeans.*,iDSS.beans.*" errorPage="error/error.jsp"%>


<%!
    String emailValue;
    boolean success = false;
    UserJBean user;
%>


<html>
<head>
<title><%=IDSSAppConstants.programTitle%></title>
</head>




<jsp:useBean id="logOnBean" scope="session" class="iDSS.webBeans.LogJBean"/>
<jsp:useBean id="monitor" scope="application" class="java.util.Hashtable"/>






       <SCRIPT LANGUAGE="Javascript"> 
          var javawsInstalled = 0; 
          isIE = "false"; 

          if (navigator.mimeTypes && navigator.mimeTypes.length) { 
             x = navigator.mimeTypes['application/x-java-jnlp-file']; 
             if (x) javawsInstalled = 1; 
          } else { 
             isIE = "true"; 
          } 

          function insertLink(url, name) { 
           if (javawsInstalled) { 
                document.write("<a href=" + url + ">"  + name + "</a>"); 
             } else { 
                document.write("Need to install Java Web Start"); 
             } 
          } 
      </SCRIPT> 

      <SCRIPT LANGUAGE="VBScript"> 
          on error resume next 
          If isIE = "true" Then 
            If Not(IsObject(CreateObject("JavaWebStart.IsInstalled"))) Then 
                  javawsInstalled = 0 
            Else 
                  javawsInstalled = 1 
            End If 
          End If 
      </SCRIPT>












<body>

<jsp:include page="templates/header.jsp" flush="true"/>


<p>Welcome to Internet-based Decision Support System (iDSS) for Coastal Management. This is a J2EE-based open system
designed to take expert input from distributed locations.
</p>

<p>
This system is
developed as a part of the doctoral research conducted at the Department of Geography, 
University of Strathclyde, Scotland, UK</p>

<p>
Please login to run the system.
</P>




<hr>
<form method="post">

    <table border="0">


        <tr>
            <td>Email:</td>
            <td><input type="text" size="20" name="email"></td>
        </tr>


        <tr>
            <td><input type="submit" value="Login"></td>
        <tr>

    </table>

</form>

<%

    if(request.getParameter("email") != null) {

        emailValue = request.getParameter("email");

        if(emailValue.equals("") || emailValue.indexOf('@') == -1) {

%>
            <p>Plese enter a valid email address. If you are a new user, please register.</p>
<%

        } //if(request.getParameter("email").equals(""))

        else {

%>
            <p>Your email address is <%=emailValue%>.</p>
            <p>Being forwarded to login process...</p>

            
<%
            success = logOnBean.logOn(emailValue);


            if(success) {


                user = logOnBean.getUser();

                if(monitor.containsKey(user)) {

                    HttpSession oldSession = (HttpSession)monitor.get(user);
                    oldSession.invalidate();

                } //if(monitor.containsKey(user))

                session.setAttribute(IDSSAppConstants.user,user);
                monitor.put(user,session);

%>


                <P>
                    <%=user.getName()%><BR>
                    <%=user.getEmail()%><BR>
                    <%=user.getLastVisited().toString()%><BR>
                    <%=user.getTotalTimeSpent()%><BR>
                </P>



<%

            } //if(success)

            else {
%>

                <P>
                    There is no registered user for <%=emailValue%>.
                </P>

<%
            } //else


        } //else


    } //if(request.getParameter("email") != null .....)

    else {

%>
            <p>Plese fill in all the fields or register if you don't already have an accound.</p>
<%


    } //else


%>






<hr>

<form method="post" action="register.jsp">
    <table border="0">
        <tr>
            <td>First visit?</td>
            <td><input type="submit" value="Register"></td>
        </tr>
    <table>
</form>

<hr>




    <SCRIPT LANGUAGE="Javascript"> 
        <!-- 
        insertLink("http://130.159.78.177:8000/idss/webstart/idssWebStart.jnlp", 
                   "iDSS Java Webstart Version");
        // --> 
    </SCRIPT> 





<hr>

<jsp:include page="templates/footer.jsp" flush="true"/>

</body>

</html>

