<?php
     include "admin/library/config.php";
	 include "admin/library/functions.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:: Australian Solar Network ::</title>
<link href="css/main.css" type="text/css" rel="stylesheet"/>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/bg.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
function showVal()
{
	var daily_usage = document.getElementById("daily_usage").value;
	var solar_power_output = document.getElementById("solar_output").value;
	if(solar_power_output != "")
	{
		var pcntg_power_used_during_day = (daily_usage*25)/100;
		var pcntg_power_used_during_day = pcntg_power_used_during_day.toFixed(2);
		var pcntg_power_used_during_eve_night = (daily_usage*75)/100;
		var pcntg_power_used_during_eve_night = pcntg_power_used_during_eve_night.toFixed(2);
		
		if(solar_power_output > pcntg_power_used_during_day)
		{
			document.getElementById("power_grid").value = (solar_power_output - pcntg_power_used_during_day);
			document.getElementById("direct_house").value = pcntg_power_used_during_day;
		}
		else
		{
			document.getElementById("power_grid").value = (pcntg_power_used_during_day - solar_power_output);
			document.getElementById("direct_house").value = solar_power_output;
		}
	}
}
function calculateSaving()
{
	var daily_usage = document.getElementById("daily_usage").value;
	var solar_power_output = document.getElementById("solar_output").value;
	var pcntg_power_used_during_day = (daily_usage*25)/100;
	var pcntg_power_used_during_day = pcntg_power_used_during_day.toFixed(2);
	var pcntg_power_used_during_eve_night = (daily_usage*75)/100;
	var pcntg_power_used_during_eve_night = pcntg_power_used_during_eve_night.toFixed(2);
	
	
	var power_grid = document.getElementById("power_grid").value;
	var power_paid_retailer = document.getElementById("power_paid_retailer").value;
	var price_per_kwh = document.getElementById("price_per_kwh").value;
	if(daily_usage == "")
	{
		alert('Enter Average Daily Power Usage.');	
		document.getElementById("daily_usage").focus();
	}
	else if(solar_power_output == "")
	{
		alert('Enter Solar Power Output.');
		document.getElementById("solar_output").focus();
	}
	else if(power_paid_retailer == "")
	{
		alert('Enter Power Paid by Retailer.');
		document.getElementById("power_paid_retailer").focus();
	}
	else if(price_per_kwh == "")
	{
		alert('Enter Current Electricity Price/kwh.');
		document.getElementById("price_per_kwh").focus();
	}
	else
	{
		document.getElementById("power_feedback").innerHTML = (parseFloat(power_grid) * parseFloat(power_paid_retailer)).toFixed(2);
		document.getElementById("power_feedback_hidden").value = (parseFloat(power_grid) * parseFloat(power_paid_retailer)).toFixed(2);
		
		var direct_house = document.getElementById("direct_house").value;
		
		document.getElementById("system_produce").innerHTML = (parseFloat(direct_house) * parseFloat(price_per_kwh)).toFixed(2);
		document.getElementById("system_produce_hidden").value = (parseFloat(direct_house) * parseFloat(price_per_kwh)).toFixed(2);
		
		var power_feedback = parseFloat(document.getElementById("power_feedback_hidden").value);
		
		var system_produce = parseFloat(document.getElementById("system_produce_hidden").value);
		
		document.getElementById("total").innerHTML = power_feedback + system_produce;
		
		document.getElementById("solar_produce").innerHTML = (solar_power_output * price_per_kwh * 365).toFixed(2);
		document.getElementById("current_cost").innerHTML = (daily_usage * price_per_kwh * 365).toFixed(2);
		document.getElementById("solar_produce_hidden").value = (solar_power_output * price_per_kwh * 365).toFixed(2);
		document.getElementById("current_cost_hidden").value = (daily_usage * price_per_kwh * 365).toFixed(2);
		
		var solar_produce_val = document.getElementById("solar_produce_hidden").value;
		var current_cost_val = document.getElementById("current_cost_hidden").value;
		
		document.getElementById("saving").innerHTML = Math.ceil((parseFloat(solar_produce_val)/parseFloat(current_cost_val)) * 100)+"%";
	}
}
</script>
</head>

<body>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="50">&nbsp;</td>
        <td><img src="images/logo.png" width="650" height="93" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td valign="top"><table bgcolor="#FFFFFF" width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="50">&nbsp;</td>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="48"><?php include("common/menu.php"); ?></td>
            </tr>
            <tr>
              <td valign="top">&nbsp;</td>
            </tr>
            <tr>
              <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td>&nbsp;</td>
                  <td><img src="images/Header_FAQ.jpg" width="860" height="253" /></td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td class="style16">Our Saving Calculater</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="form">
                          <tr>
                            <td colspan="4" style="text-align:center; padding-bottom:10px;" class="style16"><strong>Energy Usage &amp; Financial Calculation Sheet</strong></td>
                          </tr>
                          <tr>
                            <td width="25%">Average Daily Power Usage (KW)</td>
                            <td width="15%"><input type="text" size="20" name="daily_usage" id="daily_usage" onkeyup="javascript:showVal();" /></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td width="25%">Solar System Power Output (KW)</td>
                            <td width="15%"><input type="text" size="20" name="solar_output" id="solar_output" onkeyup="javascript:showVal();" /></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td width="25%">Power Going Back Into Grid</td>
                            <td width="15%"><input type="text" size="20" name="power_grid" id="power_grid" /></td>
                            <td width="23%" style="padding-left:20px;">Price Paid by retailer for Your Power ($)</td>
                            <td width="22%" style="padding-left:10px;"><input type="text" size="20" name="power_paid_retailer" id="power_paid_retailer" /></td>
                          </tr>
                          <tr>
                            <td>Power Being generated by <br />the System Used Directly into House</td>
                            <td><input type="text" size="20" name="direct_house" id="direct_house" /></td>
                            <td style="padding-left:20px;">Current Electricity Price/kwh ($)</td>
                            <td style="padding-left:10px;"><input type="text" size="20" name="price_per_kwh" id="price_per_kwh" /></td>
                          </tr>
                          <tr> 
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td  style="text-align:center; float:right; margin-right:60px;" >
                            <input type="button" value="Calculate" id="calculate" onclick="javascript:calculateSaving();" class="button"/></td>
                          </tr>
                   
                          <tr>
                            <td colspan="4" style="padding-bottom:5px;">Value of Power Feedback into the Grid/Day($) :<span id="power_feedback"></span>
                              <input type="hidden" id="power_feedback_hidden" value="" />
                            </td>
                          </tr>
                          <tr>
                            <td colspan="4" style="padding-bottom:5px;">Value Your System Products without feed-in-tariff($): <span id="system_produce"></span>
                            <input type="hidden" id="system_produce_hidden" value="" />
                            </td>
                          </tr>
                          <tr>
                            <td colspan="4" style="padding-bottom:5px;">Total of feed-in and System Production($) : <span id="total"></span></td>
                          </tr>
                          <tr>
                            <td colspan="4" style="padding-bottom:5px;">Your Solar Will produce/Year($) : <span id="solar_produce"></span>
                            <input type="hidden" id="solar_produce_hidden" value="" />
                            </td>
                          </tr>
                          <tr>
                            <td colspan="4" style="padding-bottom:5px;">Current Cost For Power/Year($): <span id="current_cost"></span>
                            <input type="hidden" id="current_cost_hidden" value="" />
                            </td>
                          </tr>
                          <tr>
                            <td colspan="4" style="padding-bottom:5px;">Saving/Year : <span id="saving"></span></td>
                          </tr>
                        </table>
                  </td>
                  
                  <td>&nbsp;</td>
                </tr>
                
                
                
                <tr>
                  <td width="20">&nbsp;</td>
                  <td>&nbsp;</td>
                  <td width="20">&nbsp;</td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td valign="top">&nbsp;</td>
            </tr>
            
        </table></td>
        <td width="50">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  
  <tr bgcolor="#ffffff">
    <td height="84" align="center" style="background:url(images/footer2.jpg) no-repeat center">
        <!-- HTML codes by Quackit.com -->
        <?php include("common/logoscroler.php"); ?></td>
  </tr>
   <tr>
        <td height="28" style="background:url(images/footer_bg.jpg) no-repeat center">&nbsp; </td>
      </tr>
      
      <tr style="margin-top:10px;">
        <td><?php include("common/footer.php"); ?></td>
  </tr>
      <tr>
        <td height="30" align="center" class="style15">© Australian Solar Network 2011 </td>
      </tr>
      
    </table></td>
  </tr>
</table>
</body>
</html>