window.onload = create_bmr_html();

function create_bmr_html(){
	document.getElementById("gastronomicus_bmr").innerHTML = '<div style="width:290px; border:1px solid #8F3599; padding:5px; font-size: 12px; font-weight: normal; color: ' + gastronomicus_font_color + '; font-family: Arial, Helvetica, sans-serif; background-color: ' + gastronomicus_bg + '"><h1 style="font-size:15px; font-weight:bold; color:#8F3599;">Calculator de calorii</h1><form name="gastronomicus_bmr" method="post" action="#"><div><div style="float:left">Greutate(kg):</div><div style="float:right"><input type="text" onkeypress="javascript: calculeaza();" name="gastronomicus_greutate" id="gastronomicus_greutate" size=3 value="60"/></div><div style="clear:both; height:5px; overflow:hidden;"></div></div><div><div style="float:left">Inaltime(cm): </div><div style="float:right"><input type="text" onkeypress="javascript: calculeaza();" name="gastronomicus_inaltime" id="gastronomicus_inaltime" size=3 value="165"  /></div><div style="clear:both; height:5px; overflow:hidden;"></div></div><div><div style="float:left">Varsta(ani): </div><div style="float:right"><input type="text" onkeypress="javascript: calculeaza();" name="gastronomicus_varsta" id="gastronomicus_varsta" size=3 value="30" /></div><div style="clear:both; height:5px; overflow:hidden;"></div></div><div><h1 style="font-size:13px; font-weight:bold; color:#8F3599;">Sex:</h1><input type="radio" onclick="javascript: calculeaza();" name="gastronomicus_sex" id="gastronomicus_sex" value="b" checked>Barbat <input name="gastronomicus_sex" type="radio" onclick="javascript: calculeaza();" id="gastronomicus_sex" value="f">Femeie</div><br /><div><h1 style="font-size:13px; font-weight:bold; color:#8F3599;">Activitate:</h1><input type="radio" onclick="javascript: calculeaza();" name="gastronomicus_activitate" id="gastronomicus_activitate" value="1.2" checked>Sedentar <input type="radio" onclick="javascript: calculeaza();" name="gastronomicus_activitate" id="gastronomicus_activitate" value="1.3">Activitati usoare <input type="radio" onclick="javascript: calculeaza();" name="gastronomicus_activitate" id="gastronomicus_activitate" value="1.4">Activitati moderate <input type="radio" onclick="javascript: calculeaza();" name="gastronomicus_activitate" id="gastronomicus_activitate" value="1.5">Foarte activ</div></form><div align="center"><div id="gastronomicus_rezultat" style="height:20px; font-weight:bold; color:#FFFFFF; width:100px; background-color:#8F3599; border:1px solid #990066; margin-top:5px; line-height:20px;">1992 kcal</div><div style="float:right;"><br /><div style="clear:both; height:0px; overflow:hidden;"></div>';
}

function calculeaza(){
	bmr=0;
	calorii=0;
	sex='b';
	for(i=0; i<document.gastronomicus_bmr.elements.length; i++){
		if (document.gastronomicus_bmr.elements[i].name=="gastronomicus_sex" && document.gastronomicus_bmr.elements[i].checked){
			sex = document.gastronomicus_bmr.elements[i].value;
		}
	}

	if (sex=='b'){
		bmr = 66 + (13.7 * document.getElementById("gastronomicus_greutate").value) + (5 * document.getElementById("gastronomicus_inaltime").value) - (6.8 * document.getElementById("gastronomicus_varsta").value);
	}
	else{
		bmr = 655 + (9.6 * document.getElementById("gastronomicus_greutate").value) + (1.7 * document.getElementById("gastronomicus_inaltime").value) - (4.7 * document.getElementById("gastronomicus_varsta").value);
	}
	activitate = 0;
	for(i=0; i<document.gastronomicus_bmr.elements.length; i++){
		if (document.gastronomicus_bmr.elements[i].name=="gastronomicus_activitate" && document.gastronomicus_bmr.elements[i].checked){
			activitate = document.gastronomicus_bmr.elements[i].value;
		}
	}
	calorii = bmr * activitate * 1.10;
	document.getElementById("gastronomicus_rezultat").innerHTML = Math.round(calorii) + " kcal";
}
