// JavaScript Document

var webroot = '/';

function getNextBusinessStep(step,setArray)
   {
    new Ajax.Updater('business-steps', 'business-step-'+step+'.php', {
    method: 'get',
	evalScripts : true
    });
	
}

function updateTravelInfo() {
	
	var travel_totalPublic = document.forms['publicTransportForm'].travel_totalPublic.value;
	var travel_totalCars=document.forms['companyCarsForm'].travel_totalCars.value;
	var travel_totalFlight=document.forms['companyFlightsForm'].travel_totalFlight.value;
	
	var stepPublic=document.forms['publicTransportForm'].stepPublic.value;
	var stepCar=document.forms['companyCarsForm'].stepCar.value;
	var stepFlight=document.forms['companyFlightsForm'].stepFlight.value;
	
	//alert("values to be sent: " + publicTransport+ "," +companyCars + "," + companyFlights);
	
	
	document.getElementById('loading').style.display = 'block';
	new Ajax.Updater('emissions', webroot + 'modules/carbon-calculators/calculators/business/getBusinessFootprint.php', {
       method: 'post',
       parameters: {travel_totalPublic:travel_totalPublic,travel_totalCars:travel_totalCars,travel_totalFlight:travel_totalFlight, stepPublic:stepPublic, stepFlight:stepFlight, stepCar:stepCar},
       evalScripts : true
       ,onComplete: function(transport) {document.getElementById('loading').style.display = "none";
	   }

});
return false;
} 

function updateFreightInfo() {
	var shipping_totalRoad = document.forms['roadFreightForm'].shipping_totalRoad.value;
	var shipping_totalSea=document.forms['seaFreightForm'].shipping_totalSea.value;
	var shipping_totalAir=document.forms['airFreightForm'].shipping_totalAir.value;
	var stepRoad=document.forms['roadFreightForm'].stepRoad.value;
	var stepSea=document.forms['seaFreightForm'].stepSea.value;
	var stepAir=document.forms['airFreightForm'].stepAir.value;

	//alert("values to be sent: " + roadFreightCarbon+ "," +seaFreightCarbon + "," + airFreightCarbon);
	document.getElementById('loading').style.display = 'block';
	new Ajax.Updater('emissions', webroot + 'modules/carbon-calculators/calculators/business/getBusinessFootprint.php', {
       method: 'post',
       parameters: {shipping_totalRoad:shipping_totalRoad,shipping_totalSea:shipping_totalSea,shipping_totalAir:shipping_totalAir, stepRoad:stepRoad, stepSea:stepSea, stepAir:stepAir},
       evalScripts : true
       ,onComplete: function(transport) {document.getElementById('loading').style.display = "none";
	   }

});
return false;
} 


function clearBusiness() {
	new Ajax.Updater('emissions', webroot + 'modules/carbon-calculators/calculators/business/getBusinessFootprint.php', {
    method: 'post',
	parameters: { killSession: '1' },
	evalScripts : true
    });
	return false;
}

function showReport(formID,finish) {
	if(formID==null || formID=='undefined') {formID='calcForm';}
	new Ajax.Updater('chartArea', webroot + 'modules/carbon-calculators/calculators/business/getBusinessFootprint.php?finish=' +finish, {
    method: 'post',
	parameters: $(formID).serialize(true),
	evalScripts : true
    });
}

upateTotalCarbon = function() {
	var businessTotal = $F('businessTotal');
}
 
function updateElement(updatedEl,totalEl) {
	var newValue = $F(totalEl);
	document.getElementById(updatedEl).value = newValue;
}

 function updateHomeInfo(formID) {
       new Ajax.Updater('emissions', 'getHome.php', {
   		method: 'get',
       	parameters: $(formID).serialize(true),
       	evalScripts : true
   });
}


function showChart() {
	new Ajax.Updater('chartArea','../../FusionCharts/mycharts/chart.php');
}
