// Вычисление времени роста бактерий

	var chck=false
	var t_int
	var t21
	var fd1;
	var fd2;
function helpod()
{
	var hlp;
switch (lng) {
	case "eng":
	hlp="/eng/scripts/h01_02.html";
	break;
	case "rus":
	hlp="/scripts/h01_02.html";
	break;
	default:
	break;
	}
window.open(hlp,'help', config='height=500,width=500,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,location=yes,status=yes');
self.name="main window"
}

function odtime()
{
if(document.ODtime.t1d.value==""){document.ODtime.t1d.value=0};
ft1d = parseFloat(document.ODtime.t1d.value.replace(/,/g,".")); 
if(isNaN(ft1d)){alert(alt02_01); document.ODtime.t1d.focus(); return true;};
ft1d = Math.abs(ft1d);
ft1d = Math.floor(ft1d);
ft1h = parseFloat(document.ODtime.t1h.value); 
if(isNaN(ft1h)||ft1h>24){alert(alt02_02); document.ODtime.t1h.focus(); return true;};
ft1h =  Math.abs(ft1h);
ft1h = Math.floor(ft1h);
ft1m = parseFloat(document.ODtime.t1m.value.replace(/,/g,".")); 
if(isNaN(ft1m)||ft1m>60){alert(alt02_03); document.ODtime.t1m.focus(); return true;};
ft1m =  Math.abs(ft1m);
fd1 = parseFloat(document.ODtime.d1.value.replace(/,/g,"."));
if(isNaN(fd1)||fd1==0){alert(alt02_04); document.ODtime.d1.focus(); return true;};
fd1 = Math.abs(fd1);
fd1 =  Math.abs(fd1);
ft2h = parseFloat(document.ODtime.t2h.value); 
if(isNaN(ft2h)||ft2h>24){alert(alt02_05); document.ODtime.t2h.focus(); return true;};
ft2h =  Math.abs(ft2h);
ft2h =  Math.floor(ft2h);
ft2m = parseFloat(document.ODtime.t2m.value.replace(/,/g,".")); 
if(isNaN(ft2m)||ft2m>60){alert(alt02_06); document.ODtime.t2m.focus(); return true;};
ft2m =  Math.abs(ft2m);
fd2 = parseFloat(document.ODtime.d2.value.replace(/,/g,".")); 
if(isNaN(fd2)||fd2==0){alert(alt02_07); document.ODtime.d2.focus(); return true;};
fd2 =  Math.abs(fd2)
fdf = parseFloat(document.ODtime.df.value.replace(/,/g,".")); 
if(isNaN(fdf)||fdf==0){alert(alt02_08); document.ODtime.df.focus(); return true;};
fdf =  Math.abs(fdf)
	t1=(ft1h-ft1d*24)*60+ft1m;
	t2=ft2h*60+ft2m;
if(t2<=t1){alert(alt02_09); return true;};
if(fd2<=fd1||fdf<=fd2){alert(alt02_10); return true;};
	t21=(t2-t1)
	t_int=t21*Math.log(fdf/fd2)/Math.log(fd2/fd1);
	ftf2h=Math.floor(t_int/60);
	ftf2m=Math.floor(t_int%60);
		t=t_int+t2;
		ftfd=Math.floor(t/1440);
		ftfh=Math.floor((t-ftfd*1440)/60);
		ftfm=Math.floor(t%60);
document.ODtime.t1d.value=ft1d;
document.ODtime.t1h.value=ft1h;
document.ODtime.t1m.value=ft1m;
document.ODtime.d1.value=fd1;
document.ODtime.t2h.value=ft2h;
document.ODtime.t2m.value=ft2m;
document.ODtime.d2.value=fd2;
document.ODtime.tfd.value=ftfd+"d";
document.ODtime.tfh.value=ftfh+"h";
document.ODtime.tfm.value=ftfm+"min";
document.ODtime.df.value=fdf;
document.ODtime.tf2h.value=ftf2h+"h";
document.ODtime.tf2m.value=ftf2m+"min";
chck=true
}

function mist()
{
if(chck==false){alert(alt02_11); return true;};
fdelOD = parseFloat(document.ODtime.delOD.value.replace(/,/g,".")); 
if(isNaN(fdelOD)||fdelOD==0){alert(alt02_12); document.ODtime.delOD.focus(); return true;};
fdelOD =  Math.abs(fdelOD);
fdel_t = parseFloat(document.ODtime.del_t.value.replace(/,/g,".")); 
if(isNaN(fdel_t)||fdel_t==0){alert(alt02_13); document.ODtime.del_t.focus(); return true;};
fdel_t =  Math.abs(fdel_t);
q=1+t_int*Math.sqrt(Math.pow(fdel_t,2)/Math.pow(t21,2)+Math.pow(fdelOD,2)*(1/Math.pow(fd1,2)+2/Math.pow(fd2,2)));
document.ODtime.delOD.value=fdelOD;
document.ODtime.del_t.value=fdel_t+"min";
document.ODtime.del_tf.value=ftf2h=Math.floor(q)+"min";
}
function calc(obj)
{
var v = parseFloat(obj.form.elements[1].value); 
if(isNaN(v)){v=0}
obj.form.elements[1].value=v+calc.arguments[1];
for(var i=1; i<=(calc.arguments.length - 2)/3; i++){
dig=Math.pow(10,calc.arguments[3*i]);
obj.form.elements[i+1].value=Math.round(calc.arguments[i*3-1]*v)/dig+calc.arguments[i*3+1];
}}
