<%@ page language="java" import=" java.util.*" errorPage="error.jsp"%>

<%!

    String userName;
    String password;
    String mode= "user";

%>


<html>
<head>
<title>Energy Environment Information System</title>


<script language="JavaScript">
    function underConstruction() {
        window.alert("This option is now under construction");
    } //function underConstruction()
</script>
<script language="JavaScript">
    function popupMessage( message ) {
        window.alert( message);
    } //function underConstruction()
</script>
<script language="JavaScript">

    function runApp(url) {

        var newWin = window.open(url,"any");
        newWin.focus();

    } //function runApp(url)

</script>



</head>


    <jsp:useBean id="em" scope="session" class="EntrakMain"/>

<%

   
    em.urlMap = "http://peta-esru.mecheng.strath.ac.uk:8000/smarthome/maps/europe/europe.html";
   	
    em.database = "highland";    
    em.hostOfDBMS = "130.159.102.16";
    em.configuration();
%>


<body>


<h2>Energy Environment Information System
</h2>
<h3>Demo Web Interface for Energy Managers </h3>

<p>
    <A HREF="#" TARGET="" onClick="underConstruction();">
        About EEIS
    </A>
    |
    <A HREF="#" TARGET="" onClick="runApp('http://www.esru.strath.ac.uk/');">
        ESRU
    </A>
    |
    <A HREF="#" TARGET="" onClick="underConstruction();">
        Energy Links
    </A>
    |
    <A HREF="#" TARGET="" onClick="underConstruction();">
        Contact
    </A>
</p>




<hr>
<form method="post">

    <table border="0">


        <tr>
            <td>User Name:</td>
            <td><input type="text" size="20" name="userName" value ="manager"></td>
        </tr>

        <tr>
            <td>Password:</td>
            <td><input type="password" size="20" name="password" value = "manager"></td>
        </tr>


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

    </table>

</form>

<p> To login, just click 'Start' button.</p>
<%

    if(request.getParameter("userName") != null && request.getParameter("password") != null) {

        userName = request.getParameter("userName");
        password = request.getParameter("password");
        if(userName.equals("") || password.equals("")) {
%>
            <p>Please enter a user name.</p>
<%
        } //if(userName.equals("") || password.equals(""))
        else {
%>
            <p>userName : <%=userName%></p>
            <p>password : <%=password%></p>
<%
            em.username = userName;
            em.password = password.toCharArray();
            //System.out.println( "username   " + userName);
            if(em.connect() == true) {
%>
                <p>em.username : <%=em.username%></p>
                <p>em.password : <%=em.password%></p>
                <p>Database connection established!</p>
                <jsp:forward page="JSPMCPM.jsp" />
<%

            } //if(em.connect() == true)

        } //else


    } //if(request.getParameter("userName") != null && request.getParameter("password") != null)

    else { %>
	          
<%

    } //else


%>







<hr>


</body>

</html>





