
<%@ page language="java" import="java.util.*,java.sql.*,java.sql.Date,java.sql.Time,java.net.*,java.io.*"%>
<%!
    String environmentParameter="ALL";
    String resolution="6";
    String ic_item;
    String eboxId = "A062166112";	
    String entity = "JWM313";
    String periods[] ={"1","6","12","24"};
%>
<script LANGUAGE="JavaScript">

   //create a global variable so the window object can be accessed elsewhere
   function createWindow(url) {

        var winNum = self.opener.winNum;
        var imgWin = self.opener.imgWin[winNum];

        //if the window.name isn't set, create the window
        if(imgWin == null) {
            var targetWin = "ImageWindow_"+winNum.toString();
            imgWin = window.open(url,targetWin,'status=yes,top=20,left=20,dependent=yes,scrollbars=yes,resizable=no,width=400,height=400,menubar=no');
            //imgWin.location.replace(url);
            imgWin.location.reload();

            self.opener.imgWin[winNum] = imgWin;
            winNum++;
            self.opener.winNum = winNum;
        }//
        else {
            if(imgWin.name != null) {
                imgWin.focus();
            }
        }//else

    }//function createWindow(url)

   function loadFrame(url,target) {
       var newWin=window.open(url,target, 'status=yes,top=20,left=20,dependent=yes,scrollbars=yes,resizable=yes,width=400,height=400,menubar=no');		
        newWin.location.replace(url);
     	//updated from newWin.location.reload();
    } //function loadFrame(url,target)
</script>
<html>
<head>
<title> Current Status of e-boxes and sensors </title>
</head>

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

<body BGCOLOR="#FFFFFF" TEXT="#CCCCCC" LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
 <font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="blue">
 <p> To view the list of the e-boxes, press 'Show the e-boxes currently connected' Button after selecting country.
 Querying process may take several seconds.
 </p> 
 </font> 
<%
    sql = new SQLStatement(em.con);
	
	String clName = ClassLoaderName.getName(getClassLoader().toString());
   
    String country ="%";
 
    String actionButtonName = request.getParameter("action");

    if(actionButtonName != null) {
        if (actionButtonName.equals("Show sensors")) {
			environmentParameter="ALL"; 
			resolution="1";
			eboxId=request.getParameter("eboxId");			
			ic_item=environmentParameter;								
  		  %>
		  
          <script>
             loadFrame("DrawTable.jsp?environmentParameter=<%=environmentParameter%>&resolution=<%=resolution%>&ic_item=<%=ic_item%>&eboxId=<%=eboxId%>","imgFrame_c");
             </script>                            
          <% 
        } //if ("Show e-boxes)
		else if (actionButtonName.equals("Show e-boxes registered")){
		  country =request.getParameter("country");	
        %>
		 
         <script>	 
              loadFrame("DrawTable_ebox_list.jsp?country=<%=country%>","imgFrame_c");
         </script>
   <%
        }
		else { //show the e-boxes currently connected
		  country =request.getParameter("country");	
		%>
		  <script>
 	     loadFrame("DrawTable_working_ebox_list.jsp?country=<%=country%>","imgFrame_c");
          </script>
	<%    }
	   
    }
%>
<form METHOD="post">
  <table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="100%">
	<!--tr >
	  <td VALIGN="MIDDLE" ALIGN="CENTER" --> 
		<table WIDTH="80%" BORDER="0" CELLPADDING="2" BGCOLOR="#000000" ALIGN="CENTER">
		  <tr VALIGN="MIDDLE" BGCOLOR="#999999" BORDERCOLOR="#000000" ALIGN="CENTER"> 
		 	<td><font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FFFFFF"> Country :</font> </td>
			<td> 
			  <center>
				<font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FFFFFF"> 
				<select NAME= "country" >
				     <option VALUE="CZ" >Czech Republic</option>        		           		 
        			 <option VALUE="GRE">Greece</option>	 
					 <option VALUE="SWE">Sweden</option>
					 <option VALUE="UK">UK</option>
            	  	 <option VALUE="%" selected >ALL</option>
				</select>
				</font> 
			  </center >
			</td> 
			<!--td>
			  <center>
				<font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FFFFFF"> 
				 <input TYPE="submit" VALUE="Show e-boxes registered" NAME="action">			 
				</font> 			
		      </center>
			</td-->
			  <td > <center ><font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FFFFFF"> 
             <input TYPE="submit" VALUE="Show the e-boxes currently connected" NAME="action">
	         </font> </center>
		    </td> 
		  </tr>
		</table >
		<!--tr>
	  <td VALIGN="MIDDLE" ALIGN="CENTER"--> 		  
	   <font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="blue">
	   <br>To view the list of the sensors connected to an e-box, 
	   press 'Show sensors' Button after typing the e-box ID obtained from the list. 
		</font>
		<table WIDTH="80%" BORDER="0" CELLPADDING="2" BGCOLOR="#000000" ALIGN="CENTER">
		  <tr VALIGN="MIDDLE" BGCOLOR="#999999" BORDERCOLOR="#000000" ALIGN="CENTER"> 
		  <td><font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FFFFFF"> e-box ID :</font>	
		  </td>
		  <td>   
			<center>
			<font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FFFFFF"> 
			 <input TYPE="text" NAME="eboxId" VALUE=<%=eboxId%> >
		 	 </center>			  			  			  
		  </td>
	     <td > <center ><font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FFFFFF"> 
         <input TYPE="submit" VALUE="Show sensors" NAME="action">
	     </font> </center>
		 </td> 
		 
		 
	   </tr>
	   </table>
  </table>
  </form>
   <font FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="Red">
   NOTE: Querying data may take a few minutes.<br>
   Codes of sensors: occ*=Occupancy, tmp*=temperature, hmd*=relative humidity, cnt*= counter, 
     anlg*= analog, mem= ebox memory, co*= CO, co2*=CO2,rly*= relay switch.      
</body>
</html>





