// Copyright 2001 David W.A. Bourne (david@boomer.org)function C0608a(form1){		var k0 = 0;		var td = 0;		var kel = 0;		var V = 0;		var t1 = 4;		var c1 = 0.0;		var t2 = 5;		var c2 = 0.0;		var t3 = 6;		var c3 = 0.0;		var t4 = 9;		var c4 = 0.0;		var t5 = 12;		var c5 = 0.0;		var t6 = 24;		var c6 = 0.0;				var temp = 0.0;		// Random values for parameters		kel = getRandom(0.1,0.05,2.5,0.01);		V = getRandom(40.0,30.0,150.0,4.0);	// Values input from form - check for valid numbers		k0 = 1.0*document.form1.k0.value;				if (k0 < 0)		{			k0 = 100;			document.form1.k0.value = k0;		}				td  = 1.0*document.form1.duration.value;				if (td > 0.0 && td < 3)		{		}		else		{			td = 2.0;			document.form1.duration.value = td;		}				temp = (k0/(kel*V))*(1-Math.exp(-kel*td));				c1 = temp*Math.exp(-kel*(t1-td));		c1 = getRandom(c1,c1*0.05,c1*10,c1*0.1);		c2 = temp*Math.exp(-kel*(t2-td));		c2 = getRandom(c2,c2*0.05,c2*10,c2*0.1);		c3 = temp*Math.exp(-kel*(t3-td));		c3 = getRandom(c3,c3*0.05,c3*10,c3*0.1);		c4 = temp*Math.exp(-kel*(t4-td));		c4 = getRandom(c4,c4*0.05,c4*10,c4*0.1);		c5 = temp*Math.exp(-kel*(t5-td));		c5 = getRandom(c5,c5*0.05,c5*10,c5*0.1);		c6 = temp*Math.exp(-kel*(t6-td));		c6 = getRandom(c6,c6*0.05,c6*10,c6*0.1);		document.form1.c1.value  = roundit(c1,2);		document.form1.c2.value  = roundit(c2,2);		document.form1.c3.value  = roundit(c3,2);		document.form1.c4.value  = roundit(c4,2);		document.form1.c5.value  = roundit(c5,2);		document.form1.c6.value  = roundit(c6,2);				document.form1.kel.value  = "";		document.form1.V.value  = "";				return false;}function C0608b(form1){	var k0;	var td;	var kel;	var V;	var t1 = 4;	var c1;	var t2 = 5;	var c2;	var t3 = 6;	var c3;	var t4 = 9;	var c4;	var t5 = 12;	var c5;	var t6 = 24;	var c6;			k0 = 1.0*document.form1.k0.value;				td  = 1.0*document.form1.duration.value;				c1 = document.form1.c1.value;		c2 = document.form1.c2.value;		c3 = document.form1.c3.value;		c4 = document.form1.c4.value;		c5 = document.form1.c5.value;		c6 = document.form1.c6.value;		// semi-log linear regression analysis		var sx = t1+t2+t3+t4+t5+t6;		var sxx = t1*t1 + t2*t2 + t3*t3 + t4*t4 + t5*t5 + t6*t6;		var sy = Math.log(c1) + Math.log(c2) + Math.log(c3) + Math.log(c4) + Math.log(c5) + Math.log(c6);		var syy = Math.log(c1)*Math.log(c1) + Math.log(c2)*Math.log(c2) + Math.log(c3)*Math.log(c3) + Math.log(c4)*Math.log(c4) + Math.log(c5)*Math.log(c5) + Math.log(c6)*Math.log(c6);		var sxy = t1*Math.log(c1) + t2*Math.log(c2) + t3*Math.log(c3) + t4*Math.log(c4) + t5*Math.log(c5) + t6*Math.log(c6);		var n = 6;				kel = -(sxy-(sx*sy/n))/(sxx-(sx*sx/n));		V = Math.exp((sy/n) + ((kel*sx)/n)); // Intercept		V = V*Math.exp(-kel*td); // Cp at the end of the infusion		V = (k0/(kel*V))*(1.0-Math.exp(-kel*td)); // V				document.form1.kel.value  = roundit(kel,3);		document.form1.V.value  = roundit(V,3);}// Returns a normally distributed random number with mean m and standard deviation s between the upper and lower limits u and lfunction getRandom(m,s,u,l){	var m;	var s;	var u;	var l;		var temp;		var j = 0;	while (j < 10) // try to get within limits 10 times	{			temp = 0.0;		for (var i = 0; i < 12 ; i++) // loop 12 times		{			temp = temp + Math.random(); // Math.random() gives 0 to 1 uniform distribution		}			temp = temp - 6.0; // Normally distributed random number with mean = 0 and std dev = 1		temp = m + temp*s; // mean = m and std dev = s			if (temp > l && temp < u) break; // exit/break from loop if within limits				j = j + 1;		}		return temp;	}function roundit(a,b){	var a;	var b;	var c;		c = b - Math.round(0.5 + (Math.log(a)/Math.log(10)));	c = Math.pow(10,c);	c = Math.round(c*a)/c;	return c;}/*function cb_help(){	HelpWin = window.open('','NewWin','toolbar=0,status=0,width=200,height=300')	HelpWin.window.focus();	message  = "<BODY BGCOLOR=#FFFFFF><title>Cp Average Help</title>";	message += "<IMG SRC=CBar0.gif> is calculated using the equation ";	message += "<img src=CBar1.gif><br>";	message += "<form><center><input type=button name=test value=Close onClick=window.close()></center></form>";	HelpWin.document.write(message);}*/
