var s, n, ts, tc, fck, bmin;

function calc_bloco() {
if(document.form1.ap.value == "" ||
document.form1.bp.value == "" ||
document.form1.n.value == "" ||
document.form1.ts.value == "" ||
document.form1.fck.value == "") {
alert("Erro: Todos os campos devem ser preenchidos");
return;
}

ap = eval(document.form1.ap.value);
bp = eval(document.form1.bp.value);
n = eval(document.form1.n.value);
ts = eval(document.form1.ts.value);
fck = eval(document.form1.fck.value);

if(ts < 1) {
alert("Erro: O valor da tensão admissível do solo deve ser maior ou igual a 1 Kgf/cm²");
return;
}

if(n > 50) {
alert("Erro: O valor da carga centrada no pilar está limitado a 50 tf no máximo");
return;
}

if(bp > ap) {
alert("Erro: Considere <a> (comprimento do pilar) sempre maior ou igual a <b> (largura do pilar)");
return;
}

if(fck < 15) {
alert("Erro: Por norma, o valor mínimo do fck aceitável para fundações é de 15 MPa");
return;
}

n = n*1000;

s = (1.10 * n) / ts;


bb = ((bp - ap) + Math.sqrt(((ap - bp) * (ap - bp)) + 4 * s)) / 2;


ab = s / bb;

if (ab < 0.60) {
ab = 0.60;
bb = 0.60 + (bp - ap);
}

tc = 0.084 * Math.pow(fck, 2/3);

bmin = (15.339*(Math.log((ts/10)/tc))+65.876)*(3.14159/180);


if ((bmin * 180 / 3.14159) < 45) {
bmin = 45 * 3.14159 / 180;
}

h = ((ab - ap) / 2) * Math.tan(bmin);

v = ab*bb*h/(100*100*100);

document.getElementById('result_a').innerHTML = Math.ceil(ab)+' cm';
document.getElementById('result_b').innerHTML = Math.ceil(bb)+' cm';
document.getElementById('result_h').innerHTML = Math.ceil(h)+' cm';
document.getElementById('result_v').innerHTML = v.toFixed(3)+' m³';
this.location = "#resultado";

}


