<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-nested" prefix="nested" %>
<%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="dwr/interface/serverElectricPower.js"></script>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/util.js"></script>

<div>
 <logic:notEqual name="SupportElectricPowerForm" property="groupID" value="-1">
  <html:link forward="getElectricPower" paramId="groupID" paramName="SupportElectricPowerForm" paramProperty="groupID">
    <bean:message key="link.groupPower"/>
  </html:link>
 </logic:notEqual>
</div>

<div id="downloadLink">
 <a href="javascript:download()">
   <bean:message key="link.downloadData"/>
 </a>
 <iframe type="hidden" class="dummyframe" src="" name="dummyframe" ></iframe>
 <%-- <iframe type="hidden" src="" style="display: none" name="dummyframe"></iframe> --%>
</div>

<html:form action="measurementElectricPower" target="info">
<table class="data">
 <thead>
  <tr class="thead">
   <td id="itemName"><bean:message key="text.itemName"/></td>
   <td id="measurementValue"><bean:message key="text.measurementValue"/></td>
  </tr>
 </thead>
 <tbody>
  <tr class="row1">
   <td nowrap><bean:message key="text.status"/></td>
   <td id="status" nowrap>
     <logic:equal name="SupportElectricPowerForm" property="status" value="0">
      <bean:message key="text.unmeasurement"/>
     </logic:equal>
     <logic:equal name="SupportElectricPowerForm" property="status" value="1">
      <bean:message key="text.measuring"/>
       <logic:equal name="SupportElectricPowerForm" property="executeRemoteBatch" value="true">
         <bean:message key="text.batch"/>
       </logic:equal>
     </logic:equal>
     <logic:equal name="SupportElectricPowerForm" property="status" value="2">
      <bean:message key="text.measured"/>
     </logic:equal>
     <logic:equal name="SupportElectricPowerForm" property="status" value="3">
      <bean:message key="text.unknown"/>
     </logic:equal>
     <logic:equal name="SupportElectricPowerForm" property="status" value="4">
      <bean:message key="text.unsetting"/>
     </logic:equal>
     <logic:equal name="SupportElectricPowerForm" property="status" value="5">
      <bean:message key="text.fixed"/>
     </logic:equal>
     <logic:equal name="SupportElectricPowerForm" property="status" value="6">
      <bean:message key="text.measurementFailured"/>
     </logic:equal>
     <logic:equal name="SupportElectricPowerForm" property="status" value="7">
      <bean:message key="text.measuring"/>
       <logic:equal name="SupportElectricPowerForm" property="executeRemoteBatch" value="true">
         <bean:message key="text.batch"/>
       </logic:equal>
      <bean:message key="text.error.dcoffStatus"/>
     </logic:equal>
     <logic:equal name="SupportElectricPowerForm" property="status" value="8">
      <bean:message key="text.measuring"/>
       <logic:equal name="SupportElectricPowerForm" property="executeRemoteBatch" value="true">
         <bean:message key="text.batch"/>
       </logic:equal>
      <bean:message key="text.error.communication"/>
     </logic:equal>
    </td>
  </tr>
  <tr class="row2">
   <td nowrap><bean:message key="text.period"/></td>
   <td id="period" nowrap>
    <logic:equal name="SupportElectricPowerForm" property="statusData" value="1">
     <bean:write name="SupportElectricPowerForm" property="startTime"/>
    </logic:equal>
    &nbsp;-&nbsp;
    <logic:equal name="SupportElectricPowerForm" property="statusData" value="1">
     <bean:write name="SupportElectricPowerForm" property="endTime"/>
    </logic:equal>
   </td>
  </tr>
  <tr class="row1">
   <td nowrap>
    <bean:message key="text.maxElectricPower"/>
    <bean:message key="text.unitWat"/>
   </td>
   <td id="maxElectricPower" nowrap>
    <logic:notEqual name="SupportElectricPowerForm" property="status" value="0">
     <bean:write name="SupportElectricPowerForm" property="maxElectricPower"/>
    </logic:notEqual>
    <logic:equal name="SupportElectricPowerForm" property="status" value="0">-</logic:equal>
   </td>
  </tr>
  <tr class="row2">
   <td nowrap>
    <bean:message key="text.minElectricPower"/>
    <bean:message key="text.unitWat"/>
   </td>
   <td id="minElectricPower" nowrap>
    <logic:notEqual name="SupportElectricPowerForm" property="status" value="0">
     <bean:write name="SupportElectricPowerForm" property="minElectricPower"/>
    </logic:notEqual>
    <logic:equal name="SupportElectricPowerForm" property="status" value="0">-</logic:equal>
   </td>
  </tr>
  <tr class="row1">
   <td nowrap>
    <bean:message key="text.aveElectricPower"/>
    <bean:message key="text.unitWat"/>
   </td>
   <td id="aveElectricPower" nowrap>
    <logic:notEqual name="SupportElectricPowerForm" property="status" value="0">
     <bean:write name="SupportElectricPowerForm" property="aveElectricPower"/>
    </logic:notEqual>
    <logic:equal name="SupportElectricPowerForm" property="status" value="0">-</logic:equal>
   </td>
   <tr class="row2">
   <td nowrap>
    <bean:message key="text.currentPower"/>
    <bean:message key="text.unitWat"/>
   </td>
   <td id="currentPower" nowrap>
    <logic:notEqual name="SupportElectricPowerForm" property="status" value="1">-</logic:notEqual>
    <logic:equal name="SupportElectricPowerForm" property="status" value="1">
     <bean:write name="SupportElectricPowerForm" property="curElectricPower"/>
    </logic:equal>
   </td>
  </tr>
  <tr class="row1">
   <td nowrap><bean:message key="text.measurementFrequency"/></td>
   <td id="measurementFrequency" nowrap>
    <bean:write name="SupportElectricPowerForm" property="num"/>
    <bean:message key="text.timesCount" />
   </td>
  </tr>
  <tr class="row2">
   <td nowrap><bean:message key="text.totalTime"/></td>
   <td id="totalTime" nowrap>
    <bean:write name="SupportElectricPowerForm" property="totalHour" />
    <bean:message key="text.hour" />
    <bean:write name="SupportElectricPowerForm" property="totalMinute" />
    <bean:message key="text.minute" />
   </td>
  </tr>
  <logic:equal name="SupportElectricPowerForm" property="validPowerControl" value="1">
   <tr class="row1">
    <td nowrap><bean:message key="text.maxPowerConsumptionControlLevel"/></td>
    <td id="ctrlLevel" nowrap>
     <logic:notEqual name="SupportElectricPowerForm" property="controlLevel" value="-1">
      <bean:message key="text.level" />
      <bean:write name="SupportElectricPowerForm" property="controlLevel" />
     </logic:notEqual>
    </td>
   </tr>
  </logic:equal>
 </tbody>
</table>

<table class="data">
 <thead>
  <tr class="thead">
   <td id="itemName"><bean:message key="text.itemName"/></td>
   <td id="setupValue"><bean:message key="text.setupValue"/></td>
  </tr>
 </thead>
 <tbody>
  <tr class="row1">
   <td nowrap>
     <bean:message key="text.period"/>
     <bean:message key="text.scope.range" arg0="5" arg1="24" />
   </td>
   <td nowrap>
    <span id="periodHour_input">
     <html:select name="SupportElectricPowerForm" property="periodHour" onchange="changeTest(this)">
      <html:option value="00">00</html:option>
      <html:option value="01">01</html:option>
      <html:option value="02">02</html:option>
      <html:option value="03">03</html:option>
      <html:option value="04">04</html:option>
      <html:option value="05">05</html:option>
      <html:option value="06">06</html:option>
      <html:option value="07">07</html:option>
      <html:option value="08">08</html:option>
      <html:option value="09">09</html:option>
      <html:option value="10">10</html:option>
      <html:option value="11">11</html:option>
      <html:option value="12">12</html:option>
      <html:option value="13">13</html:option>
      <html:option value="14">14</html:option>
      <html:option value="15">15</html:option>
      <html:option value="16">16</html:option>
      <html:option value="17">17</html:option>
      <html:option value="18">18</html:option>
      <html:option value="19">19</html:option>
      <html:option value="20">20</html:option>
      <html:option value="21">21</html:option>
      <html:option value="22">22</html:option>
      <html:option value="23">23</html:option>
      <html:option value="24">24</html:option>
     </html:select>
     <bean:message key="text.hour"/>
    </span>
    <span id="periodHour_text">
     <logic:notEqual name="SupportElectricPowerForm" property="periodHour" value="00">
      <bean:write name="SupportElectricPowerForm" property="periodHour"/>
      <bean:message key="text.hour"/>
     </logic:notEqual>
    </span>
     
    <span id="periodMinute_input">
     <html:select name="SupportElectricPowerForm" property="periodMinute">
      <html:option value="00">00</html:option>
      <html:option value="01">01</html:option>
      <html:option value="02">02</html:option>
      <html:option value="03">03</html:option>
      <html:option value="04">04</html:option>
      <html:option value="05">05</html:option>
      <html:option value="06">06</html:option>
      <html:option value="07">07</html:option>
      <html:option value="08">08</html:option>
      <html:option value="09">09</html:option>
      <html:option value="10">10</html:option>
      <html:option value="11">11</html:option>
      <html:option value="12">12</html:option>
      <html:option value="13">13</html:option>
      <html:option value="14">14</html:option>
      <html:option value="15">15</html:option>
      <html:option value="16">16</html:option>
      <html:option value="17">17</html:option>
      <html:option value="18">18</html:option>
      <html:option value="19">19</html:option>
      <html:option value="20">20</html:option>
      <html:option value="21">21</html:option>
      <html:option value="22">22</html:option>
      <html:option value="23">23</html:option>
      <html:option value="24">24</html:option>
      <html:option value="25">25</html:option>
      <html:option value="26">26</html:option>
      <html:option value="27">27</html:option>
      <html:option value="28">28</html:option>
      <html:option value="29">29</html:option>
      <html:option value="30">30</html:option>
      <html:option value="31">31</html:option>
      <html:option value="32">32</html:option>
      <html:option value="33">33</html:option>
      <html:option value="34">34</html:option>
      <html:option value="35">35</html:option>
      <html:option value="36">36</html:option>
      <html:option value="37">37</html:option>
      <html:option value="38">38</html:option>
      <html:option value="39">39</html:option>
      <html:option value="40">40</html:option>
      <html:option value="41">41</html:option>
      <html:option value="42">42</html:option>
      <html:option value="43">43</html:option>
      <html:option value="44">44</html:option>
      <html:option value="45">45</html:option>
      <html:option value="46">46</html:option>
      <html:option value="47">47</html:option>
      <html:option value="48">48</html:option>
      <html:option value="49">49</html:option>
      <html:option value="50">50</html:option>
      <html:option value="51">51</html:option>
      <html:option value="52">52</html:option>
      <html:option value="53">53</html:option>
      <html:option value="54">54</html:option>
      <html:option value="55">55</html:option>
      <html:option value="56">56</html:option>
      <html:option value="57">57</html:option>
      <html:option value="58">58</html:option>
      <html:option value="59">59</html:option>
     </html:select>
    </span>
    <span id="periodMinute_text">
     <bean:write name="SupportElectricPowerForm" property="periodMinute"/>
    </span>
    <bean:message key="text.minute"/>
   </td>
  </tr>
  <tr class="row2">
   <td nowrap>
     <bean:message key="text.measurementInterval"/>
     <bean:message key="text.seconds.range" arg0="5" arg1="60" />
   </td>
   <td nowrap>
    <span id="interval_input">
     <html:select name="SupportElectricPowerForm" property="interval">
      <html:option value="05">05</html:option>
      <html:option value="06">06</html:option>
      <html:option value="07">07</html:option>
      <html:option value="08">08</html:option>
      <html:option value="09">09</html:option>
      <html:option value="10">10</html:option>
      <html:option value="11">11</html:option>
      <html:option value="12">12</html:option>
      <html:option value="13">13</html:option>
      <html:option value="14">14</html:option>
      <html:option value="15">15</html:option>
      <html:option value="16">16</html:option>
      <html:option value="17">17</html:option>
      <html:option value="18">18</html:option>
      <html:option value="19">19</html:option>
      <html:option value="20">20</html:option>
      <html:option value="21">21</html:option>
      <html:option value="22">22</html:option>
      <html:option value="23">23</html:option>
      <html:option value="24">24</html:option>
      <html:option value="25">25</html:option>
      <html:option value="26">26</html:option>
      <html:option value="27">27</html:option>
      <html:option value="28">28</html:option>
      <html:option value="29">29</html:option>
      <html:option value="30">30</html:option>
      <html:option value="31">31</html:option>
      <html:option value="32">32</html:option>
      <html:option value="33">33</html:option>
      <html:option value="34">34</html:option>
      <html:option value="35">35</html:option>
      <html:option value="36">36</html:option>
      <html:option value="37">37</html:option>
      <html:option value="38">38</html:option>
      <html:option value="39">39</html:option>
      <html:option value="40">40</html:option>
      <html:option value="41">41</html:option>
      <html:option value="42">42</html:option>
      <html:option value="43">43</html:option>
      <html:option value="44">44</html:option>
      <html:option value="45">45</html:option>
      <html:option value="46">46</html:option>
      <html:option value="47">47</html:option>
      <html:option value="48">48</html:option>
      <html:option value="49">49</html:option>
      <html:option value="50">50</html:option>
      <html:option value="51">51</html:option>
      <html:option value="52">52</html:option>
      <html:option value="53">53</html:option>
      <html:option value="54">54</html:option>
      <html:option value="55">55</html:option>
      <html:option value="56">56</html:option>
      <html:option value="57">57</html:option>
      <html:option value="58">58</html:option>
      <html:option value="59">59</html:option>
      <html:option value="60">60</html:option>
     </html:select>
    </span>
    <span id="interval_text">
     <bean:write name="SupportElectricPowerForm" property="interval"/>
    </span>
    <bean:message key="text.second"/>
   </td>
  </tr>
  <tr class="row1">
   <td nowrap><bean:message key="text.resultCheck"/></td>
   <td nowrap>
    <span id="check_input">
     <html:radio name="SupportElectricPowerForm" property="check" value="false" styleId="check_false"/>
      <label for="check_false">
       <bean:message key="text.new"/>
      </label>
     <html:radio name="SupportElectricPowerForm" property="check" value="true" styleId="check_true"/>
      <label for="check_true">
       <bean:message key="text.succeed"/>
      </label>
    </span>
    <span id="check_text">
     <logic:equal name="SupportElectricPowerForm" property="check" value="false">
      <bean:message key="text.new"/>
     </logic:equal>
     <logic:equal name="SupportElectricPowerForm" property="check" value="true">
      <bean:message key="text.succeed"/>
     </logic:equal>
    </span>
   </td>
  </tr>
 </tbody>
</table>
 <logic:equal name="CurrentUserInfo" property="electricPowerMonitoring" value="1">
  <table width="0" border="0" align="center">
   <tr>
    <td colspan="2" id="center" nowrap>
      <html:submit property="action.run">
       <bean:message key="button.startMeasurement"/>
      </html:submit>
      <html:submit property="action.stop">
       <bean:message key="button.stopMeasurement"/>
      </html:submit>
      <html:submit property="action.graph" onclick="return openReadingGraph(this.form);">
       <bean:message key="button.graphMeasurement"/>
      </html:submit>
    </td>
   </tr>
  </table>
  <html:hidden name="SupportElectricPowerForm" property="serverID"/>
  <html:hidden name="SupportElectricPowerForm" property="groupID"/>
 </logic:equal>
</html:form>

<script language="JavaScript" type="text/javascript">
<!--
   var readingWindow = null;
   function changeTest(choose) {
     var selectedHour = choose.options[choose.selectedIndex].value;
     var minute = choose.form.elements["periodMinute"];
     var time = minute.value;
     var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : null;
     
     // 分の要素を一旦、全て削除する
     while(minute.options.length) {
       minute.remove(0);
     }

     if(selectedHour == 24) {
       // 24時間が選択された場合、分を00のみに設定する
       opt =  document.createElement("option");
       opt.text = "00";
       opt.value = "00";
       minute.add(opt, where);

     } else if(selectedHour == 00) {
       // 00時間が選択された場合、分を05から59の範囲に設定する
       for(i = 5; i <= 59; i++) {
         opt =  document.createElement("option");
         if(i < 10) {
           opt.text = "0" + i;
           opt.value = "0" + i;
         } else {
           opt.text = i;
           opt.value = i;
         }
         minute.add(opt, where);
       }
       if (Number(time) > 4) {
         minute.value = time;
       }

     } else {
       // 01から23時間が選択された場合、分を00から59の範囲に設定する
       for(i = 0; i <= 59; i++) {
         opt =  document.createElement("option");
         if(i < 10) {
           opt.text = "0" + i;
           opt.value = "0" + i;
         } else {
           opt.text = i;
           opt.value = i;
         }
         minute.add(opt, where);
       }
       minute.value = time;
     }
   }
   
   <bean:define id="msgUnmeasurement">
    <bean:message key="text.unmeasurement"/>
   </bean:define>

   <bean:define id="msgMeasuring">
    <bean:message key="text.measuring"/>
   </bean:define>

   <bean:define id="msgMeasured">
    <bean:message key="text.measured"/>
   </bean:define>

   <bean:define id="msgUnknown">
    <bean:message key="text.unknown"/>
   </bean:define>

   <bean:define id="msgUnsetting">
    <bean:message key="text.unsetting"/>
   </bean:define>

   <bean:define id="msgFixed">
    <bean:message key="text.fixed"/>
   </bean:define>

   <bean:define id="msgMeasurementFailured">
    <bean:message key="text.measurementFailured"/>
   </bean:define>

   <bean:define id="msgErrorDcOffStatus">
    <bean:message key="text.error.dcoffStatus"/>
   </bean:define>

   <bean:define id="msgErrorCommunication">
    <bean:message key="text.error.communication"/>
   </bean:define>

   <bean:define id="msgRemoteBatch">
    <bean:message key="text.batch"/>
   </bean:define>
   
   <bean:define id="hour">
    <bean:message key="text.hour"/>
   </bean:define>

   <bean:define id="minute">
    <bean:message key="text.minute"/>
   </bean:define>

   <bean:define id="times">
    <bean:message key="text.timesCount"/>
   </bean:define>

   <bean:define id="level">
    <bean:message key="text.level"/>
   </bean:define>

   <bean:define id="sid" name="SelectedServer" property="serverID"/>
   var serverId = <%= sid.toString() %>;
   var executer = null;
   var measuringCnt = 0;
   var totalHour = 0;
   var totalMinute = 0;
   <bean:define id="exeBatch"name="SupportElectricPowerForm" property="executeRemoteBatch"/>
   var executeRemoteBatch = <%= exeBatch.toString() %>;
   
   function checkMeasureStatus() {
     serverElectricPower.getElectricPowerData(serverId, callbackCheckMeasureStatus);
   }
   
   function callbackCheckMeasureStatus(result) {
     renewalMeasureData();
     if((result.status == 1) || (result.status == 7) || (result.status == 8)) {
       startMeasurement();
     }

     //グラフボタンの表示／非表示
     displayGraph(result);

     /* オブジェクト削除(メモリを明示的に解放) */
     delete result;
   }

   function renewalMeasureData() {
     dwr.engine.setErrorHandler(function(){
       executer.stop();
     });
     dwr.engine.beginBatch();
     serverElectricPower.getElectricPowerData(serverId, callbackRenewalMeasureData);
     serverElectricPower.getMeasuredPeriod(serverId, callbackRenewalMeasuredPeriod);
     dwr.engine.endBatch();
   }
   
   function callbackRenewalMeasureData(result) {
     measuringCnt = 0;
     executeRemoteBatch = result.executeRemoteBatch;
     switch(result.status) {
       case 0:
         Element.update('status', '<%= msgUnmeasurement.toString() %>');
         break;
       case 1:
           //リモートバッチフラグがtrueの場合、リモートバッチを表示
         if(executeRemoteBatch) {
           Element.update('status', '<%= msgMeasuring.toString() %><%= msgRemoteBatch.toString()%>');
         } else {
           Element.update('status', '<%= msgMeasuring.toString() %>');
         }
         measuringCnt++;
         break;
       case 2:
         Element.update('status', '<%= msgMeasured.toString() %>');
         break;
       case 3:
         Element.update('status', '<%= msgUnknown.toString() %>');
         break;
       case 4:
         Element.update('status', '<%= msgUnsetting.toString() %>');
         break;
       case 5:
         Element.update('status', '<%= msgFixed.toString() %>');
         break;
       case 6:
         Element.update('status', '<%= msgMeasurementFailured.toString() %>');
         break;
       case 7:
           //リモートバッチフラグがtrueの場合、リモートバッチを表示
         if(executeRemoteBatch) {
             Element.update('status', '<%= msgMeasuring.toString() %><%= msgRemoteBatch.toString()%><%= msgErrorDcOffStatus.toString() %>');
         } else {
             Element.update('status', '<%= msgMeasuring.toString() %><%= msgErrorDcOffStatus.toString() %>');
         }
         measuringCnt++;
         break;
       case 8:
           //リモートバッチフラグがtrueの場合、リモートバッチを表示
         if(executeRemoteBatch) {
             Element.update('status', '<%= msgMeasuring.toString() %><%= msgRemoteBatch.toString()%><%= msgErrorCommunication.toString() %>');
         } else {
             Element.update('status', '<%= msgMeasuring.toString() %><%= msgErrorCommunication.toString() %>');
         }
         measuringCnt++;
         break;
     }
     
     Element.update('maxElectricPower', (result.status == 0) ? '-' : result.maxPower);
     Element.update('minElectricPower', (result.status == 0) ? '-' : result.minPower);
     Element.update('aveElectricPower', (result.status == 0) ? '-' : result.avgPower);
     Element.update('currentPower', (result.status == 1) ? result.curPower : '-');
     Element.update('measurementFrequency', result.count + '<%= times.toString() %>');

     <logic:equal name="SupportElectricPowerForm" property="validPowerControl" value="1">
      Element.update('ctrlLevel', result.controlLevel != -1 ? "<%= level.toString() %>" + result.controlLevel : '-');
     </logic:equal>
     
     totalHour = Math.floor(result.acumerationTime / 3600);
     totalMinute = Math.floor(result.acumerationTime / 60) % 60;
     Element.update('totalTime', totalHour + "&nbsp;" + "<%= hour.toString() %>" + "&nbsp;" + 
                                 totalMinute + "&nbsp;" + "<%= minute.toString() %>" + "&nbsp;");

    if(measuringCnt == 0) {
       stopMeasurement();
     }

    //グラフボタンの表示／非表示
    displayGraph(result);

    /* オブジェクト削除(メモリを明示的に解放) */
     delete result;
   }

   function displayGraph(result) {
       <logic:equal name="CurrentUserInfo" property="electricPowerMonitoring" value="1">
       form.elements["action.graph"].disabled = !(result.status == 1
              || result.status == 2
              || result.status == 7
              || result.status == 8);
       </logic:equal>
   }

   function callbackRenewalMeasuredPeriod(result) {
     Element.update('period', result);
     /* オブジェクト削除(メモリを明示的に解放) */
     delete result;
   }

   var form = document.SupportElectricPowerForm;
   
   function startMeasurement() {
     executer = new PeriodicalExecuter(renewalMeasureData, 5);
     Element.hide($('downloadLink'));
     hideInputField();
     <logic:equal name="CurrentUserInfo" property="electricPowerMonitoring" value="1">
     form.elements["action.run"].disabled = true;
     if(executeRemoteBatch) {
         form.elements["action.stop"].disabled = true;
     } else {
         form.elements["action.stop"].disabled = false;
     }
     </logic:equal>
   }

   function stopMeasurement() {
     if(executer != null) {
       executer.stop();
       executer = null;
     }
     Element.show($('downloadLink'));
     showInputField();
     <logic:equal name="CurrentUserInfo" property="electricPowerMonitoring" value="1">
      form.elements["action.run"].disabled = false;
      form.elements["action.stop"].disabled = true;
     </logic:equal>
   }

   window.onload = function callChangeTest() {
      <logic:equal name="CurrentUserInfo" property="electricPowerMonitoring" value="0">
        form.periodHour.disabled = true;
        form.periodMinute.disabled = true;
        form.interval.disabled = true;
        form.check[0].disabled = true;
        form.check[1].disabled = true;
      </logic:equal>
     changeTest(document.getElementsByName("periodHour").item(0));
     checkMeasureStatus();
   }
   

   window.onunload = function() {
       if (readingWindow != null && !readingWindow.closed)
           readingWindow.close();
   }

   function download() {
     dummyframe.location="<html:rewrite forward="downloadServerData" />";
   }

   function hideInputField() {
     Element.hide($('periodHour_input'));
     Element.hide($('periodMinute_input'));
     Element.hide($('interval_input'));
     Element.hide($('check_input'));
     Element.show($('periodHour_text'));
     Element.show($('periodMinute_text'));
     Element.show($('interval_text'));
     Element.show($('check_text'));
   }

   function showInputField() {
     Element.show($('periodHour_input'));
     Element.show($('periodMinute_input'));
     Element.show($('interval_input'));
     Element.show($('check_input'));
     Element.hide($('periodHour_text'));
     Element.hide($('periodMinute_text'));
     Element.hide($('interval_text'));
     Element.hide($('check_text'));
   }

   //測定値グラフ生成
   function openReadingGraph(form) {
       readingWindow = window.open('', 'readingWindow', 'width=620, height=320, menubar=no, toolbar=no, scrollbars=no, resizable=no, location=no, status=no');
       readingWindow.focus();
       form.action = '<html:rewrite forward="graphElectricPower"/>';
       form.target = 'readingWindow';
       form.submit();
       form.action = '<html:rewrite forward="measurementElectricPower"/>';
       form.target = 'info';
       return false;
   }
// -->
</script>

