<!-- script program here

//--------------------------------------------------------------------------------
// Copyright 2004, Ed Colet (EdC), All rights reserved.
// EdC owns and will retain all right, title interest and ownership 
// in and to the Program and any copies or updates of the Program.
//--------------------------------------------------------------------------------
	
	function find_Z_time(form)
	{
		// input time, mean, sd of race1
		var t_hh1 = form.time1_hh.value
		var t_mm1 = form.time1_mm.value
		var t_ss1 = form.time1_ss.value		
		var mu_hh1 = form.mu1_hh.value
		var mu_mm1 = form.mu1_mm.value
		var mu_ss1 = form.mu1_ss.value
		var sd_hh1 = form.sd1_hh.value
		var sd_mm1 = form.sd1_mm.value
		var sd_ss1 = form.sd1_ss.value

		//convert to secs
		var t1 = (t_hh1*60*60) + (t_mm1*60)+ (t_ss1*1)  
		var mu1 = (mu_hh1*60*60) + (mu_mm1*60)+ (mu_ss1*1)  
		var sd1 = (sd_hh1*60*60) + (sd_mm1*60)+ (sd_ss1*1)  

		// calcuate zscore
		var z1 = (t1 - mu1)/sd1

		// input mean and sd of race2
	  	var mu_hh2 = form.mu2_hh.value
		var mu_mm2 = form.mu2_mm.value
		var mu_ss2 = form.mu2_ss.value
		var sd_hh2 = form.sd2_hh.value
		var sd_mm2 = form.sd2_mm.value
		var sd_ss2 = form.sd2_ss.value

		//convert to secs
		var mu2 = (mu_hh2*60*60) + (mu_mm2*60)+ (mu_ss2*1)  
		var sd2 = (sd_hh2*60*60) + (sd_mm2*60)+ (sd_ss2*1)  

		// predicted time for race2 (in secs) is the zscore using mean and sd of race2, and solving for time2
		var t2 = (z1*sd2)+mu2

		// convert t2 (secs) to minutes expressed as a decimal
		var cmm = t2/60

		// convert from minutes to hours as a decimal
		var chh = cmm / 60
		// isolate data at the rt of the decimal, convert to minutes as a decimal
 		var rt_side = chh % 1
		var ccmm = rt_side * 60
		// isolate minutes (decimal) to seconds, 
		var css =  ccmm % 1
		var css = css * 60

		//output predicted hh:mm:ss
		form.pss.value = Math.round(css)
		form.pmm.value = Math.round(ccmm)
		form.phh.value = chh - rt_side
		
		//chk for debugging
		//form.chk1.value = t2
    	//form.chk2.value = cmm
    	//form.chk3.value = chh
    	//form.chk4.value = rt_side
    	//form.chk5.value = ccmm
    	//form.chk6.value = css
    	//form.chk7.value = css 
	}
//--> 
