$(document).ready(function() {

	$("#olie").change(function(){
		if($(this).val()!="0"){
			$(".gas").each(function(){
   				$(this).css("display","none");
   			});
		}else{
			$(".gas").each(function(){
   				$(this).attr("style","");
   			});
		}
	});
	
	$("#gas").change(function(){
		if($(this).val()!="0"){
			$(".olie").each(function(){
   				$(this).css("display","none");
   			});
		}else{
			$(".olie").each(function(){
   				$(this).attr("style","");
   			});
		}
	});
	
	$("#bereken").click(function(){
	
	
		
		var olie = $("#olie").val();
		var gas = $("#gas").val();
		
		var oppervlakte = $("#oppervlakte").val();
		var capaciteit = $("#capaciteit").val();
		
		var olieTotal;
		var gasTotal;
		var amountHours;
		var olieHoeveelheid;
		var waterHoeveelHeid; 
	
		if(olie !='0'){
		
			var olieTotal = parseInt(capaciteit) / parseInt(olie); 	
			var amountHours = parseInt(oppervlakte) / parseInt(olieTotal);
			var olieHoeveelheid = parseInt(oppervlakte) * parseInt(olie);
			var waterHoeveelHeid = parseInt(oppervlakte) * 12 / 1000; 
		
			$("#uren").val(Math.round(amountHours));
			$("#dagen").val(Math.round(amountHours / 24 * 10)/10);
			$("#olie_hoeveelheid").val(olieHoeveelheid + " ltr.");
			$("#water_hoeveelheid").val(waterHoeveelHeid + " m3");
			
		}else{
			if(gas !='0'){
			
				var gasTotal = parseInt(capaciteit) / parseInt(gas); 	
				var amountHours = parseInt(oppervlakte) / parseInt(gasTotal);
				var olieHoeveelheid = parseInt(oppervlakte) * parseInt(gas);
				var waterHoeveelHeid = parseInt(oppervlakte) * 12 / 1000; 
			
				$("#uren").val(Math.round(amountHours));
				$("#dagen").val(Math.round(amountHours / 24 * 10)/10);
				$("#gas_hoeveelheid").val(olieHoeveelheid + " m3");
				$("#water_hoeveelheid").val(waterHoeveelHeid + " m3");	
			}
		}
			
	});
	
	
	var sKwh;
	var sKcal;
	var sVom2;
	var sGasm3uur;
	var sOlieltruur; 
	var sGasm3dag;
	var sOlieltrdag;
	
	var sStoom = $("#stoomkgh").val();
	var sMainkwh = $("#kwh_main").val();
	
	$("#btnRekenStoom").click(function(){
	
		
		sKwh = 723 / 1000 * $("#stoomkgh").val();
		
		sKcal = 625 / 1000 * $("#stoomkgh").val() ;
		sVom2 = 25 / 1000 * $("#stoomkgh").val();
		sGasm3uur = 87.5 / 1000 * $("#stoomkgh").val();
		sOlieltruur = 70 / 1000 * $("#stoomkgh").val(); 
		sGasm3dag = sGasm3uur * 24;
		sOlieltrdag = sOlieltruur * 24;
	
		$("#kwh").val(Math.round(sKwh)); 	
		$("#kcal").val(Math.round(sKcal));
		$("#vom2").val(Math.round(sVom2));
		$("#gasm3uur").val(Math.round(sGasm3uur));
		$("#olieltruur").val(Math.round(sOlieltruur)); 	
		$("#gasm3dag").val(Math.round(sGasm3dag));	
		$("#olieltrdag").val(Math.round(sOlieltrdag));
	});
	
	$("#btnRekenKwh").click(function(){
	

		$("#kwh_stoomkgh").val(Math.round($("#kwh_kwh").val() / 723.38 * 1000));
		$("#kwh_kcal").val(Math.round( $("#kwh_kwh").val() / 723.38 * 625));
		$("#kwh_vom2").val(Math.round( $("#kwh_kwh").val() / 723.38 * 25));
		$("#gasm3uur").val(Math.round($("#kwh_kwh").val()/ 723.38 * 87.5 ));
		$("#olieltruur").val(Math.round($("#kwh_kwh").val()/ 723.38 * 70)); 
		$("#gasm3dag").val(Math.round($("#gasm3uur").val() * 24));	
		$("#olieltrdag").val(Math.round($("#olieltruur").val() * 24));						
	});
	
	
	$("#btnRekenKcal").click(function(){
		$("#kcal_stoomkgh").val(Math.round($("#kcal_kcal").val() / 625 * 1000));
		$("#kcal_kwh").val(Math.round($("#kcal_kcal").val() / 625 * 723.38));
		$("#kcal_vom2").val(Math.round( $("#kcal_kcal").val()/ 625 * 25 ));
		$("#gasm3uur").val(Math.round( $("#kcal_kwh").val() / 723.38 * 87.5 ));
		$("#olieltruur").val(Math.round($("#kcal_kcal").val() / 625 * 70)); 
		$("#gasm3dag").val(Math.round($("#gasm3uur").val() * 24));
		$("#olieltrdag").val(Math.round($("#olieltruur").val() * 24));					
	});
	
	
	$("#btnRekenKVo2").click(function(){
		$("#vo2_stoomkgh").val(Math.round($("#vo2_vom2").val() / 25 * 1000));
		$("#vo2_kwh").val(Math.round($("#vo2_vom2").val() / 25 * 723.38));
		$("#vo2_kcal").val(Math.round($("#vo2_vom2").val() / 25 * 625));
		$("#gasm3uur").val(Math.round( $("#vo2_kwh").val() / 723.38 * 87.5 ));
		$("#olieltruur").val(Math.round($("#vo2_vom2").val() / 25 * 70)); 
		$("#gasm3dag").val(Math.round($("#gasm3uur").val() * 24));
		$("#olieltrdag").val(Math.round($("#olieltruur").val() * 24));
	});
	
	
	
	$("#stoomTable tr").hide();
	$("#selector").change(function(){
		$("#stoomTable tr").hide();
		if ($(this).val()!=""){
			$("." + $(this).val()).each(function(){
   				$(this).show();
   			});
		}
	});
	
	$("#selector option[value=stoom]").attr("selected","selected") ;

	$(".stoom").each(function(){
		$(this).show();
	});
	

});


