<!-- //

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function resetHTML() {

document.getElementById('savingsBreakdown').innerHTML = '';


return;

}

function printPage() {

var b3=parseFloat(document.getElementById("b3").value);
var b6=parseFloat(document.getElementById("b6").value);

if(b3==0 && b6==0) {

alert('Please enter a number of fittings before printing the report');


} else {

window.print();
return false;


}


}

function EnergyCalc(form) {

var circuitWatts250 = 283;
var circuitWatts400 = 430;
var circuitWatts200 = 217;
var circuitWatts350 = 374;
var co2 = 0.53702*10;

var kitAtype = '200W STANDARD conversion kit including lamp'; //Non dimming kit for 250W
var kitBtype = '200W VENTRONIC conversion kit including lamp'; //Dimming kit for 250W
var kitCtype = '400W STANDARD conversion kit including lamp'; //Non dimming kit for 400W
var kitDtype = '400W VENTRONIC conversion kit including lamp'; //Dimming kit for 400W

var kitAcost = 80;
var kitBcost = 180;
var kitCcost = 80;
var kitDcost = 180;

var b3=parseFloat(document.getElementById("b3").value); 
var c3=parseFloat(document.getElementById("c3").value); 
var d3=parseFloat(document.getElementById("d3").value); 
var e3=parseFloat(document.getElementById("e3").value); 
var f3=parseFloat(document.getElementById("f3").value); 
var g3=parseFloat(document.getElementById("g3").value);
var b6=parseFloat(document.getElementById("b6").value); 
var f6=parseFloat(document.getElementById("f6").value); 
var g6=parseFloat(document.getElementById("g6").value); 

var total_250W_qty=b3;
var total_400W_qtys=b6;
var total_200W_dims=f3;
var total_350W_dims=f6;

var total_250W_cost = total_250W_qty*circuitWatts250*c3*d3*52*e3/1000; 
var total_400W_cost = total_400W_qtys*circuitWatts400*c3*d3*52*e3/1000;

var total_200W_cost = total_250W_qty*circuitWatts200*c3*d3*52*e3/1000; 
var total_350W_cost = total_400W_qtys*circuitWatts350*c3*d3*52*e3/1000;

var total_250W_savings = total_250W_cost-total_200W_cost; 
var total_400W_savings = total_400W_cost-total_350W_cost;

var dim_savings_200W = circuitWatts200*f3*c3*d3*g3*52*e3*0.5*0.00001;  
var dim_savings_350W = circuitWatts350*f6*c3*d3*g6*52*e3*0.5*0.00001;  

var totalSavings = roundNumber(total_250W_savings+total_400W_savings+dim_savings_200W+dim_savings_350W,2); 

var totalKWHsavings = total_250W_savings+total_400W_savings+dim_savings_200W+dim_savings_350W/e3;
var totalco2Savings = totalKWHsavings*co2;   



con = new Array(total_250W_qty,total_400W_qtys,total_200W_dims,total_350W_dims); 

var conversions='';


if(con[0]!=0 || con[1]!=0 || con[2]!=0 || con[3]!=0) {

if(con[0]!=0) {

  conversions+= '<li>By converting ' + con[0]  + ' existing 250W fittings to 200W you will save £' + roundNumber(total_250W_savings,2).toFixed(2) + ' per year</li>';

}



if(con[1]!=0) {

  conversions+= '<li>By converting ' + con[1]  + ' existing 400W fittings to 350W you will save £' + roundNumber(total_400W_savings,2).toFixed(2) + ' per year</li>';

}

if(con[2]!=0) {

  conversions+= '<li>Auto dimming ' + con[2]  + ' x 200W fittings to 50% will save you an additional £' + roundNumber(dim_savings_200W,2).toFixed(2) + ' per year</li>';

}



if(con[3]!=0) {

  conversions+= '<li>Auto dimming ' + con[3]  + ' x 350W fittings to 50% will save you an additional £' + roundNumber(dim_savings_350W,2).toFixed(2) + ' per year</li>';

}

var co2Savings ='';

if(conversions) {

co2Savings='<br /><span style="font-weight:normal;">In addition you will save ' + roundNumber(totalco2Savings,0) + ' kg of CO2</span>';

}

// CONVERSIONS ####################################################

kitAqty=b3-f3;

var kitAtotalCost=kitAqty*kitAcost;

kitBqty=f3;

var kitBtotalCost=kitBqty*kitBcost;

kitCqty=b6-f6;

var kitCtotalCost=kitCqty*kitCcost;

kitDqty=f6;

var kitDtotalCost=kitDqty*kitDcost;

var kitTotalcost=kitAtotalCost+kitBtotalCost+kitCtotalCost+kitDtotalCost;


var kits='';

if(kitAqty!=0 || kitBqty!=0 || kitCqty!=0 || kitDqty!=0) {

  kits += '<tr><th>QTY</th><th>TYPE OF CONVERSION KIT REQUIRED</th></tr>'

}

if(kitAqty!=0) {

  kits += '<tr><td>' + kitAqty + '</td><td>' + kitAtype + '</td></tr>';

}

if(kitBqty!=0) {

  kits += '<tr><td>' + kitBqty + '</td><td>' + kitBtype + '</td></tr>';

}

if(kitCqty!=0) {

  kits += '<tr><td>' + kitCqty + '</td><td>' + kitCtype + '</td></tr>';

}

if(kitDqty!=0) {

  kits += '<tr><td>' + kitDqty + '</td><td>' + kitDtype + '</td></tr>';

}

if(kitAqty!=0 || kitBqty!=0 || kitCqty!=0 || kitDqty!=0) {

  kits += '<tr><td colspan="2" style="text-align:right; font-weight:bold; font-size:1.2em;"></td></tr>'

  kits = '<table id="conkits">' + kits + '</table>';

}

// PAYBACK ####################################################

var monthlySaving = totalSavings/12;

var payback = kitTotalcost/monthlySaving;



document.getElementById('savingsBreakdown').innerHTML = '<div class="results1"><h2>Summary of energy savings:</h2><ul>'
 + conversions + '</ul><p style="font-size:1.4em;">Total energy saving per year is <span style="font-weight:bold;">&pound;'
 + roundNumber(totalSavings,2).toFixed(2) + '</span> with a reduction in CO2 emissions of <span style="font-weight:bold;">'
 + roundNumber(totalco2Savings,0) + ' kg</span></p></div><div class="results2"><h2>Conversion kits required to achieve these savings:</h2>'
 + kits +'</div><!-- <div class="results3"><h2>Payback time for this conversion: ' + roundNumber(payback,0) + ' months</h2></div> -->';

alert('THANK YOU - The results of your calculation are displayed in the bottom section of the page. Please feel free to print the report and contact us for an itemised quotation.');


} else {

alert('Please enter a number of fittings');

}

}


// -->