
//var pers  //number of persons in household
var ele_co2 = 0
//var ele_amount = 0

var gas_fac = 11.2
var gas_co2 = 0

//mpg = new Array(4)
//miles = new Array(4)
//car_co2 = new Array(4)

var car01_co2 = 0
var car02_co2 = 0
var car03_co2 = 0
var car04_co2 = 0

var foo_co2 = 0
var mis_co2 = 0

var mea_factor = 1 //meat factor
var org_factor = 1 //organic food

var mis_factor = 1 //misc spending
var com_factor = 0 //composting?
var re1_factor = 0 //recycling 1 ?
var re2_factor = 0
var bus_co2 = 0
var tra_co2 = 0
var fli_co2 = 0

//---------------------------------------------------------------------------------------------
function LoadEvents() {

document.getElementById("eleCalTable").style.display = "none" ;
document.getElementById("gasCalTable").style.display = "none" ; 
document.getElementById("gaskWhTable").style.display = "none" ; 

document.getElementById("carCalTable01").style.display = "none" ; 
document.getElementById("carCalTable02").style.display = "none" ; 
document.getElementById("carCalTable03").style.display = "none" ; 
document.getElementById("carCalTable04").style.display = "none" ; 

document.getElementById("fliCalTableUK").style.display = "none" ; 
document.getElementById("fliCalTableEur").style.display = "none" ; 
document.getElementById("fliCalTableAme").style.display = "none" ; 
document.getElementById("fliCalTableAsi").style.display = "none" ; 

}
//---------------------------------------------------------------------------------------------
function calculate_ele(x) {

if (x == 1700) { ele_kWh = 1700 ; document.getElementById("eleCalTable").style.display = "none" ; }
if (x == 3300) { ele_kWh = 3300 ; document.getElementById("eleCalTable").style.display = "none" ; }
if (x == 5000) { ele_kWh = 5000 ; document.getElementById("eleCalTable").style.display = "none" ; }
if (x == 0) { document.getElementById("eleCalTable").style.display = "block" ; } //added 20.7 
if (x == 1) {
	var ele2 = document.form1.ele2.value ;
	var ele1 = document.form1.ele1.value ;
	ele_kWh = ele2 - ele1 ;
	}

document.form1.ele_kWh.value = Math.round(ele_kWh) ;

var ele_ren = 1 //proportion of ele renewable
if (document.form1.ele_ren.checked == true) ele_ren = 0.1 ;

ele_co2 = ele_kWh * ele_ren * 0.00043 ;
document.form1.ele_co2.value = Math.round(ele_co2 * 100)/100 ;

calculate_tot() ;

}
//---------------------------------------------------------------------------------------------
function calculate_gas(x) {

var gas_result //final amount in kWh
if (x == 10000) { 
	gas_kWh = 10000 ; 
	document.getElementById("gasCalTable").style.display = "none" ; 
	document.getElementById("gaskWhTable").style.display = "none" ; 
	} 
if (x == 20000) { 
	gas_kWh = 20000 ; 
	document.getElementById("gasCalTable").style.display = "none" ; 
	document.getElementById("gaskWhTable").style.display = "none" ; 
	} 
if (x == 28000) { 
	gas_kWh = 28000 ; 
	document.getElementById("gasCalTable").style.display = "none" ; 
	document.getElementById("gaskWhTable").style.display = "none" ; 
	} 
if (x == 0) { 
	document.getElementById("gaskWhTable").style.display = "none" ; 
	document.getElementById("gasCalTable").style.display = "block" ;  //i.e. show calc. table
	}
if (x == 1) {
	var gas2 = document.form1.gas2.value ;
	var gas1 = document.form1.gas1.value ;
	var gas_diff = gas2 - gas1;
	document.form1.gas_diff.value = gas_diff ;
	gas_kWh = Math.round(gas_diff * gas_fac); // default gas_fac is defined at the top for metric meters and updated by code in radio buttons
	document.form1.gas_kWh_box.value = gas_kWh 
	}
if (x == 2) { 
	document.getElementById("gasCalTable").style.display = "none" ; 
	document.getElementById("gaskWhTable").style.display = "block" ; 
	} 
if (x == 3) {
	var gas3 = document.form1.gas3.value ;
	gas_kWh = gas3 ; 
	}

document.form1.gas_kWh.value = gas_kWh ;

gas_co2 = gas_kWh * 0.00019 ;
document.form1.gas_co2.value = Math.round(gas_co2 * 100)/100 ;

calculate_tot() ;

}
//---------------------------------------------------------------------------------------------
function display_car_questions(x) {

if (x > 0) document.getElementById("carCalTable01").style.display = "block" ;
if (x < 1) document.getElementById("carCalTable01").style.display = "none" ;
if (x > 1) document.getElementById("carCalTable02").style.display = "block" ;
if (x < 2) document.getElementById("carCalTable02").style.display = "none" ;
if (x > 2) document.getElementById("carCalTable03").style.display = "block" ;
if (x < 3) document.getElementById("carCalTable03").style.display = "none" ;
if (x > 3) document.getElementById("carCalTable04").style.display = "block" ;
if (x < 4) document.getElementById("carCalTable04").style.display = "none" ;

}

//---------------------------------------------------------------------------------------------
function calculate_car01(x) {

if (x == 1)  document.form1.mpg01.value = 45 ; 
if (x == 2)  document.form1.mpg01.value = 35 ; 
if (x == 3)  document.form1.mpg01.value = 25 ; 
mpg01 = document.form1.mpg01.value 

if (x == 5)  document.form1.mil01.value = 6000 ; 
if (x == 6)  document.form1.mil01.value = 9000 ; 
if (x == 7)  document.form1.mil01.value = 12000 ; 
miles01 = document.form1.mil01.value 

car01_co2 = Math.round(100 * miles01 * 0.0105 / mpg01) / 100 ; 
if (mpg01 == 0) car01_co2 = "" ;
document.form1.car01_co2.value = car01_co2 ;

calculate_tot() ;

}
//---------------------------------------------------------------------------------------------
function calculate_car02(x) {

if (x == 1)  document.form1.mpg02.value = 45 ; 
if (x == 2)  document.form1.mpg02.value = 35 ; 
if (x == 3)  document.form1.mpg02.value = 25 ; 
mpg02 = document.form1.mpg02.value 

if (x == 5)  document.form1.mil02.value = 6000 ; 
if (x == 6)  document.form1.mil02.value = 9000 ; 
if (x == 7)  document.form1.mil02.value = 12000 ; 
miles02 = document.form1.mil02.value 

car02_co2 = Math.round(100 * miles02 * 0.0105 / mpg02) / 100 ; 
if (mpg02 == 0) car02_co2 = "" ;
document.form1.car02_co2.value = car02_co2 ;

calculate_tot() ;

}
//---------------------------------------------------------------------------------------------
function calculate_car03(x) {

if (x == 1)  document.form1.mpg03.value = 45 ; 
if (x == 2)  document.form1.mpg03.value = 35 ; 
if (x == 3)  document.form1.mpg03.value = 25 ; 
mpg03 = document.form1.mpg03.value 

if (x == 5)  document.form1.mil03.value = 6000 ; 
if (x == 6)  document.form1.mil03.value = 9000 ; 
if (x == 7)  document.form1.mil03.value = 12000 ; 
miles03 = document.form1.mil03.value 

car03_co2 = Math.round(100 * miles03 * 0.0105 / mpg03) / 100 ; 
if (mpg03 == 0) car03_co2 = "" ;
document.form1.car03_co2.value = car03_co2 ;

calculate_tot() ;

}
//---------------------------------------------------------------------------------------------
function calculate_car04(x) {

if (x == 1)  document.form1.mpg04.value = 45 ; 
if (x == 2)  document.form1.mpg04.value = 35 ; 
if (x == 3)  document.form1.mpg04.value = 25 ; 
mpg04 = document.form1.mpg04.value 

if (x == 5)  document.form1.mil04.value = 6000 ; 
if (x == 6)  document.form1.mil04.value = 9000 ; 
if (x == 7)  document.form1.mil04.value = 12000 ; 
miles04 = document.form1.mil04.value 

car04_co2 = Math.round(100 * miles04 * 0.0105 / mpg04) / 100 ; 
if (mpg04 == 0) car04_co2 = "" ;
document.form1.car04_co2.value = car04_co2 ;

calculate_tot() ;

}
//---------------------------------------------------------------------------------------------

function calculate_foo_sum(v) {

if (v == 1) mea_factor = 1.15 // i.e. above average
if (v == 2) mea_factor = 1.0 // i.e. average
if (v == 3) mea_factor = 0.85 // i.e. below average
if (v == 4) mea_factor = 0.7 // i.e. veg
if (v == 5) mea_factor = 0.5 // i.e. vegan

if (v == 11) org_factor = 1.0 // i.e. average
if (v == 12) org_factor = 0.75 // i.e. part
if (v == 13) org_factor = 0.5 // i.e. mostly

foo_co2 = Math.round (1.4 * mea_factor * org_factor * 100) / 100
document.form1.foo_co2.value = foo_co2

calculate_tot() ;

//document.form1.foo_sum.value = Math.round (1.4 * mea_factor * org_factor * 100) / 100

}

//---------------------------------------------------------------------------------------------

function calculate_mis_sum(v) {


if (v == 1) mis_factor = 1.429  // i.e. above average (5)
if (v == 2) mis_factor = 1.0    // i.e. average (3.5)
if (v == 3) mis_factor = 0.571  // i.e. below average (2)

if (v == 11) com_factor = 0 // i.e. no
if (v == 12) com_factor = 1 // i.e. yes compost

if (v == 21) re1_factor = 0 // i.e. no
if (v == 22) re1_factor = 1 // i.e. yes recycle glass, paper and metal

if (v == 31) re2_factor = 0 // i.e. no
if (v == 32) re2_factor = 1 // i.e. yes recycle plastic

mis_co2 = 3.5 * mis_factor  - 0.13 * com_factor - 0.07 * re1_factor - 0.14 * re2_factor

document.form1.mis_co2.value = Math.round (mis_co2 * 100) / 100

calculate_tot() ;

}
//---------------------------------------------------------------------------------------------
function show_country_mess(cou) {
alert("This calculator is constructed using values applicable to the UK.  Values for other countries will be roughly the same.  If you would like to help make the calculator more applicable to other countries, please contact us.");
}

//---------------------------------------------------------------------------------------------
function calculate_bus() {

var bus = document.form1.bus.value ;
bus_co2 = Math.round(bus * 0.0001 * 100) / 100 ;
document.form1.bus_co2.value = bus_co2 ;

calculate_tot() ;
}
//---------------------------------------------------------------------------------------------
function calculate_tra() {

var tra = document.form1.tra.value ;
tra_co2 = Math.round(tra * 0.0001 * 100) / 100 ;
document.form1.tra_co2.value = tra_co2 ;

calculate_tot() ;
}
//---------------------------------------------------------------------------------------------
function show_hide_UK(x) {

if (x == 1) document.getElementById("fliCalTableUK").style.display = "none" ; 
if (x == 2) document.getElementById("fliCalTableUK").style.display = "block" ; 

}

//---------------------------------------------------------------------------------------------
function show_hide_eur(x) {

if (x == 1) document.getElementById("fliCalTableEur").style.display = "none" ; 
if (x == 2) document.getElementById("fliCalTableEur").style.display = "block" ; 

}
//---------------------------------------------------------------------------------------------
function calculate_fli_eur() {

//alert("gh");

var e2 = document.form1.e2.value;
var e3 = document.form1.e3.value;
var e4 = document.form1.e4.value;
var e5 = document.form1.e5.value;
var e6 = document.form1.e6.value;
var e8 = document.form1.e8.value;
var e10 = document.form1.e10.value;
var e18 = document.form1.e18.value;
var e20 = document.form1.e20.value;
var e24 = document.form1.e24.value;

var tot = e2 * 2 + e3 * 3 + e4 * 4 + e5 * 5 + e6 * 6 + e8 * 8 + e10 * 10 + e18 * 18 + e20 * 20 + e24 * 24 ;

document.form1.fli_eur.value = tot;

calculate_fli_tot() ;

}
//---------------------------------------------------------------------------------------------
function show_hide_ame(x) {

if (x == 1) document.getElementById("fliCalTableAme").style.display = "none" ; 
if (x == 2) document.getElementById("fliCalTableAme").style.display = "block" ; 

}

//---------------------------------------------------------------------------------------------
function calculate_fli_ame() {

var a16 = document.form1.a16.value;
var a18 = document.form1.a18.value;
var a20 = document.form1.a20.value;
var a24 = document.form1.a24.value;
var a32 = document.form1.a32.value;

var tot = a16 * 16 + a18 * 18 + a20 * 20 + a24 * 24 + a32 * 32 

document.form1.fli_ame.value = tot;

calculate_fli_tot() ;

}
//---------------------------------------------------------------------------------------------
function show_hide_asi(x) {

if (x == 1) document.getElementById("fliCalTableAsi").style.display = "none" ; 
if (x == 2) document.getElementById("fliCalTableAsi").style.display = "block" ; 

}
//---------------------------------------------------------------------------------------------
function calculate_fli_asi() {

var s8 = document.form1.s8.value;
var s10 = document.form1.s10.value;
var s16 = document.form1.s16.value;
var s18 = document.form1.s18.value;
var s20 = document.form1.s20.value;
var s24 = document.form1.s24.value;
var s48 = document.form1.s48.value;

var tot = s8 * 8 + s10 * 10 + s16 * 16 + s18 * 18 + s20 * 20 + s24 * 24 + s48 * 48 

document.form1.fli_asi.value = tot;

calculate_fli_tot() ;

}

//---------------------------------------------------------------------------------------------
function calculate_fli_tot() {

//alert("gh")

var fli_UK = document.form1.fli_UK.value  ;
var fli_eur = document.form1.fli_eur.value ;
var fli_ame = document.form1.fli_ame.value ;
var fli_asi = document.form1.fli_asi.value ;
var fli_hrs = fli_UK * 1 + fli_eur * 1 + fli_ame * 1 + fli_asi * 1 ;

document.form1.fli_hrs.value = fli_hrs ;

fli_co2 = fli_hrs * 0.25 ;
document.form1.fli_co2.value = Math.round(fli_co2 * 100)/100 ;

calculate_tot() ;
}

//---------------------------------------------------------------------------------------------
function calculate_tot() {

var peo = document.form1.peo.value 

var tot_co2 = (ele_co2 + gas_co2 + car01_co2 + car02_co2 + car03_co2 + car04_co2)/ peo 
//alert (tot_co2)

tot_co2 = tot_co2 + foo_co2 + mis_co2 + 1.1 + bus_co2 + tra_co2 + fli_co2
tot_co2 = Math.round(tot_co2 * 100)/100 
document.form1.tot_co2.value = tot_co2 ;

Show_total_vs_world(tot_co2)
}
//---------------------------------------------------------------------------------------------
function Show_total_vs_world(tot) { //compared to rest of the world

document.form1.tot_co2_versus_world.value = tot ;

var max = Math.max (20, tot); // as 20 is the largest of the places shown
var scale = 300 / max //was 400 until 12.3

bar = scale * tot ; if (bar < 1) {bar = 1; } ; document.getElementById("your_total").style.width = bar ;
bar = scale * 10.7 ; if (bar < 1) {bar = 1; } ; document.getElementById("UK").style.width = bar ;
bar = scale * 4 ; if (bar < 1) {bar = 1; } ; document.getElementById("World").style.width = bar ;
bar = scale * 20 ; if (bar < 1) {bar = 1; } ; document.getElementById("USA").style.width = bar ;
bar = scale * 6.1 ; if (bar < 1) {bar = 1; } ; document.getElementById("Switzerland").style.width = bar ;
bar = scale * 3.2 ; if (bar < 1) {bar = 1; } ; document.getElementById("China").style.width = bar ;
bar = scale * 1.2 ; if (bar < 1) {bar = 1; } ; document.getElementById("India").style.width = bar ;
bar = scale * 0.1 ; if (bar < 1) {bar = 1; } ; document.getElementById("Tanzania").style.width = bar ;
bar = scale * 1.5 ; if (bar < 1) {bar = 1; } ; document.getElementById("Sustainable").style.width = bar ;

}
//---------------------------------------------------------------------------------------------
function updateScreen (id, x) {

if (x == 0) x = "-" ;
var newtext = document.createTextNode(x) ; 
var cel = document.getElementById(id) ;
var last_child = cel.lastChild ;
if (last_child != null) {cel.removeChild(cel.lastChild) } ; //'if' is needed for MSIE
cel.appendChild(newtext) ; 

}

//---------------------------------------------------------------------------------------------
function updatepc (id, x, tot) {


//var pc = Math.round( 100 * x / tot ) + "%" ; updateScreen (id, pc ) ;
var pc = "-" ;
if (x != 0) pc = Math.round( 100 * x / tot ) + "%" ; 

updateScreen (id, pc ) ;

}

//--------------------------------------------------------------------------------------------------------------
function calculate(check) {

var tot = 0 ;
var qas = 0 ; // i.e. questions answered

pers = document.form1.pers.value ;
if (pers != "?") qas = qas + 1 ;

var ele = document.form1.ele.value;
if (ele != "?") {
	var ele_co2 = ele * 0.00043 ;
	var ele_pp = Math.round(ele_co2 * 100/ pers)/100 ;
	var ele_co2 = Math.round(ele_co2 * 100)/100 ;
	updateScreen ("ele_co2", ele_co2 ) ;
	updateScreen ("ele_pp", ele_pp ) ;
	tot = tot + ele_pp ; qas = qas + 1 ;
	}

var gas = document.form1.gas.value;
if (gas != "?") {
	var gas_co2 = gas * 0.00019 ;
	var gas_pp = Math.round(gas_co2 * 100/ pers)/100 ;
	var gas_co2 = Math.round(gas_co2 * 100)/100 ;
	updateScreen ("gas_co2", gas_co2 ) ;
	updateScreen ("gas_pp", gas_pp ) ;
	tot = tot + gas_pp ; qas = qas + 1 ;
	}

var car1_con = document.form1.car1_con.value;
var car1 = document.form1.car1.value ;
if (car1 != "?") {
	var car1_co2 = Math.round(100 * car1 * 0.0105 / car1_con) / 100 ; 
	var car1_pp = Math.round( car1_co2 * 100/ pers)/100;
	updateScreen ("car1_co2", car1_co2 ) ;
	updateScreen ("car1_pp", car1_pp ) ;
	tot = tot + car1_pp ; qas = qas + 1 ;
	}

var car2_con = document.form1.car2_con.value;
var car2 = document.form1.car2.value;
if (car2 != "?") {
	var car2_co2 = Math.round(100 * car2 * 0.0105 / car2_con ) / 100; 
	var car2_pp = Math.round(car2_co2 * 100/ pers)/100;
	updateScreen ("car2_co2", car2_co2 ) ;
	updateScreen ("car2_pp", car2_pp ) ;
	tot = tot + car2_pp ; qas = qas + 1 ;
	}

var car3_con = document.form1.car3_con.value;
var car3 = document.form1.car3.value;
if (car3 != "?") {
	var car3_co2 = Math.round(100 * car3 * 0.0105 / car3_con) / 100 ; 
	var car3_pp = Math.round(car3_co2 * 100/ pers ) / 100 ;
	updateScreen ("car3_co2", car3_co2 ) ;
	updateScreen ("car3_pp", car3_pp ) ;
	tot = tot + car3_pp ; qas = qas + 1 ;
	}

var foo = document.form1.foo.value ;
if (foo != "?") {
	var foo_pp = foo * 1 ; // the *1 declares numerical variable
	updateScreen ("foo_pp", foo_pp ) ;
	tot = tot + foo_pp ; qas = qas + 1 ;
	}

var hea_pp = document.form1.hea.value ; // = 1.1 @ Feb 07
updateScreen ("hea_pp", hea_pp ) ;
tot = tot + hea_pp * 1 ; qas = qas + 1 ;

var mis = document.form1.mis.value ;
if (mis != "?") {
	var mis_pp = mis * 1 ;
	updateScreen ("mis_pp", mis_pp ) ;
	tot = tot + mis_pp ; qas = qas + 1 ;
	}

var bus = document.form1.bus.value;
if (bus != "?") {
	var bus_pp = Math.round(bus * 0.0001 * 100) / 100 ;
	updateScreen ("bus_pp", bus_pp ) ;
	tot = tot + bus_pp ; qas = qas + 1 ;
	}

var tra = document.form1.tra.value ;
if (tra != "?") {
	var tra_pp = Math.round(tra * 0.0001 * 100) / 100 ;
	updateScreen ("tra_pp", tra_pp ) ;
	tot = tot + tra_pp ; qas = qas + 1 ;
	}

var fli = document.form1.fli.value;
if (fli != "?") {
	var fli_pp = fli * 0.25 ;
	updateScreen ("fli_pp", fli_pp ) ;
	tot = tot + fli_pp ; qas = qas + 1 ;
	}

tot = Math.round( tot * 10 ) / 10 ;
//document.form1.tot_pp3.value = tot ;
//alert()

//updateScreen ("tot", "Running total" ) ; //disabled 4.3.07 as causes problems with layout in IE

var totqas = 12

if (qas < totqas) {
	ununswereds = totqas - qas
	if (check == 2) alert ("You have not completed " + ununswereds + " box(es) yet" ) ; //i.e. if from button
	}

if (qas == totqas ) {     // i.e. if all questions answered
	var max_pp = ele_pp ;
	max_pp = Math.max (max_pp, gas_pp) ;
	max_pp = Math.max (max_pp, car1_pp) ;
	max_pp = Math.max (max_pp, car2_pp) ;
	max_pp = Math.max (max_pp, car3_pp) ;
	max_pp = Math.max (max_pp, foo_pp) ;
	max_pp = Math.max (max_pp, hea_pp) ;
	max_pp = Math.max (max_pp, mis_pp) ;
	max_pp = Math.max (max_pp, bus_pp) ;
	max_pp = Math.max (max_pp, tra_pp) ;
	max_pp = Math.max (max_pp, fli_pp) ;

	var scale = 250 / max_pp //was 400, then 300 until 12.3
	updateBar ( "ele_bar", ele_pp , scale) ;	
	updateBar ( "gas_bar", gas_pp , scale) ;	
	updateBar ( "car1_bar", car1_pp , scale) ;	
	updateBar ( "car2_bar", car2_pp , scale) ;	
	updateBar ( "car3_bar", car3_pp , scale) ;	
	updateBar ( "foo_bar", foo_pp , scale) ;	
	updateBar ( "hea_bar", hea_pp , scale) ;	
	updateBar ( "mis_bar", mis_pp , scale) ;	
	updateBar ( "bus_bar", bus_pp , scale) ;	
	updateBar ( "tra_bar", tra_pp , scale) ;	
	updateBar ( "fli_bar", fli_pp , scale) ;	

	updatepc ( "ele_pc", ele_pp, tot) ;
	updatepc ( "gas_pc", gas_pp, tot) ;
	updatepc ( "car1_pc", car1_pp, tot) ;
	updatepc ( "car2_pc", car2_pp, tot) ;
	updatepc ( "car3_pc", car3_pp, tot) ;
	updatepc ( "foo_pc", foo_pp, tot) ;
	updatepc ( "hea_pc", hea_pp, tot) ;
	updatepc ( "mis_pc", mis_pp, tot) ;
	updatepc ( "bus_pc", bus_pp, tot) ;
	updatepc ( "tra_pc", tra_pp, tot) ;
	updatepc ( "fli_pc", fli_pp, tot) ;

	//updateScreen ("tot", "Your total" ) ;

	document.form1.tot_pp3.value = tot ;
	document.form1.tot_pp4.value = tot ;
	Show_total(tot) ;

	}

//var tot_co2 = gas_co2 + ele_co2 + car1_co2 + car2_co2 + car3_co2 ;
//tot_co2 = Math.round(tot_co2 * 100) / 100 ;
//var tot_pp1 = gas_pp + ele_pp + car1_pp + car2_pp + car3_pp ;
//tot_pp1 = Math.round(tot_pp1 * 100) / 100
//var tot_pp2 = tot_pp1 + fli_pp + tra_pp + bus_pp ;
//tot_pp2 = Math.round(tot_pp2 * 100) / 100
//alert (tot_pp2)
//var tot_pp3 = tot_pp2 + foo_pp * 1 + hea_pp * 1 + mis_pp * 1
//tot_pp3 = Math.round(tot_pp3 * 10) / 10
//var tot_pp4 = tot_pp3 
//document.form1.tot_pp3.value = tot_pp3 ;

//Show_total(tot_pp3)



//saving data via cookie --------------------------

d = new Date() ;
d.setFullYear(d.getFullYear() + 10) ; //i.e. in 10 years time
expires = "expires=" + d.toGMTString() ;

var st = "data=" + pers + "," + ele + "," + gas + "," + car1_con + "," + car1 + "," + car2_con + "," + car2 + "," ;
st = st + car3_con + "," + car3 + "," + foo + "," + mis + "," + bus + "," + tra + "," + fli + ",; " + expires ;
document.cookie = st


}

//---------------------------------------------------------------------------------------------
function LoadEvents_old() {

cookies = document.cookie ;
//cookies = "" ;
//alert (cookies) ;
if (cookies != "") {
	//alert ("cookies enabled") ;
	pos1 = 5 ; pos2 = cookies.indexOf(";", pos1) ;
	if (pos2 == -1) pos2 = cookies.length ;
	st = cookies.substring(pos1, pos2) ;

	pos1 = 0 ; pos2 = st.indexOf(",", pos1) ; pers = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; ele = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; gas = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; car1_con = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; car1 = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; car2_con = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; car2 = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; car3_con = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; car3 = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; foo = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; mis = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; bus = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; tra  = st.substring(pos1, pos2) ;
	pos1 = pos2 + 1 ; pos2 = st.indexOf(",", pos1) ; fli = st.substring(pos1, pos2) ;

	document.form1.pers.value = pers ; 
	document.form1.ele.value = ele ;
	document.form1.gas.value = gas ;
	document.form1.car1_con.value = car1_con ;
	document.form1.car1.value = car1 ;
	document.form1.car2_con.value = car2_con ;
	document.form1.car2.value = car2 ;
	document.form1.car3_con.value = car3_con ;
	document.form1.car3.value = car3 ;
	document.form1.foo.value = foo ;
	document.form1.mis.value = mis ;
	///document.form1.bus.value = bus ;
	///document.form1.tra.value = tra ;
	document.form1.fli.value = fli ;
	}

document.getElementById("ele_bar").style.width = 1 ;
document.getElementById("gas_bar").style.width = 1 ;
document.getElementById("car1_bar").style.width = 1 ;
document.getElementById("car2_bar").style.width = 1 ;
document.getElementById("car3_bar").style.width = 1 ;
document.getElementById("foo_bar").style.width = 1 ;
document.getElementById("hea_bar").style.width = 1 ;
document.getElementById("mis_bar").style.width = 1 ;
document.getElementById("bus_bar").style.width = 1 ;
document.getElementById("tra_bar").style.width = 1 ;
document.getElementById("fli_bar").style.width = 1 ;

Show_total(0.1)


}


//---------------------------------------------------------------------------------------------
function updateBar (id, x, scale) {

var bar = scale * x; if (bar < 1) {bar = 1; } ; document.getElementById(id).style.width = bar ;

}

