var year= new Array (2005.0,2006.0,2007.0,2008.0,2009.0,2010.0,2011.0,2012.0,2013.0,2014.0,2015.0,2016.0,2017.0,2018.0,2019.0,2020.0,2021.0,2022.0,2023.0,2024.0,2025.0,2026.0,2027.0,2028.0,2029.0,2030.0,2031.0,2032.0,2033.0,2034.0,2035.0,2036.0,2037.0,2038.0,2039.0,2040.0,2041.0,2042.0,2043.0,2044.0,2045.0,2046.0,2047.0,2048.0,2049.0,2050.0);
var rni= new Array (45);
var imm= new Array (45);
var new_pop= new Array (45);
var act_per= new Array (45);
var emp_per= new Array (45); //Aquesta variable és en realitat un input des del formulari web
var r_d= new Array (45);
var inv_gdp= new Array (45);
var int_EU= new Array (45); //Economic integration of new EU members (0-1)	
var con_EU= new Array (45); //Economic convergence of new EU members (0-1)
var ren_per= new Array (45);
var nuc_per= new Array (45);
var tran_inc= new Array (45); //% of income allocated to pax transport	;
var nstr0= new Array (45);
var nstr1= new Array (45);
var nstr2= new Array (45);
var nstr3= new Array (45);
var nstr4= new Array (45);
var nstr5= new Array (45);
var nstr6= new Array (45);
var nstr7= new Array (45);
var nstr8= new Array (45);
var nstr9= new Array (45);
var nstr10= new Array (45);
var fre_regional= new Array (45);
var fre_domestic= new Array (45);
var fre_intrazone= new Array (45);
var fre_extrazone= new Array (45);
var K_transp= new Array (45);
var inf_sd_ro= new Array (45);
var inf_ld_ro= new Array (45);
var inf_sd_ra= new Array (45);
var inf_ld_ra= new Array (45);
var inf_air= new Array (45);
//var price_barrel= new Array (45); //Price barrel /barrel
//var excises_oil= new Array (0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57,0.57); //Excises on oil price in €/l
//var price_electricity= new Array (0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12); //Price electricity €/KWh (average consumption of 0.3KWh/km)
//var tax_car= new Array (0.01,0.0104846156976744,0.0109677395348837,0.0114478796511628,0.0119235441860465,0.0123932412790698,0.0128554790697674,0.0133087656976744,0.0137516093023256,0.0141825180232558,0.0146,0.015003115503876,0.0153931333333333,0.0157718744186047,0.0161411596899225,0.0165028100775194,0.0168586465116279,0.0172104899224806,0.0175601612403101,0.0179094813953488,0.0182602713178295,0.0186143519379845,0.0189735441860465,0.0193396689922481,0.0197145472868217,0.0201,0.0204975113372093,0.0209072186046512,0.0213289223837209,0.021762423255814,0.0222075218023256,0.0226640186046512,0.0231317142441861,0.0236104093023256,0.0240999043604651,0.0246,0.0251103566860465,0.0256300744186047,0.0261581130813954,0.0266934325581395,0.0272349927325581,0.0277817534883721,0.0283326747093023,0.0288867162790698,0.0294428380813953,0.03); //Taxes road mode for cars
//var tax_truck= new Array (0.02,0.0210734557311005,0.0221471861101139,0.023221465784953,0.0242965694035307,0.0253727716137599,0.0264503470635534,0.0275295704008241,0.0286107162734849,0.0296940593294486,0.0307798742166282,0.031868399847932,0.0329587037700005,0.0340484471230881,0.0351352078110968,0.0362165637379289,0.0372900928074863,0.0383533729236714,0.0394039819903861,0.0404394979115327,0.0414574985910133,0.0424555619327299,0.0434312658405848,0.04438218821848,0.0453059069703177,0.0462,0.0470644665569923,0.047908991273013,0.0487456801253438,0.0495866390912663,0.0504439741480621,0.051329791273013,0.0522561964434006,0.0532352956365065,0.0542791948296124,0.0554,0.0566063159294946,0.0578927426180961,0.0592503788703483,0.0606703234907948,0.0621436752839793,0.0636615330544455,0.0652149956067369,0.0667951617453974,0.0683931302749706,0.07); //Taxes road mode for trucks
var cong= new Array (45); //Congestion
var freight_price= new Array (45); //Average value of freight in €/Tn
var pax_sd_per= new Array (45); //%Short distance including extraEU
var pax_sd_ra_var= new Array (45);
var pax_ld_ra_var= new Array (45);
var pax_air_var= new Array (45);
var pax_air_noEU_share= new Array (45);  //Air ExtraEU share over long distance traffic
var pax_ro_sd_occ= new Array (45); //Car occupancy in urban environment
var pax_ro_ld_occ= new Array (45); //Car occupancy in suburban environment
var fre_dist_EU= new Array (45);
var fre_dist_noEU= new Array (45);
var fre_ld_ra_var= new Array (45);
var fre_IWW_var= new Array (45);
var fre_sea_var= new Array (45);
var fre_ro_ld_percent= new Array (45);  //Road Long distance share
var fre_ro_occ= new Array (45); //Freight optimisation
//var clean_car_share= new Array (0.0,0.00126266046511628,0.00253849302325581,0.00384066976744186,0.00518236279069767,0.00657674418604651,0.00803698604651163,0.00957626046511628,0.0112077395348837,0.0129445953488372,0.0148,0.0167883658914729,0.0189290666666667,0.0212427162790698,0.0237499286821705,0.0264713178294574,0.0294274976744186,0.0326390821705426,0.0361266852713178,0.0399109209302326,0.0440124031007752,0.0484517457364341,0.0532495627906977,0.0584264682170543,0.0640030759689923,0.07,0.0764252325581395,0.0832362790697675,0.090378023255814,0.0977953488372093,0.105433139534884,0.113236279069767,0.121149651162791,0.129118139534884,0.137086627906977,0.145,0.152814162790698,0.16052911627907,0.16815588372093,0.175705488372093,0.183188953488372,0.190617302325581,0.198001558139535,0.205352744186047,0.21268188372093,0.22); //% non fossil road cars
//var red_fos_car= new Array (0.0,0.00555666279069768,0.0111765581395349,0.0169229186046512,0.022858976744186,0.0290479651162791,0.0355531162790698,0.0424376627906977,0.0497648372093023,0.0575978720930233,0.066,0.0750127286821706,0.0845906666666667,0.0946666976744186,0.105173705426357,0.116044573643411,0.127212186046512,0.138609426356589,0.150169178294574,0.161824325581395,0.173507751937984,0.185152341085271,0.196690976744186,0.208056542635659,0.21918192248062,0.23,0.240459145348837,0.250569674418605,0.260357389534884,0.269848093023256,0.279067587209302,0.288041674418605,0.296796156976744,0.305356837209302,0.31374951744186,0.322,0.330131726744186,0.338158697674419,0.346092552325581,0.353944930232558,0.361727470930233,0.369451813953488,0.377129598837209,0.384772465116279,0.392392052325581,0.4); //%reduction of emission fossil road cars
//var red_truck= new Array (0.0,0.00284494767441861,0.00572353488372093,0.0086694011627907,0.0117161860465116,0.0148975290697674,0.0182470697674419,0.0217984476744186,0.0255853023255814,0.029641273255814,0.034,0.0386851705426357,0.0436806666666667,0.0489604186046512,0.0544983565891473,0.0602684108527132,0.066244511627907,0.0724005891472868,0.0787105736434109,0.0851483953488372,0.091687984496124,0.0983032713178295,0.104968186046512,0.111656658914729,0.118342620155039,0.125,0.131607462209302,0.138162604651163,0.14466775872093,0.151125255813954,0.157537427325581,0.163906604651163,0.170235119186047,0.176525302325581,0.182779485465116,0.189,0.195189311046512,0.201350418604651,0.207486456395349,0.213600558139535,0.21969585755814,0.225775488372093,0.231842584302326,0.237900279069767,0.243951706395349,0.25); //Truck
//var red_ra= new Array (0.0,0.00576277906976744,0.0115278139534884,0.0172973604651163,0.0230736744186047,0.028859011627907,0.0346556279069767,0.0404657790697674,0.0462917209302326,0.0521357093023256,0.058,0.0638868682170543,0.0697986666666667,0.0757377674418605,0.0817065426356589,0.0877073643410853,0.0937426046511628,0.0998146356589147,0.105925829457364,0.112078558139535,0.11827519379845,0.124518108527132,0.130809674418605,0.137152263565891,0.143548248062015,0.15,0.156507784883721,0.163063441860465,0.169656703488372,0.176277302325581,0.182914970930233,0.189559441860465,0.196200447674419,0.202827720930233,0.209430994186046,0.216,0.222526924418605,0.22901376744186,0.23546498255814,0.241885023255814,0.248278343023256,0.254649395348837,0.26100263372093,0.267342511627907,0.27367348255814,0.28);
//var red_sea= new Array (0.0,0.00679355813953489,0.0135996279069767,0.0204307209302326,0.0272993488372093,0.034218023255814,0.0411992558139535,0.0482555581395349,0.0553994418604651,0.0626434186046512,0.07,0.0774750697674419,0.085048,0.0926915348837209,0.100378418604651,0.108081395348837,0.115773209302326,0.123426604651163,0.131014325581395,0.13850911627907,0.145883720930233,0.15311088372093,0.160163348837209,0.167013860465116,0.173635162790698,0.18,0.186088569767442,0.19191088372093,0.197484406976744,0.202826604651163,0.207954941860465,0.21288688372093,0.217639895348837,0.222231441860465,0.226678988372093,0.231,0.235210848837209,0.239323534883721,0.243348965116279,0.247298046511628,0.251181686046512,0.255010790697674,0.258796267441861,0.262549023255814,0.266279965116279,0.27);
//var red_air= new Array (0.0,0.00418851162790698,0.00843832558139535,0.0128107441860465,0.0173670697674419,0.0221686046511628,0.0272766511627907,0.032752511627907,0.038657488372093,0.0450528837209302,0.052,0.0595411472868217,0.0676426666666667,0.0762519069767442,0.0853162170542636,0.0947829457364341,0.104599441860465,0.114713054263566,0.125071131782946,0.135621023255814,0.14631007751938,0.157085643410853,0.167895069767442,0.178685705426357,0.189404899224806,0.2,0.210420813953488,0.220626976744186,0.230580581395349,0.240243720930233,0.249578488372093,0.258546976744186,0.267111279069767,0.275233488372093,0.282875697674419,0.29,0.296584069767442,0.302667906976744,0.308307093023256,0.313557209302326,0.318473837209302,0.323112558139535,0.327528953488372,0.331778604651163,0.335917093023256,0.34); //Airplane

var alfa_gdp,A_gdp;

var clean_car_share=new Array(45);
var red_fos_car=new Array(45);
var red_truck=new Array(45);
var red_ra=new Array(45);
var red_sea=new Array(45);
var red_air=new Array(45);
var tax_truck=new Array(45);
var tax_car=new Array(45);
var price_electricity=new Array(45);
var excises_oil=new Array(45);
var price_barrel=new Array(45);

var tot_pop=new Array(45);
var new_pop_traf=new Array(45);
var emp=new Array(45);
var K_tot=new Array(45);
var work_r_d=new Array(45);
var y_work=new Array(45);
var GDP=new Array(45);
var GDP_cap=new Array(45);
var inf_port=new Array(45);
var fos_per=new Array(45);
var CO2_kwh=new Array(45);
var fos_en=new Array(45);
var oil_tax=new Array(45);
var tot_oil_tax=new Array(45);
var av_inc=new Array(45);
var tran_price=new Array(45);
var pax_sd_ro=new Array(45);
var pax_ld_ro=new Array(45);
var pax_sd_ra=new Array(45);
var pax_ld_ra=new Array(45);
var pax_air=new Array(45);
var pax_noEU=new Array(45);
var pax_tot=new Array(45);
var sd_ro_price=new Array(45);
var ld_ro_price=new Array(45);
var ro_price_var=new Array(45);
var ra_price_var=new Array(45);
var pax_sd_ro_share=new Array(45);
var pax_sd_ra_share=new Array(45);
var K_pax_sd=new Array(45);
var pax_ro_cost=new Array(45);
var pax_ra_cost=new Array(45);
var pax_air_cost=new Array(45);
var pax_ro_cost_var=new Array(45);
var pax_ra_cost_var=new Array(45);
var pax_air_cost_var=new Array(45);
var pax_ld_ro_share=new Array(45);
var pax_ld_ra_share=new Array(45);
var pax_ld_air_share=new Array(45);
var K_pax_ld=new Array(45);
var price_oil=new Array(45);
var price_oil_tot=new Array(45);
var car_OC=new Array(45);
var truck_OC=new Array(45);
var pax_VOT=new Array(45);
var freight_VOT=new Array(45);
var congestion=new Array(45);
var cost_car=new Array(45);
var cost_truck=new Array(45);
var fre_extraEU=new Array(45);
var fre_sd_ro=new Array(45);
var fre_ld_ro=new Array(45);
var fre_ra=new Array(45);
var fre_IWW=new Array(45);
var fre_SSS=new Array(45);
var fre_total=new Array(45);
var fre_foreland=new Array(45);
var fre_all=new Array(45);
var fre_price_ro_sd=new Array(45);
var fre_price_ro_ld=new Array(45);
var fre_price_ro_ave=new Array(45);
var fre_price_ra=new Array(45);
var fre_price_IWW=new Array(45);
var fre_price_sea=new Array(45);
var fre_ro_sd_cost_var=new Array(45);
var fre_ro_ld_cost_var=new Array(45);
var fre_ra_cost_var=new Array(45);
var fre_IWW_cost_var=new Array(45);
var fre_sea_cost_var=new Array(45);
var fre_ro_ld_share=new Array(45);
var fre_ra_share=new Array(45);
var fre_IWW_share=new Array(45);
var fre_sea_share=new Array(45);
var fre_K=new Array(45);
var red_car=new Array(45);
var rco2_truck_ld=new Array(45);
var rco2_truck_sd=new Array(45);
var rco2_fre_ra=new Array(45);
var rco2_fre_air=new Array(45);
var rco2_fre_sea=new Array(45);
var rco2_pax_ro=new Array(45);
var rco2_pax_ro_ld=new Array(45);
var rco2_pax_ro_sd=new Array(45);
var rco2_pax_ro_bus=new Array(45);
var rco2_pax_ra=new Array(45);
var rco2_pax_air=new Array(45);
var rco2_clean_car=new Array(45);
//var rco2_clean_truck=new Array(45);
var co2_pax_ro=new Array(45);
var co2_pax_ro_ld=new Array(45);
var co2_pax_ro_sd=new Array(45);
var co2_truck=new Array(45);
var co2_truck_ld=new Array(45);
var co2_truck_sd=new Array(45);
var co2_air=new Array(45);
var co2_pax_air=new Array(45);
var co2_pax_fre=new Array(45);
var co2_sea=new Array(45);
var co2_IWW=new Array(45);
var co2_dir=new Array(45);
var co2_var=new Array(45);
var co2_ro_clean=new Array(45);
var co2_ra=new Array(45);
var co2_pax_ra=new Array(45);
var co2_fre_ra=new Array(45);
var co2_clean=new Array(45);
var co2_sea_foreland=new Array(45);
var co2_air_foreland=new Array(45);
var time=new Array(45);



function MIN(a,b,c,d){
v=Math.min(a,b);
if(d)w=Math.min(c,d);else w=c;
return Math.min(v,w);
}

function executar(){
i=document.getElementById("year").value-2005;



document.getElementById("Pop_tot").value="";
document.getElementById("PIB").value="";
document.getElementById("PIB_CAP").value="";
document.getElementById("Pax_tot").value="";
document.getElementById("Fre_tot").value="";
document.getElementById("ro_pax").value="";
document.getElementById("ro_fre").value="";
document.getElementById("sd_pax").value="";
document.getElementById("sd_fre").value="";
document.getElementById("CO2_pax").value="";
document.getElementById("CO2_fre").value="";
document.getElementById("en_price").value="";
document.getElementById("CO2_dir").value="";
document.getElementById("CO2_ind").value="";
document.getElementById("CO2_tot").value="";
document.getElementById("CO2_ext_pax").value="";
document.getElementById("CO2_ext_fre").value="";





rni[i]=document.getElementById("rni").value/1.0;
imm[i]=document.getElementById("imm").value/1.0;
new_pop[i]=document.getElementById("new_pop").value/1.0;
act_per[i]=document.getElementById("act_per").value/1.0;
emp_per[i]=document.getElementById("emp_per").value/1.0;
r_d[i]=document.getElementById("r_d").value/1.0;
inv_gdp[i]=document.getElementById("inv_gdp").value/1.0;
// K_transp[i]=document.getElementById("K_transp").value/1.0;
// inf_sd_ro[i]=document.getElementById("inf_sd_ro").value/1.0;
// inf_ld_ro[i]=document.getElementById("inf_ld_ro").value/1.0;
// inf_sd_ra[i]=document.getElementById("inf_sd_ra").value/1.0;
// inf_ld_ra[i]=document.getElementById("inf_ld_ra").value/1.0;
// inf_air[i]=document.getElementById("inf_air").value/1.0;
ren_per[i]=document.getElementById("ren_per").value/1.0;
nuc_per[i]=document.getElementById("nuc_per").value/1.0;
red_ra[i]=document.getElementById("red_ra").value/1.0;  //?? Està inicialitzada pels 45 anys i s'ha de llegir
red_sea[i]=document.getElementById("red_sea").value/1.0;  //?? Està inicialitzada pels 45 anys i s'ha de llegir
int_EU[i]=document.getElementById("int_EU").value/1.0;
con_EU[i]=document.getElementById("con_EU").value/1.0;
pax_ro_sd_occ[i]=document.getElementById("pax_ro_sd_occ").value/1.0; 
pax_ro_ld_occ[i]=document.getElementById("pax_ro_ld_occ").value/1.0; 
fre_ro_occ[i]=document.getElementById("fre_ro_occ").value/1.0;
clean_car_share[i]=document.getElementById("clean_car_share").value/1.0; //?? Està inicialitzada pels 45 anys i s'ha de llegir 
red_fos_car[i]=document.getElementById("red_fos_car").value/1.0; //?? Està inicialitzada pels 45 anys i s'ha de llegir
price_barrel[i]=document.getElementById("price_barrel").value/1.0; //?? Està inicialitzada pels 45 anys i s'ha de llegir
excises_oil[i]=document.getElementById("excises_oil").value/1.0;  //?? Està inicialitzada pels 45 anys i s'ha de llegir
tran_inc[i]=document.getElementById("tran_inc").value/1.0; 
red_truck[i]=document.getElementById("red_truck").value/1.0;  //?? Està inicialitzada pels 45 anys i s'ha de llegir
red_air[i]=document.getElementById("red_air").value/1.0; //?? Està inicialitzada pels 45 anys i s'ha de llegir

price_electricity[i]=Number(document.getElementById("price_electricity").value)/1.0; //?? Està inicialitzada pels 45 anys i s'ha de llegir
tax_car[i]=Number(document.getElementById("tax_car").value)/1.0;  //?? Està inicialitzada pels 45 anys i s'ha de llegir
tax_truck[i]=Number(document.getElementById("tax_truck").value)/1.0;  //?? Està inicialitzada pels 45 anys i s'ha de llegir
freight_price[i]=document.getElementById("freight_price").value/1.0;
cong[i]=document.getElementById("cong").value/1.0;
pax_sd_per[i]=document.getElementById("pax_sd_per").value/1.0;
pax_sd_ra_var[i]=document.getElementById("pax_sd_ra_var").value/1.0;
pax_air_noEU_share[i]=document.getElementById("pax_air_noEU_share").value/1.0;
pax_ld_ra_var[i]=document.getElementById("pax_ld_ra_var").value/1.0;
pax_air_var[i]=document.getElementById("pax_air_var").value/1.0;
fre_ro_ld_percent[i]=document.getElementById("fre_ro_ld_percent").value/1.0;
fre_ld_ra_var[i]=document.getElementById("fre_ld_ra_var").value/1.0;
fre_IWW_var[i]=document.getElementById("fre_IWW_var").value/1.0;
fre_sea_var[i]=document.getElementById("fre_sea_var").value/1.0;
nstr0[i]=document.getElementById("nstr0").value/1.0; //NSTR 0 Agricultural products
nstr1[i]=document.getElementById("nstr1").value/1.0; //NSTR 1 Foodstuffs
nstr2[i]=document.getElementById("nstr2").value/1.0; //NSTR 2 Solid mineral fuels
nstr3[i]=document.getElementById("nstr3").value/1.0; //NSTR 3 Oil derivates
nstr4[i]=document.getElementById("nstr4").value/1.0; //NSTR 4 Ores, metal waste
nstr5[i]=document.getElementById("nstr5").value/1.0; //NSTR 5 Metal products
nstr6[i]=document.getElementById("nstr6").value/1.0; //NSTR 6 Building minerals & material
nstr7[i]=document.getElementById("nstr7").value/1.0; //NSTR 7 Fertilisers
nstr8[i]=document.getElementById("nstr8").value/1.0; //NSTR 8 Chemicals
nstr9[i]=document.getElementById("nstr9").value/1.0; //NSTR 9 Machinery & other manufacturing
nstr10[i]=document.getElementById("nstr10").value/1.0; //NSTR 10 crude oil
// fre_regional[i]=document.getElementById("fre_regional").value/1.0; //Regional
// fre_domestic[i]=document.getElementById("fre_domestic").value/1.0; //Domestic (intraNUTS0 within EU27)
// fre_intrazone[i]=document.getElementById("fre_intrazone").value/1.0; //intraZone
// fre_extrazone[i]=document.getElementById("fre_extrazone").value/1.0; //extraZone
fre_dist_EU[i]=document.getElementById("fre_dist_EU").value/1.0; //Average distance inside EU27 territory for all commodities (calculated from COMEXT database)
fre_dist_noEU[i]=document.getElementById("fre_dist_noEU").value/1.0; //Average distance outside EU27 territory for all commodities (calculated from COMEXT database)

tot_pop[i]=491999371*Math.pow(rni[i],(year[i]-2005))+(year[i]-2005)*imm[i];
emp[i]=tot_pop[i]*act_per[i]*emp_per[i];
alfa_gdp=0.894;
A_gdp=4.26502177125395;
K_tot[i]=35176933.5126663*Math.pow((1+inv_gdp[i]),(year[i]-2005));
work_r_d[i]=emp[i]*(1+r_d[i]);
GDP[i]=Math.pow(K_tot[i],alfa_gdp)*Math.pow(work_r_d[i],(1-alfa_gdp))/A_gdp;
y_work[i]=GDP[i]*1000000/work_r_d[i];
GDP_cap[i]=GDP[i]/tot_pop[i]*1000000;
inf_port[i]=1-(inf_sd_ro[i]+inf_ld_ro[i]+inf_sd_ra[i]+inf_ld_ra[i]+inf_air[i]);
fos_per[i]=1-ren_per[i]-nuc_per[i];
CO2_kwh[i]=400*(1-ren_per[i]+0.25)*(1-nuc_per[i]+0.4);
fos_en[i]=311.633504150842*(co2_dir[i]/874.418140754396); //Energy consumed from fossil sources by transport year in MToe
oil_tax[i]=price_oil[i]; //Average taxes in €/litre
tot_oil_tax[i]=oil_tax[i]*fos_en[i]*1000/1.2; //Taxes on oil by transport in M€
new_pop_traf[i]=((new_pop[i]+tot_pop[i])/tot_pop[i]-1)*int_EU[i]*con_EU[i]+1;

rco2_clean_car[i]=0.006*CO2_kwh[i]/400; //Emission non-carbon cars
rco2_pax_ro[i]=0.230437457083507*(1-red_fos_car[i])*(1-clean_car_share[i])+rco2_clean_car[i]*clean_car_share[i]; //Emission  cars
rco2_pax_ro_ld[i]=rco2_pax_ro[i]/pax_ro_ld_occ[i]; //Emission  cars long-dist
rco2_pax_ro_sd[i]=rco2_pax_ro[i]/pax_ro_sd_occ[i]; //Emission  cars urban
red_car[i]=(0.230437457083507-rco2_pax_ro[i])/0.230437457083507; //Car
rco2_truck_ld[i]=0.138*(1-red_truck[i])*14.5/fre_ro_occ[i]; //Emission  HGV trucks
rco2_truck_sd[i]=0.284089602056834*(1-red_truck[i])*14.5/fre_ro_occ[i]; //Emission  Vans
rco2_fre_ra[i]=0.0334*(1-red_ra[i]); //Emission  freight rail
rco2_fre_air[i]=1.642*(1-red_air[i]); //Emission  freight planes
rco2_fre_sea[i]=0.03*(1-red_sea[i]); //Emission  ships
rco2_pax_ro_bus[i]=0.023*(1-red_car[i]); //Emission  BUS
rco2_pax_ra[i]=0.022*(1-red_ra[i]); //Emission  pax rail
rco2_pax_air[i]=0.13*(1-red_air[i]); //Emission  planes

av_inc[i]=0.7; //Available income (over GDP/capita)
price_oil[i]=price_barrel[i]/260.507; //Price oil €/l
price_oil_tot[i]=(price_oil[i]+excises_oil[i])*1.19; //Total price oil €/l including excises and VAT
car_OC[i]=0.09; //Operative cost cars

truck_OC[i]=0.13; //Operative cost trucks
pax_VOT[i]=7*(1+(GDP_cap[i]-20309.7047658624)/20309.7047658624); //Time value passenger
freight_VOT[i]=0.05*freight_price[i]/365/24*14/50; //Time value freight (5% yearly discount of price, 14Tn truck)
congestion[i]=Math.pow((cong[i]+1),(year[i]-2005))-1; //Increase on time (congestion)
time[i]=0.00833333333333333*(1+congestion[i]); //Time spent
cost_car[i]=time[i]*pax_VOT[i]+(0.3*price_electricity[i]*clean_car_share[i]+0.1*(1-clean_car_share[i])*price_oil_tot[i]*(1-red_car[i]))+tax_car[i]+car_OC[i]; //Cost of 1km by car
cost_truck[i]=freight_VOT[i]*(1+congestion[i])+((price_oil_tot[i])*0.3*(1-red_truck[i]))+tax_truck[i]+truck_OC[i]; //Cost of 1km by truck
ro_price_var[i]=(cost_car[i]-0.253571426014144)/0.253571426014144; //Road price change (on the whole period)
ra_price_var[i]=Math.pow((pax_sd_ra_var[i]+1),(year[i]-2005))-1; //Rail price change (on the whole period)
K_pax_sd[i]=5; //K factor of modal share logit
sd_ro_price[i]=0.214900606405954*(1+ro_price_var[i]); //Road price for short distance
ld_ro_price[i]=0.332402405013027*(1+ra_price_var[i]); //Rail price for short distance
pax_sd_ro_share[i]=Math.exp(-K_pax_sd[i]*((1+ro_price_var[i])*0.214900606405954/Math.min((1+ro_price_var[i])*0.214900606405954,(1+ra_price_var[i])*0.332402405013027)))/(Math.exp(-K_pax_sd[i]*((1+ro_price_var[i])*0.214900606405954/Math.min((1+ro_price_var[i])*0.214900606405954,(1+ra_price_var[i])*0.332402405013027)))+Math.exp(-K_pax_sd[i]*((1+ra_price_var[i])*0.332402405013027/Math.min((1+ro_price_var[i])*0.214900606405954,(1+ra_price_var[i])*0.332402405013027)))); //Road share	
pax_sd_ra_share[i]=Math.exp(-K_pax_sd[i]*((1+ra_price_var[i])*0.332402405013027/Math.min((1+ro_price_var[i])*0.214900606405954,(1+ra_price_var[i])*0.332402405013027)))/(Math.exp(-K_pax_sd[i]*((1+ro_price_var[i])*0.214900606405954/Math.min((1+ro_price_var[i])*0.214900606405954,(1+ra_price_var[i])*0.332402405013027)))+Math.exp(-K_pax_sd[i]*((1+ra_price_var[i])*0.332402405013027/Math.min((1+ro_price_var[i])*0.214900606405954,(1+ra_price_var[i])*0.332402405013027)))); //Rail share
K_pax_ld[i]=5; //K factor of modal share logit
pax_ro_cost_var[i]=(cost_car[i]-0.253571426014144)/0.253571426014144; //Road generalised cost change (on the whole period)
pax_ra_cost_var[i]=Math.pow((pax_ld_ra_var[i]+1),(year[i]-2005))-1; //Rail generalised cost change (on the whole period)
pax_air_cost_var[i]=Math.pow((pax_air_var[i]+1),(year[i]-2005))-1; //Air generalised cost change (on the whole period)
pax_ro_cost[i]=0.214900606405954*(1+pax_ro_cost_var[i]); //Road generalised cost
pax_ra_cost[i]=0.310325836562307*(1+pax_ra_cost_var[i]); //Rail generalised cost
pax_air_cost[i]=0.287720472491819*(1+pax_air_cost_var[i]); //Air generalised cost
pax_ld_ro_share[i]=Math.exp(-K_pax_ld[i]*((1+pax_ro_cost_var[i])*0.214900606405954/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))/(Math.exp(-K_pax_ld[i]*((1+pax_ro_cost_var[i])*0.214900606405954/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))+Math.exp(-K_pax_ld[i]*((1+pax_ra_cost_var[i])*0.310325836562307/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))+Math.exp(-K_pax_ld[i]*((1+pax_air_cost_var[i])*0.287720472491819/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))); //Road share long distance including extraEU
pax_ld_ra_share[i]=Math.exp(-K_pax_ld[i]*((1+pax_ra_cost_var[i])*0.310325836562307/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))/(Math.exp(-K_pax_ld[i]*((1+pax_ro_cost_var[i])*0.214900606405954/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))+Math.exp(-K_pax_ld[i]*((1+pax_ra_cost_var[i])*0.310325836562307/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))+Math.exp(-K_pax_ld[i]*((1+pax_air_cost_var[i])*0.287720472491819/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))); //Rail share long distance including extraEU
pax_ld_air_share[i]=Math.exp(-K_pax_ld[i]*((1+pax_air_cost_var[i])*0.287720472491819/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))/(Math.exp(-K_pax_ld[i]*((1+pax_ro_cost_var[i])*0.214900606405954/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))+Math.exp(-K_pax_ld[i]*((1+pax_ra_cost_var[i])*0.310325836562307/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))+Math.exp(-K_pax_ld[i]*((1+pax_air_cost_var[i])*0.287720472491819/MIN((1+pax_ro_cost_var[i])*0.214900606405954,(1+pax_ra_cost_var[i])*0.310325836562307,(1+pax_air_cost_var[i])*0.287720472491819)))); //Air share long distance including extraEU
tran_price[i]=(1+ro_price_var[i])*0.214900606405954*pax_sd_ro_share[i]*pax_sd_per[i]*(1-pax_sd_per[i])+(1+ra_price_var[i])*0.332402405013027*pax_sd_ro_share[i]*pax_sd_per[i]+(1+pax_ro_cost_var[i])*0.214900606405954*pax_ld_ro_share[i]*(1-pax_sd_per[i])+(1+pax_ra_cost_var[i])*0.310325836562307*pax_ld_ra_share[i]*(1-pax_sd_per[i])+(1+pax_air_cost_var[i])*0.287720472491819*pax_ld_air_share[i]*(1-pax_sd_per[i]); //Average transport price in €/km
pax_tot[i]=GDP_cap[i]*0.15*tot_pop[i]/tran_price[i]/1000000000*av_inc[i]; //All pax	
pax_sd_ro[i]=pax_tot[i]*pax_sd_ro_share[i]*pax_sd_per[i]; //Short Road
pax_ld_ro[i]=pax_tot[i]*pax_ld_ro_share[i]*(1-pax_sd_per[i])*(1-pax_air_noEU_share[i]); //Long Road
pax_sd_ra[i]=pax_tot[i]*pax_sd_ra_share[i]*pax_sd_per[i]; //Short Rail
pax_ld_ra[i]=pax_tot[i]*pax_ld_ra_share[i]*(1-pax_sd_per[i])*(1-pax_air_noEU_share[i]); //Long Rail
pax_air[i]=pax_tot[i]*pax_ld_air_share[i]*(1-pax_sd_per[i])*(1-pax_air_noEU_share[i]); //Air EU27
pax_noEU[i]=pax_tot[i]*(1-pax_sd_per[i])*pax_air_noEU_share[i]; //Air ExtraEU
fre_K=1.06702314558375; //K logit
fre_ro_sd_cost_var[i]=(cost_truck[i]-0.438541446992204)/0.438541446992204; //Road short price change (on the whole period)
fre_ro_ld_cost_var[i]=(cost_truck[i]-0.438541446992204)/0.438541446992204; //Road long price change (on the whole period)
fre_ra_cost_var[i]=Math.pow((fre_ld_ra_var[i]+1),(year[i]-2005))-1; //Rail price change (on the whole period)
fre_IWW_cost_var[i]=Math.pow((fre_IWW_var[i]+1),(year[i]-2005))-1; //IWW price change (on the whole period)
fre_sea_cost_var[i]=Math.pow((fre_sea_var[i]+1),(year[i]-2005))-1; //Sea price change (on the whole period)
fre_price_ro_sd[i]=1.5*(1+fre_ro_sd_cost_var[i]); //Road short price
fre_price_ro_ld[i]=1*(1+fre_ro_ld_cost_var[i]); //Road long price
fre_price_ro_ave[i]=fre_price_ro_ld[i]*fre_ro_ld_percent[i]+fre_price_ro_sd[i]*(1-fre_ro_ld_percent[i]); //Road average price
fre_price_ra[i]=2.34084918776497*(1+fre_ra_cost_var[i]); //Rail price
fre_price_IWW[i]=3.79044486124727*(1+fre_IWW_cost_var[i]); //IWW price
fre_price_sea[i]=1.19995115737875*(1+fre_sea_cost_var[i]); //Sea price

fre_ro_ld_share[i]=+Math.exp(-fre_K*fre_price_ro_ave[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))/(Math.exp(-fre_K*fre_price_ro_ave[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_ra[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_IWW[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_sea[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))); //Road share
fre_ra_share[i]=+Math.exp(-fre_K*fre_price_ra[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))/(Math.exp(-fre_K*fre_price_ro_ave[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_ra[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_IWW[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_sea[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))); //Rail share
fre_IWW_share[i]=+Math.exp(-fre_K*fre_price_IWW[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))/(Math.exp(-fre_K*fre_price_ro_ave[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_ra[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_IWW[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_sea[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))); //IWW share
fre_sea_share[i]=+Math.exp(-fre_K*fre_price_sea[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))/(Math.exp(-fre_K*fre_price_ro_ave[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_ra[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_IWW[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))+Math.exp(-fre_K*fre_price_sea[i]/MIN(fre_price_ro_ave[i],fre_price_ra[i],fre_price_IWW[i],fre_price_sea[i]))); //Sea share

//fre_extraEU[i]=((208.30335998868*(1+nstr0[i])^(year[i]-2005)+247.264027159336*(1+nstr1[i])^(year[i]-2005)+232.530910970627*(1+nstr2[i])^(year[i]-2005)+826.051606447457*(1+nstr3[i])^(year[i]-2005)+114.048230200627*(1+nstr4[i])^(year[i]-2005)+141.170017186948*(1+nstr5[i])^(year[i]-2005)+993.128870407816*(1+nstr6[i])^(year[i]-2005)+39.4211565410233*(1+nstr7[i])^(year[i]-2005)+129.877399492219*(1+nstr8[i])^(year[i]-2005)+388.373851797601*(1+nstr9[i])^(year[i]-2005)+561.830569807665*(1+nstr10[i])^(year[i]-2005)-(F99*(1+C99)^(year[i]-2005)+F100*(1+C100)^(year[i]-2005)+F101*(1+C101)^(year[i]-2005)+F102*(1+C102)^(year[i]-2005)))/F103)^(1/(year[i]-2005))-1; //extraEU neighbouring countries

fre_total[i]=(208.30335998868*Math.pow((1+nstr0[i]),(year[i]-2005))+247.264027159336*Math.pow((1+nstr1[i]),(year[i]-2005))+232.530910970627*Math.pow((1+nstr2[i]),(year[i]-2005))+826.051606447457*Math.pow((1+nstr3[i]),(year[i]-2005))+114.048230200627*Math.pow((1+nstr4[i]),(year[i]-2005))+141.170017186948*Math.pow((1+nstr5[i]),(year[i]-2005))+993.128870407816*Math.pow((1+nstr6[i]),(year[i]-2005))+39.4211565410233*Math.pow((1+nstr7[i]),(year[i]-2005))+129.877399492219*Math.pow((1+nstr8[i]),(year[i]-2005))+388.373851797601*Math.pow((1+nstr9[i]),(year[i]-2005))+561.830569807665*Math.pow((1+nstr10[i]),(year[i]-2005)))*new_pop_traf[i]; //All intraEU27 and TNC

fre_sd_ro[i]=fre_total[i]*fre_ro_ld_share[i]*(1-fre_ro_ld_percent[i]); //Short road
fre_ld_ro[i]=fre_total[i]*fre_ro_ld_share[i]*fre_ro_ld_percent[i]; //Long road
fre_ra[i]=fre_total[i]*fre_ra_share[i]; //Rail
fre_IWW[i]=fre_total[i]*fre_IWW_share[i]; //IWW
fre_SSS[i]=fre_total[i]*fre_sea_share[i]; //Sea SSS
fre_foreland[i]=fre_total[i]*fre_dist_noEU[i]/fre_dist_EU[i]; //Sea foreland
fre_all[i]=fre_foreland[i]+fre_total[i]; //All fre

//rco2_clean_truck[i]=0.012*CO2_kwh[i]/400; //Emission non-carbon trucks
co2_pax_ro_ld[i]=rco2_pax_ro_ld[i]*pax_ld_ro[i]*(1-clean_car_share[i]); //Emissions cars long-dist
co2_pax_ro_sd[i]=rco2_pax_ro_sd[i]*pax_sd_ro[i]*(1-clean_car_share[i]); //Emissions cars urban
co2_pax_ro[i]=co2_pax_ro_ld[i]+co2_pax_ro_sd[i]; //Emissions cars TOTAL
co2_truck_ld[i]=rco2_truck_ld[i]*fre_ld_ro[i]; //Emissions trucks longdist
co2_truck_sd[i]=rco2_truck_sd[i]*fre_sd_ro[i]; //Emissions trucks urban
co2_truck[i]=co2_truck_ld[i]+co2_truck_sd[i]; //Emissions trucks TOTAL
co2_pax_air[i]=rco2_pax_air[i]*pax_air[i]; //Emissions planes pax
co2_pax_fre[i]=0; //Emissions planes freight
co2_air[i]=co2_pax_air[i]+co2_pax_fre[i]; //Emissions planes TOTAL
co2_sea[i]=rco2_fre_sea[i]*fre_SSS[i]; //Emissions ships TOTAL
co2_IWW[i]=rco2_fre_sea[i]*fre_IWW[i]; //Emissions IWW TOTAL
co2_dir[i]=co2_pax_ro[i]+co2_truck[i]+co2_air[i]+co2_sea[i]+co2_IWW[i]; //Total direct greenhouse emissions calculated
co2_ro_clean[i]=clean_car_share[i]*(pax_sd_ro[i]+pax_ld_ro[i])*rco2_clean_car[i]; //Road electric
co2_pax_ra[i]=rco2_pax_ra[i]*(pax_ld_ra[i]+pax_sd_ra[i]); //Emissions rail pax
co2_fre_ra[i]=rco2_fre_ra[i]*fre_ra[i]; //Emissions rail freight
co2_ra[i]=co2_pax_ra[i]+co2_fre_ra[i]; //Emissions rail TOTAL
co2_clean[i]=co2_ra[i]+co2_ro_clean[i]; //Indirect CO2
co2_var[i]=(co2_dir[i]+co2_clean[i]-1042.34)/1042.34; //Increase of Total CO2 in relation to 2005 levels
co2_sea_foreland[i]=fre_foreland[i]*rco2_fre_sea[i]; //Sea foreland emissions
co2_air_foreland[i]=pax_noEU[i]*rco2_pax_air[i]; //Air foreland emissions

//Resultats

if (co2_var[i]*100<-50.00)document.getElementById("percR").innerHTML="<span class='resB'>Variació emissions de CO<sub>2</sub></span> <span class='resKO'>"+(co2_var[i]*100).numberFormat("#,##0.00")+"%</span>";
else document.getElementById("percR").innerHTML="<span class='resB'>Variació emissions de CO<sub>2</sub></span> <span class='resOK'>"+(co2_var[i]*100).numberFormat("#,##0.00")+"%</span>";

if (tot_pop[i]<495025061)document.getElementById("imgPob").src="./imatges/ko.gif";
if (tot_pop[i]==495025061)document.getElementById("imgPob").src="./imatges/igual.gif";
if (tot_pop[i]>495025061)document.getElementById("imgPob").src="./imatges/ok.gif";

if (GDP_cap[i]<47244)document.getElementById("imgEco").src="./imatges/ko.gif";
if (GDP_cap[i]==47244)document.getElementById("imgEco").src="./imatges/igual.gif";
if (GDP_cap[i]>47244)document.getElementById("imgEco").src="./imatges/ok.gif";

var d_co2_pax,d_co2_fre;
d_co2_pax=(1000*(co2_pax_ro[i]+co2_pax_air[i]+co2_ro_clean[i]+co2_pax_ra[i])/pax_tot[i]);
d_co2_fre=(1000*(co2_truck[i]+co2_sea[i]+co2_IWW[i]+co2_fre_ra[i])/fre_total[i]);
d_co2_pax=d_co2_pax-20; 
d_co2_fre=d_co2_fre-43.95;

if (d_co2_fre+d_co2_pax<0)document.getElementById("imgTec").src="./imatges/ok.gif";
if (d_co2_fre+d_co2_pax==0)document.getElementById("imgTec").src="./imatges/igual.gif";
if (d_co2_fre+d_co2_pax>0)document.getElementById("imgTec").src="./imatges/ko.gif";

//if ((1000*(co2_pax_ro[i]+co2_pax_air[i]+co2_ro_clean[i]+co2_pax_ra[i])/pax_tot[i])+(1000*(co2_truck[i]+co2_sea[i]+co2_IWW[i]+co2_fre_ra[i])/fre_total[i])<85.16)document.getElementById("imgTec").src="./imatges/ok.gif";
//if ((1000*(co2_pax_ro[i]+co2_pax_air[i]+co2_ro_clean[i]+co2_pax_ra[i])/pax_tot[i])+(1000*(co2_truck[i]+co2_sea[i]+co2_IWW[i]+co2_fre_ra[i])/fre_total[i])==85.16)document.getElementById("imgTec").src="./imatges/igual.gif";
//if ((1000*(co2_pax_ro[i]+co2_pax_air[i]+co2_ro_clean[i]+co2_pax_ra[i])/pax_tot[i])+(1000*(co2_truck[i]+co2_sea[i]+co2_IWW[i]+co2_fre_ra[i])/fre_total[i])>85.16)document.getElementById("imgTec").src="./imatges/ko.gif";

if ((co2_dir[i]+co2_clean[i])<1042.54*0.5)document.getElementById("imgEmi").src="./imatges/vist.gif";
if ((co2_dir[i]+co2_clean[i])==1042.54*0.5)document.getElementById("imgEmi").src="./imatges/igual.gif";
if ((co2_dir[i]+co2_clean[i])>1042.54*0.5)document.getElementById("imgEmi").src="./imatges/x.gif";

soundManager.onready(function(oStatus) {
  if (oStatus.success) {
  var so = soundManager.createSound({
  id: 'aSound',
  url: 'so.mp3',
  volume: 50
  });
   so.play();
  }
});

//DHTMLSound("so.wav");
setTimeout ( "escriuRes("+i+")", 1000 );
}
function escriuRes(i){
document.getElementById("Pop_tot").value=tot_pop[i].numberFormat("###,###,##0");
document.getElementById("PIB").value=GDP[i].numberFormat("###,###,##0");
document.getElementById("PIB_CAP").value=GDP_cap[i].numberFormat("###,##0");
document.getElementById("Pax_tot").value=pax_tot[i].numberFormat("###,###,##0.00");
document.getElementById("Fre_tot").value=fre_total[i].numberFormat("###,###,##0.00");
document.getElementById("ro_pax").value=((pax_sd_ro[i]+pax_ld_ro[i])/pax_tot[i]).numberFormat("##0.00%");
document.getElementById("ro_fre").value=((fre_sd_ro[i]+fre_ld_ro[i])/fre_total[i]).numberFormat("##0.00%");
document.getElementById("sd_pax").value=((pax_sd_ro[i]+pax_sd_ra[i])/pax_tot[i]).numberFormat("##0.00%");
document.getElementById("sd_fre").value=(fre_sd_ro[i]/fre_total[i]).numberFormat("##0.00%");
document.getElementById("CO2_pax").value=(1000*(co2_pax_ro[i]+co2_pax_air[i]+co2_ro_clean[i]+co2_pax_ra[i])/pax_tot[i]).numberFormat("##0.00");
document.getElementById("CO2_fre").value=(1000*(co2_truck[i]+co2_sea[i]+co2_IWW[i]+co2_fre_ra[i])/fre_total[i]).numberFormat("##0.00");
document.getElementById("en_price").value=tran_price[i].numberFormat("##0.0000");
document.getElementById("CO2_dir").value=co2_dir[i].numberFormat("#,##0.00");
document.getElementById("CO2_ind").value=co2_clean[i].numberFormat("#,##0.00");
document.getElementById("CO2_tot").value=(co2_dir[i]+co2_clean[i]).numberFormat("#,##0.00");
document.getElementById("CO2_ext_pax").value=co2_air_foreland[i].numberFormat("#,##0.00");
document.getElementById("CO2_ext_fre").value=co2_sea_foreland[i].numberFormat("#,##0.00");

document.getElementById("pobR").innerHTML="<span class='resB'>Població (UE27)<br>"+tot_pop[i].numberFormat("###,###,##0")+"</span><br><span  class='resB2'>habitants</span>";
document.getElementById("pibR").innerHTML="<span class='resB'>Economia<br>"+GDP_cap[i].numberFormat("###,###,##0")+"</span><br><span  class='resB2'>€ per habitant</span>";
document.getElementById("tecR").innerHTML="<span class='resB'>Tecnologia<br>"+document.getElementById("CO2_pax").value+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+document.getElementById("CO2_fre").value+"</span><br><span  class='resB2'>gCO<sub>2</sub>/pax-km&nbsp;&nbsp;gCO<sub>2</sub>/tones-km</span>";
document.getElementById("emiR").innerHTML="<span class='resB'>Emissions<br>"+document.getElementById("CO2_tot").value+"</span><br><span  class='resB2'>Milions tonelades</span>";

}
