<%@ page language="java" import="java.util.*" errorPage="error.jsp"%>
<%!
    String userName;
    String password;
    String mode= "user";
%>

<html>
<head>
<title>Energy Environment Information System for end customers</title>
<script language="JavaScript">
    function popupMessage( message ) {
        window.alert( message);
    } //function underConstruction()
</script>

<script language="JavaScript">
    var winNum = 0;
    function runApp(url) {
        var newWin = window.open(url,"any");
        newWin.focus();
    }
</script>

</head>
<jsp:useBean id="em" scope="session" class="EntrakMain"/>
<%
   // em.urlMap = "http://localhost:8000/maps/europe/uk/glasgow/index.html";
    // em.setup();   
    em.database = "smarthomes";
    em.hostOfDBMS = "peta-esru.mecheng.strath.ac.uk";
	em.configuration();
%>
<body>
<font face="book antiqua">
<h3 ALIGN="center" > WELCOME TO A "HOME ENERGY and HEALTH CARE SERVICE </h2>
<h4 ALIGN="center"> FIND OUT WAYS THAT YOU CAN SAVE <font color="#3300ff">MONEY </font>
<font color="#ff0000">-ENERGY-</font><font color="#009966">ENVIRONMENT-
</font> and PROTECT <font color="#00ff00"> YOUR HEALTH !</font></h3>
</font>
<font size="2" color="black">

<p> Save money from your electricity abd gas bill by using an effective management of
 your energy con consumption. The new energy service provides an effective, secure and
 reliable way to control and /or monitoring your home appliances that in most times
 consume more energy than necessary.
</p>

<p> Now you can monitor how much energy your major appliances consume in real time and you
can also control these very easily through your personal web site.  You can be aware of
 the status of the indoor environment all the time. You can be even warned before a hazardous situation actually happens (e.g.<font color="red"> Cold alarm, Mould detection </font>). 

</P>

<p> We don't only have financial benefits from the implementation of this service but we
also help to save our environment.
</p>

</font>

<img src="images/energy_homeowner.gif" width="150" height="150" border="0" 
alt="energy information service for homeowner" align="right">

<font size="2" color="lighblue">
<p> For more information about the electricity savings Click
<A HREF="#" TARGET="" onClick="popupMessage( 'under Construction');"> here.
</A>

</p>

<p> For a demonstration of the system Click
<A HREF="#" TARGET="" onClick="popupMessage( 'under Construction');"> here.
</A>
</p>

</font>
<hr>
<font color="red"> <h3> MEMBER LOGIN </h3></font>
<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> New members: Sign Up
<A HREF="#" TARGET="" onClick= "popupMessage( 'under Construction');"> here.
</A>

<%
    
    if(request.getParameter("userName") != null && request.getParameter("password") != null) { //#3
         
		//ebox_id =  request.getParameter("password");   
	    userName = request.getParameter("userName");
        password = request.getParameter("password");
	
		//userName ="scot";
		//password ="scot";
        if(userName.equals("") || password.equals("")) { 
%>
         
			 <script language="JavaScript">
				<!--
                    popupMessage(' Plese enter both user name and password.')
				// -->	
	     </script> 
<%
        } 
        else { //#2
%>
          <%--  <p>userName : <%=userName%></p> 
            <p>password : <%=password%></p>
			--%>
<%
            em.username = userName;
            em.password = password.toCharArray();
            if(em.connect() == true) {
%>
                <p>em.username : <%=em.username%></p>
                <p>em.password : <%=em.password%></p>
                <p>Database connection established!</p>

               <jsp:forward page="hw_main.jsp" /> 

<%
            }
		    else{//#1  %>	
			    <script language="JavaScript">
				<!--
                    popupMessage(' Authentication Failed! ')
				// -->	
			    </script>
<%			}// #1	 
       } // #2
    } //#3
    else {

%>
        <%--
          <script language="JavaScript">
				<!--
                    popupMessage(' Plese enter user name and password.')
				// -->	
	     </script>
         --%> 
<%
    } 
%>


<hr>


</body>

</html>





