// JavaScript Document

function calculateflight()
{
	var distance	=	(document.flightform.flightdistance.value);
	var carbon		=	(document.flightform.flightcarbonweight.value);
	var carbon1		=	(document.flightform.flightacarbonweight.value);
	var price		=	(document.flightform.flightprice.value);
	if(document.flightform.flighttype[0].checked){ var totalcarbon	=	(distance*carbon)/1000; }
	else { var totalcarbon	=	(distance*carbon1)/1000; }
	document.flightform.flighttotalcarbonweight.value = Math.round(totalcarbon*1000)/1000;
	document.flightform.amount.value = Math.round(totalcarbon*price*100)/100;
}

function calculateco2()
{
	var distance	=	(document.co2form.co2value.value);
	var price		=	(document.co2form.co2price.value);
	var totalcarbon	=	Math.round((distance*price)*1000)/1000;
	document.co2form.amount.value = totalcarbon;
}


function calculatecar()
{
	var distance	=	(document.carform.cardistance.value);
	var carbon		=	(document.carform.carcarbonweight.value);
	var price		=	(document.carform.carprice.value);
	var totalcarbon	=	(distance*carbon)/1000;
	document.carform.cartotalcarbonweight.value = Math.round(totalcarbon*1000)/1000;
	if(document.carform.triptype[0].checked){
		document.carform.amount.value = Math.round(totalcarbon*price*100)/100;
	} else if(document.carform.triptype[1].checked){
		document.carform.amount.value = Math.round(52*totalcarbon*price*100)/100;
	} else {
		document.carform.amount.value = Math.round(totalcarbon*price*100)/100;
	}
}

function calculatehome()
{
	var consumption	=	(document.homeform.homecomsumption.value);
	var carbon		=	(document.homeform.homecarbonweight.value);
	var price		=	(document.homeform.homeprice.value);
	var totalcarbon	=	(consumption*carbon);
	document.homeform.hometotalcarbonweight.value = Math.round(totalcarbon*1000)/1000;
	document.homeform.hometotalprice.value = Math.round(totalcarbon*price*100)/100;

	var econsumption=	(document.homeform.homeecomsumption.value);
	var ecarbon		=	(document.homeform.homeecarbonweight.value);
	var eprice		=	(document.homeform.homeeprice.value);
	var totalecarbon	=	(econsumption*ecarbon);
	document.homeform.homeetotalcarbonweight.value = Math.round(totalecarbon*1000)/1000;
	document.homeform.homeetotalprice.value = Math.round(totalecarbon*eprice*100)/100;

	document.homeform.amount.value	=	(Math.round((document.homeform.hometotalprice.value)*100)/100)+(Math.round((document.homeform.homeetotalprice.value)*100)/100);
}

function opendiv(divname1,divmenu1,divname2,divmenu2,divname3,divmenu3,divname4,divmenu4){
	document.getElementById(divname1).style.display=""; document.getElementById(divmenu1).style.display="";
	document.getElementById(divname2).style.display="None"; document.getElementById(divmenu2).style.display="None";
	document.getElementById(divname3).style.display="None"; document.getElementById(divmenu3).style.display="None";
	document.getElementById(divname4).style.display="None"; document.getElementById(divmenu4).style.display="None";
}
