// JavaScript Document
var dwin = null;
function debug(msg) {
if ((dwin == null) || (dwin.closed)) {
dwin = window.open('','debugconsole','scrollbars=yes,resizable=yes,height=100,width=300');
dwin.document.open('text/html', 'replace');
}
dwin.document.writeln(''+msg);
dwin.scrollTo(0,10000);
dwin.focus();
// dwin.document.close();  // uncomment this if you want to see only last message , not all the previous messages
}
function save_total(){
	var save_total =1; //change this stupid way..
	var residents = document.getElementById("numresidents");
    var numresidents = residents.options[residents.selectedIndex].value;
	var electricity = document.getElementById("electricitybill");
    var electricitybill = electricity.options[electricity.selectedIndex].value;
	var gas = document.getElementById("gasbill");
    var gasbill = gas.options[gas.selectedIndex].value;
	var propane = document.getElementById("propanebill");
    var propanebill = propane.options[propane.selectedIndex].value;
	var oil = document.getElementById("oilbill");
    var oilbill = oil.options[oil.selectedIndex].value;
	var newspaper = document.getElementById("newspaper_recycle");
    var newspaper_recycle = newspaper.options[newspaper.selectedIndex].value;
	var plastic = document.getElementById("plastic_recycle");
    var plastic_recycle = plastic.options[plastic.selectedIndex].value;
	var glass = document.getElementById("glass_recycle");
    var glass_recycle = glass.options[glass.selectedIndex].value;
	var aliminum = document.getElementById("aliminum_recycle");
    var aliminum_recycle = aliminum.options[aliminum.selectedIndex].value;
	
	my_ajax_request('/carbon-calculator/widgets/household/inc/ajax_widget.php','widget=household&unit='+ Form.getInputs('offset_form','radio','unit').find(function(radio) { return radio.checked; }).value +'&numresidents='+ numresidents +'&electricitybill='+ electricitybill + '&gasbill='+ gasbill +'&propanebill='+ propanebill +'&oilbill=' + oilbill +'&newspaper_recycle='+ newspaper_recycle +'&plastic_recycle=' + plastic_recycle +'&glass_recycle='+ glass_recycle +'&aliminum_recycle=' + aliminum_recycle + '&user_id=' + user_id+'&save_total='+save_total);
		
	
		
	
	}
function calculate(save_total)
{
	var user_id = document.getElementById("user_id").value;
	if(!save_total){
	save_total = 0;
	}
	var residents = document.getElementById("numresidents");
    var numresidents = residents.options[residents.selectedIndex].value;
	var electricity = document.getElementById("electricitybill");
    var electricitybill = electricity.options[electricity.selectedIndex].value;
	var gas = document.getElementById("gasbill");
    var gasbill = gas.options[gas.selectedIndex].value;
	var propane = document.getElementById("propanebill");
    var propanebill = propane.options[propane.selectedIndex].value;
	var oil = document.getElementById("oilbill");
    var oilbill = oil.options[oil.selectedIndex].value;
	var newspaper = document.getElementById("newspaper_recycle");
    var newspaper_recycle = newspaper.options[newspaper.selectedIndex].value;
	var plastic = document.getElementById("plastic_recycle");
    var plastic_recycle = plastic.options[plastic.selectedIndex].value;
	var glass = document.getElementById("glass_recycle");
    var glass_recycle = glass.options[glass.selectedIndex].value;
	var aliminum = document.getElementById("aliminum_recycle");
    var aliminum_recycle = aliminum.options[aliminum.selectedIndex].value;
	
	my_ajax_request('/carbon-calculator/widgets/household/inc/ajax_widget.php','widget=household&unit='+ Form.getInputs('offset_form','radio','unit').find(function(radio) { return radio.checked; }).value +'&numresidents='+ numresidents +'&electricitybill='+ electricitybill + '&gasbill='+ gasbill +'&propanebill='+ propanebill +'&oilbill=' + oilbill +'&newspaper_recycle='+ newspaper_recycle +'&plastic_recycle=' + plastic_recycle +'&glass_recycle='+ glass_recycle +'&aliminum_recycle=' + aliminum_recycle + '&user_id=' + user_id+'&save_total='+save_total);
	
}
