<%@ page language="java" import=" java.util.*" errorPage="error.jsp"%>
<%!
    String userName="manager";
    String password="manager";
    String mode= "user";
%>
<html>
<head>
<title> Login on the Demo Web site of Smarthomes project </title>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<noscript> </noscript> 
<script LANGUAGE="JavaScript">
<!--
function MM_preloadimages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadimages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>
<jsp:useBean id="em" scope="session" class="EntrakMain"/>
<%
    em.urlMap = "http://localhost:8000/eeis/maps/europe/europe.html";
   	
    em.database = "smarthomes";    
    em.hostOfDBMS = "localhost";
	 
    em.configuration();
%>
<body BGCOLOR="#FFFFFF" TOPMARGIN="0" LEFTMARGIN="2" MARGINWIDTH="0" MARGINHEIGHT="0" onLoad="MM_preloadimages('images/loginpagewhite.gif','images/loginpageselected.gif','images/loginpage.gif','images/signupselected.gif','images/signup.gif','images/aboutselected.gif','images/about.gif','images/help2selected.gif','images/help2.gif','images/loginpageselected.gif','images/loginpagewhite.gif','images/signupselected.gif','images/signupwhite.gif','images/aboutselected.gif','images/aboutwhite.gif','images/help2selected.gif','images/help2white.gif')">
<br>
<br>
<table WIDTH="600" BORDER="0" CELLSPACING="0" CELLPADDING="1" HEIGHT="330">
  <tr> 
	<td VALIGN="top"> 
	  <p>&nbsp;</p>
	  <p><img SRC="images/smarthouse.gif" WIDTH="180" HEIGHT="89"></p>
	</td>
	<td WIDTH="420" VALIGN="top"> 
	  <p><font FACE="Geneva, Arial, Helvetica, san-serif" COLOR="#999999"><b>WELCOME</b></font><br>
	  </p>
	  <p><font FACE="Georgia, Times New Roman, Times, serif" SIZE="2">Welcome 
		to the Smarthomes project energy information service webpage.</font></p>
	  <p><font FACE="Georgia, Times New Roman, Times, serif" SIZE="2">The Smarthomes 
		project aims to provide householders and utilities with low-latency data 
		on energy consumption and environmental data on homes via the Internet.  
		This is a Web site for the demonstration of the Smarthomes infrastructure on which data transaction is 
		established between the e-service system, EnTrak and Web-based user interface). 
		Although the user interface was not designed for end-users (e.g. householders, energy managers etc), 
		you can see real-time data currently monitored and check the status of the e-boxes deployed over a number of countries in Europe (i.e. Czech Republic, Greece and Scotalnad  ).</p>
	  <p><font FACE="Georgia, Times New Roman, Times, serif" SIZE="2">
	  If you need more information, contact min@esru.strath.ac.uk.</p>  
	  <p>To login, just click the 'start' button below. </font></p>
	  <form METHOD="post" NAME="form1" ACTION="">
		<table WIDTH="260" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="#999999" HEIGHT="90" ALIGN="center">
		  <tr ALIGN="center"> 
			<td HEIGHT="25"><img SRC="images/userid.gif" WIDTH="65" HEIGHT="21"></td>
			<td VALIGN="middle" HEIGHT="25"> <font FACE="Arial, Helvetica, sans-serif"> 
			  <input TYPE="text" SIZE="15" NAME="userName" VALUE="manager" MAXLENGTH="15">
			  </font></td>
		  </tr>
		  <tr ALIGN="center"> 
			<td HEIGHT="25"><font COLOR="#FFFFFF" FACE="Arial, Helvetica, sans-serif" SIZE="2"><img SRC="images/password.gif" WIDTH="65" HEIGHT="21"></font></td>
			<td VALIGN="middle" HEIGHT="25"> <font FACE="Arial, Helvetica, sans-serif"> 
			  <input TYPE="password" SIZE="15" NAME="password" VALUE ="manager" MAXLENGTH="15">
			  </font></td>
		  </tr>
		  <tr ALIGN="center"> 
			<td HEIGHT="25">&nbsp;</td>
			<td HEIGHT="25"> 
			  <input TYPE="image" BORDER="0" NAME="submit" SRC="images/start.gif">
			</td>
		  </tr>
		</table>
	  </form>
	  <font FACE="Georgia, Times New Roman, Times, serif" SIZE="2"> 
<%
    if(request.getParameter("userName") != null && request.getParameter("password") != null) {
        userName = request.getParameter("userName");
        password = request.getParameter("password");
        if(userName.equals("") || password.equals("")) {
%>
	  </font> 
	  <p><font FACE="Georgia, Times New Roman, Times, serif" SIZE="2">Please fill 
		in both the fields.</font></p>
	  <p><font FACE="Georgia, Times New Roman, Times, serif" SIZE="2"> 
		<%

        } //if(userName.equals("") || password.equals(""))
        else {
            em.username = userName;
            em.password = password.toCharArray();
            if(em.connect() == true) {
%>
<script javascript>
		window.top.location.href='eeis.jsp';
</script>
		<%
            } //if(em.connect() == true)
        } //else
    } //if(request.getParameter("userName") != null && request.getParameter("password") != null)
    else { %>
		</font> 
	  <%
    } //else
%>
	</td>
  </tr>
</table>
</body>
</html>
