function calculate(form) {
			var feeda = form.feeda.value
			var rmoista = form.moista.value
			var rtnda = form.tnda.value
			var rproa = form.proa.value
			var costa = form.costa.value
			var feedb = form.feedb.value
			var rmoistb = form.moistb.value
			var rtndb = form.tndb.value
			var rprob = form.prob.value
			var costb = form.costb.value
			var cowweight = form.cowweight.value
			var state = form.state.value
			var feedc = form.feedc.value
			var rmoistc = form.moistc.value
			var rtndc = form.tndc.value
			var rproc = form.proc.value
			var costc = form.costc.value


		//calculate all to 0% moisture.
			if (rmoista == 0) {
			var proa = rproa
			var tnda = rtnda
			var moista = rmoista
			}	
			else {	
				var proa = ((100 * rproa) / (100 - rmoista))
				var tnda = ((100 * rtnda) / (100 - rmoista))
				var moista = 0
			}
			if (rmoistb == 0) {
				var prob = rprob
				var tndb = rtndb
				var moistb = rmoistb
			}
			else {
				var prob = ((100 * rprob) / (100 - rmoistb))
				var tndb = ((100 * rtndb) / (100 - rmoistb))
				var moistb = 0
			}
			if (rmoistc == 0) {
				var proc = rproc
				var tndc = rtndc
				var moistc = rmoistc
			}
			else {
				var proc = ((100 * rproc) / (100 - rmoistc))
				var tndc = ((100 * rtndc) / (100 - rmoistc))
				var moistc = 0
			}
		
			if (state == "1") {
				var statecopy = "Dry pregnant mature cow - middle third of pregnancy"
				}
			else if (state == "2") {
				var statecopy = "Dry pregnant mature cow - last third of pregnancy"
				}
			else if (state == "3") {
				var statecopy = "Cows nursing calves - average milking ability - first 3 to 4 months after calving"
				}
			else {
				var statecopy = "Cows nursing calves - heavy milking ability - first 3 to 4 months after calving"
				}
		
		
			if (cowweight == "800" && state == "1") {
				var feedr = 17.0
				var feedrd = 15.3
				var tndr = 49.0
				var pror = 7.19
				}
			else if (cowweight == "900" && state == "1") {
				var feedr = 18.6
				var feedrd = 16.7
				var tndr = 49.10
				var pror = 7.18
				}
			else if (cowweight == "1000" && state == "1") {
				var feedr = 20.1
				var feedrd = 18.1
				var tndr = 48.62
				var pror = 7.18
				}
			else if (cowweight == "1100" && state == "1") {
				var feedr = 21.7
				var feedrd = 19.5
				var tndr = 48.64
				var pror = 7.17
				}
			else if (cowweight == "1200" && state == "1") {
				var feedr = 23.1
				var feedrd = 20.8
				var tndr = 48.56
				var pror = 6.73
				}
			else if (cowweight == "1300" && state == "1") {
				var feedr = 24.4
				var feedrd = 21.7
				var tndr = 49.77
				var pror = 6.91
				}
			else if (cowweight == "1400" && state == "1") {
				var feedr = 25.9
				var feedrd = 23.3
				var tndr = 48.93
				var pror = 6.87
				}
			else if (cowweight == "800" && state == "2") {
				var feedr = 18.7
				var feedrd = 16.8
				var tndr = 54.76
				var pror = 8.33
				}
			else if (cowweight == "900" && state == "2") {
				var feedr = 20.2
				var feedrd = 18.9
				var tndr = 51.85
				var pror = 7.98
				}
			else if (cowweight == "1000" && state == "2") {
				var feedr = 21.8
				var feedrd = 19.6
				var tndr = 53.57
				var pror = 8.16
				}
			else if (cowweight == "1100" && state == "2") {
				var feedr = 23.3
				var feedrd = 21.0
				var tndr = 53.33
				var pror = 7.62
				}
			else if (cowweight == "1200" && state == "2") {
				var feedr = 24.8
				var feedrd = 22.3
				var tndr = 52.9
				var pror = 7.62
				}
			else if (cowweight == "1300" && state == "2") {
				var feedr = 26.2
				var feedrd = 23.6
				var tndr = 52.97
				var pror = 7.63
				}
			else if (cowweight == "1400" && state == "2") {
				var feedr = 27.7
				var feedrd = 24.9
				var tndr = 52.61
				var pror = 7.63
				}
			else if (cowweight == "800" && state == "3") {
				var feedr = 18.1
				var feedrd = 16.3
				var tndr = 61.96
				var pror = 11.04
				}
			else if (cowweight == "900" && state == "3") {
				var feedr = 20.1
				var feedrd = 18.1
				var tndr = 59.67
				var pror = 10.50
				}
			else if (cowweight == "1000" && state == "3") {
				var feedr = 22.4
				var feedrd = 20.2
				var tndr = 56.93
				var pror = 9.90
				}
			else if (cowweight == "1100" && state == "3") {
				var feedr = 24.0
				var feedrd = 21.6
				var tndr = 56.02
				var pror = 9.26
				}
			else if (cowweight == "1200" && state == "3") {
				var feedr = 25.6
				var feedrd = 23.0
				var tndr = 55.65
				var pror = 9.13
				}
			else if (cowweight == "1300" && state == "3") {
				var feedr = 27.0
				var feedrd = 24.3
				var tndr = 55.14
				var pror = 9.05
				}
			else if (cowweight == "1400" && state == "3") {
				var feedr = 28.4
				var feedrd = 25.6
				var tndr = 54.77
				var pror = 9.00
				}
			else if (cowweight == "800" && state == "4") {
				var feedr = 18.5
				var feedrd = 16.7
				var tndr = 72.46
				var pror = 13.17
				}
			else if (cowweight == "900" && state == "4") {
				var feedr = 20.8
				var feedrd = 18.7
				var tndr = 70.05
				var pror = 12.83
				}
			else if (cowweight == "1000" && state == "4") {
				var feedr = 22.9
				var feedrd = 20.6
				var tndr = 66.99
				var pror = 12.13
				}
			else if (cowweight == "1100" && state == "4") {
				var feedr = 24.8
				var feedrd = 22.3
				var tndr = 65.02
				var pror = 11.67
				}
			else if (cowweight == "1200" && state == "4") {
				var feedr = 26.4
				var feedrd = 23.8
				var tndr = 63.87
				var pror = 11.34
				}
			else if (cowweight == "1300" && state == "4") {
				var feedr = 28.1
				var feedrd = 25.3
				var tndr = 62.85
				var pror = 11.07
				}
			else {
				var feedr = 29.7
				var feedrd = 26.7
				var tndr = 59.55
				var pror = 10.49
				}	
	
		var vala = (costa - costb)
		var valb = (prob - pror)
		var valc = (tndb - tndr)

		var vald = (costb - costa)
		var vale = (proa - pror)
		var valf = (tnda - tndr)

		var hotcow = (feedc.length)
		var cowhot = (feedb.length)

	if (cowhot == 0) {
			var afpounda = feedrd / ((100 - rmoista) / 100)
				var totalcost = (Math.round(costa/20*afpounda)/100)
				var costcheck = (Math.round(totalcost * 10) / 10)
				var costcheck2 = Math.round(totalcost)

				if (totalcost == costcheck) {
					var totalcost = (totalcost + "0")
				}
				else if (totalcost == costcheck2) {
					var totalcost = (totalcost + "00")
				}
				else if (totalcost == 0) {
					totalcost = 0.00
				}				

			document.write("<div align=\"center\"><br><img src=\"images/ez_ration_logo_sm.gif\" alt=\"\" height=\"58\" width=\"150\"  border=\"0\">")
			document.write("<br><br>A ", cowweight, " pound ", statecopy, " <br>Requires a Ration mixture of ", feedr, " total pounds at 10% moisture,<br>")
			document.write((Math.round(feedrd * (pror))/100), " pounds of protien and ", (Math.round(feedrd * tndr / 10)/10), " pounds of TDN (energy).<br><br>")
			document.write((Math.round(afpounda*10)/10), " pounds of ", feeda, " at ", (Math.round(rmoista*100)/100), "% moisture<br><br>")
			document.write("Protien at ", (Math.round(proa * afpounda)/100), " pounds meets requirement of ", (Math.round(feedrd * (pror))/100), " pounds and<br>")
			document.write("TDN at ", (Math.round((tnda * afpounda)/10)/10), " pounds meets requirement of ", (Math.round((tndr*feedrd)/10)/10), " pounds.<br>")
			document.write("Total cost per head per day is $ ", totalcost, "<br><br><br>")			
	}
	else if (hotcow == 0) {
			// start of calculations for 2 feeds only

		if (vala > "0" && valb >= "0" && valc >= "0") {
			var afpoundb = feedrd / ((100 - rmoistb) / 100)
			var totalcost = (Math.round(costb/20*afpoundb)/100)
				var costcheck = (Math.round(totalcost * 10) / 10)
				var costcheck2 = Math.round(totalcost)

				if (totalcost == costcheck) {
					var totalcost = (totalcost + "0")
				}
				else if (totalcost == costcheck2) {
					var totalcost = (totalcost + "00")
				}
				else if (totalcost == 0) {
					totalcost = 0.00
				}				

			document.write("<div align=\"center\"><br><img src=\"images/ez_ration_logo_sm.gif\" alt=\"\" height=\"58\" width=\"150\"  border=\"0\">")

			document.write("<br><br>A ", cowweight, " pound ", statecopy, " <br>Requires a Ration mixture of ", feedr, " total pounds at 10% moisture,<br>")
			document.write((Math.round(feedrd * (pror))/100), " pounds of protien and ", (Math.round(feedrd * tndr / 10)/10), " pounds of TDN (energy).<br><br>")

			document.write((Math.round(afpoundb*100)/100), " pounds of ", feedb, " at ", (Math.round(rmoistb*100)/100), "% moisture<br><br>")
			document.write("Protein at ", (Math.round(prob * afpoundb)/100), " pounds meets requirement of ", (Math.round(feedrd * (pror))/100), " pounds and<br>")
			document.write("TDN at ", (Math.round((tndb * afpoundb)/10)/10), " pounds meets requirement of ", (Math.round(tndr*feedrd/10)/10),  " pounds.<br>")
			document.write("Total cost per head per day is $ ", totalcost, "<br><br><br>")
			}
		else if (vald > "0" && vale >= "0" && valf >= "0") {
			var afpounda = feedrd / ((100 - rmoista) / 100)
			var totalcost = (Math.round(costa/20*afpounda)/100)
				var costcheck = (Math.round(totalcost * 10) / 10)
				var costcheck2 = Math.round(totalcost)

				if (totalcost == costcheck) {
					var totalcost = (totalcost + "0")
				}
				else if (totalcost == costcheck2) {
					var totalcost = (totalcost + "00")
				}
				else if (totalcost == 0) {
					totalcost = 0.00
				}				

			document.write("<div align=\"center\"><br><img src=\"images/ez_ration_logo_sm.gif\" alt=\"\" height=\"58\" width=\"150\"  border=\"0\">")
			document.write("<br><br>A ", cowweight, " pound ", statecopy, " <br>Requires a Ration mixture of ", feedr, " total pounds at 10% moisture,<br>")
			document.write((Math.round(feedrd * (pror))/100), " pounds of protien and ", (Math.round(feedrd * tndr / 10)/10), " pounds of TDN (energy).<br><br>")
			document.write((Math.round(afpounda*100)/100), " pounds of ", feeda, " at ", (Math.round(rmoista*100)/100), "% moisture<br><br>")
			document.write("Protien at ", (Math.round(proa * afpounda)/100), " pounds meets requirement of ", (Math.round(feedrd * (pror))/100), " pounds and<br>")
			document.write("TDN at ", (Math.round((tnda * afpounda)/10)/10), " pounds meets requirement of ", (Math.round((tndr*feedrd)/10)/10), " pounds.<br>")
			document.write("Total cost per head per day is $ ", totalcost, "<br><br><br>")			
			}
		else if (valb < "0" && vale < "0") {
			document.write("<div align=\"center\"><br><br><br><img src=\"images/ez_ration_logo.gif\" alt=\"\" width=\"262\" height=\"102\" border=\"0\">")
			document.write("<div align=\"center\"><br><br><br>Neither feed has enough protein.<br><br>You need to use another feed with better nutrition<br>or add a grain feed to raise nutrition.<br><br><br></div>")
			}
		else {
			//calculate cheepest a or b
			if (vala >= "0") {
				//calculate cheepest ration with minimum protien if b is cheepest
				var i=1
				var totalr = (feedrd*100)
				var mix = 0

				while (i<= totalr) {
					var pounda = (i/100)
					var poundb = (feedrd - (i/100))
					
					mix = ((prob * poundb) + ( proa * pounda))/feedrd
					var comp = (mix - pror)

					if (comp >= "0") {
						afpounda = pounda / ((100 - rmoista) / 100)
						afpoundb = poundb / ((100 - rmoistb) / 100)
						var afcosta = ((costa / 2000) * afpounda)
						var afcostb = ((costb / 2000) * afpoundb)

									var tcostan = Math.round(afcosta * 100) /100
									var tcosta = tcostan
									var costcheck = (Math.round(tcosta * 10) / 10)
									var costcheck2 = Math.round(tcosta)

									if (tcosta == costcheck) {
										var tcosta = (tcostan + "0")
									}
									else if (tcosta == costcheck2) {
										var tcosta = (tcostan + "00")
									}
									else if (tcosta == 0) {
										var tcosta = 0.00
									}

									var tcostbn = Math.round(afcostb * 100) /100
									var tcostb = tcostbn
									var costcheck3 = (Math.round(tcostb * 10) / 10)
									var costcheck4 = Math.round(tcostb)

									if (tcostb == costcheck3) {
										var tcostb = (tcostbn + "0")
									}
									else if (tcostb == costcheck4) {
										var tcostb = (tcostbn + "00")
									}
									else if (tcostb == 0) {
										 var tcostb = 0.00
									}								

									var cofpd = (Math.round((tcostan + tcostbn)*100)/100)
									var costcheck5 = (Math.round(cofpd * 10) / 10)
									var costcheck6 = Math.round(cofpd)

									if (cofpd == costcheck5) {
										var cofpd = (cofpd + "0")
									}
									else if (cofpd == costcheck6) {
										var cofpd = (cofpd + "00")
									}
									
						var tndmix = (((tndb * poundb) + (tnda * pounda))/feedrd)
						var tndcomp = tndmix - tndr
						if (tndcomp >= "0") {
							document.write("<div align=\"center\"><br><br><img src=\"images/ez_ration_logo_sm.gif\" alt=\"\" height=\"58\" width=\"150\"  border=\"0\">")
							document.write("<br><br>A ", cowweight, " pound ", statecopy, " <br>Requires a Ration mixture of ", feedr, " total pounds at 10% moisture,<br>")
							document.write((Math.round(feedrd * (pror))/100), " pounds of protien and ", (Math.round(feedrd * tndr / 10)/10), " pounds of TDN (energy).<br><br>")
							document.write((Math.round(afpounda*100)/100), " pounds ", feeda, " at ", (Math.round(rmoista*100)/100), "% moisture and <br>", (Math.round(afpoundb*100)/100), " pounds ", feedb, " at ", (Math.round(rmoistb*100)/100), "% moisture.<br><br>",  "Protein at ", (Math.round(feedrd * mix)/100), " pounds meets requirement of ", (Math.round(feedrd * (pror))/100), " pounds.<br>")
							document.write("TDN at ", (Math.round(feedrd * tndmix / 10)/10), " pounds meets requirement ", (Math.round(feedrd * tndr / 10)/10), " pounds.<br><br>")
							document.write("Cost of ", feeda, " is $", tcosta, "<br>Cost of ", feedb, " is $", tcostb, "<br>Total cost per head per day is $ ", cofpd)
							}
						else {
							document.write("<div align=\"center\"><br><br><br><img src=\"images/ez_ration_logo.gif\" alt=\"\" width=\"262\" height=\"102\" border=\"0\">")
							document.write("<br><br>A ", cowweight, " pound ", statecopy, " <br>Requires a Ration mixture of ", feedr, " total pounds at 10% moisture,<br>")
							document.write((Math.round(feedrd * (pror))/100), " pounds of protien and ", (Math.round(feedrd * tndr / 10)/10), " pounds of TDN (energy).<br><br>")
							document.write((Math.round(afpounda*100)/100), " pounds ", feeda, " at ", (Math.round(rmoista*100)/100), "% moisture and <br>", (Math.round(afpoundb*100)/100), " pounds ", feedb, " at ", (Math.round(rmoistb*100)/100), "% moisture.<br><br>",  "Protein at ", (Math.round(feedrd * mix)/100), " pounds meets requirement of ", (Math.round(feedrd * (pror))/100), " pounds.<br>")
							document.write("TDN at ", (Math.round(feedrd * tndmix / 10)/10), " pounds is short of ", (Math.round(feedrd * tndr / 10)/10), " pounds.<br><br>")
							document.write("<b><font color=\"red\">If TDN (energy) is short it may be best to try to add a little grain to complete the ration.</font></b><br><br>")
							document.write("Cost of ", feeda, " is $", tcosta, "<br>Cost of ", feedb, " is $", tcostb, "<br>Total cost per head per day is $ ", cofpd)
							}
						i=totalr
						}
				i++
				}
			}
			else {
				var i=1
				var totalr = (feedrd*100)
				var mix = 0

				while (i<= totalr) {
					var poundb = (i/100)
					var pounda = (feedrd - (i/100))
					
					mix = ((prob * poundb) + ( proa * pounda))/feedrd
					var comp = (mix - pror)
					if (comp >= "0") {
						afpounda = pounda / ((100 - rmoista) / 100)
						afpoundb = poundb / ((100 - rmoistb) / 100)
						var afcosta = ((costa / 2000) * afpounda)
						var afcostb = ((costb / 2000) * afpoundb)
						
									var tcostan = Math.round(afcosta * 100) /100
									var tcosta = tcostan
									var costcheck = (Math.round(tcosta * 10) / 10)
									var costcheck2 = Math.round(tcosta)

									if (tcosta == costcheck) {
										var tcosta = (tcostan + "0")
									}
									else if (tcosta == costcheck2) {
										var tcosta = (tcostan + "00")
									}
									else if (tcosta == 0) {
										var tcosta = 0.00
									}

									var tcostbn = Math.round(afcostb * 100) /100
									var tcostb = tcostbn
									var costcheck3 = (Math.round(tcostb * 10) / 10)
									var costcheck4 = Math.round(tcostb)

									if (tcostb == costcheck3) {
										var tcostb = (tcostbn + "0")
									}
									else if (tcostb == costcheck4) {
										var tcostb = (tcostbn + "00")
									}
									else if (tcostb == 0) {
										 var tcostb = 0.00
									}								

									var cofpd = (Math.round((tcostan + tcostbn)*100)/100)
									var costcheck5 = (Math.round(cofpd * 10) / 10)
									var costcheck6 = Math.round(cofpd)

									if (cofpd == costcheck5) {
										var cofpd = (cofpd + "0")
									}
									else if (cofpd == costcheck6) {
										var cofpd = (cofpd + "00")
									}
						
						var tndmix = (((tndb * poundb) + ( tnda * pounda))/feedrd)
						var tndcomp = tndmix -tndr
						if (tndcomp >= "0") {
							document.write("<div align=\"center\"><br><img src=\"images/ez_ration_logo_sm.gif\" alt=\"\" height=\"58\" width=\"150\"  border=\"0\">")
							document.write("<br><br>A ", cowweight, " pound ", statecopy, " <br>Requires a Ration mixture of ", feedr, " total pounds at 10% moisture,<br>")
							document.write((Math.round(feedrd * (pror))/100), " pounds of protien and ", (Math.round(feedrd * tndr / 10)/10), " pounds of TDN (energy).<br><br>")
							document.write((Math.round(afpounda*100)/100), " pounds ", feeda, " at ", (Math.round(rmoista*100)/100), "% moisture and <br>", (Math.round(afpoundb*100)/100), " pounds ", feedb, " at ", (Math.round(rmoistb*100)/100), "% moisture.<br><br>",  "Protein at ", (Math.round(feedrd * mix)/100), " pounds meets requirement of ", (Math.round(feedrd * (pror))/100), " pounds.<br>")
							document.write("TDN at ", (Math.round(feedrd * tndmix / 10)/10), " pounds meets requirement ", (Math.round(feedrd * tndr / 10)/10), " pounds.<br><br>")
							document.write("Cost of ", feeda, " is $", tcosta, "<br>Cost of ", feedb, " is $", tcostb, "<br>Total cost per head per day is $ ", cofpd)
							}
						else {
							document.write("<div align=\"center\"><br><br><br><img src=\"images/ez_ration_logo.gif\" alt=\"\" width=\"262\" height=\"102\" border=\"0\">")
							document.write("<br><br>A ", cowweight, " pound ", statecopy, " <br>Requires a Ration mixture of ", feedr, " total pounds at 10% moisture,<br>")
							document.write((Math.round(feedrd * (pror))/100), " pounds of protien and ", (Math.round(feedrd * tndr / 10)/10), " pounds of TDN (energy).<br><br>")
							document.write((Math.round(afpounda*100)/100), " pounds ", feeda, " at ", (Math.round(rmoista*100)/100), "% moisture and <br>", (Math.round(afpoundb*100)/100), " pounds ", feedb, " at ", (Math.round(rmoistb*100)/100), "% moisture.<br><br>",  "Protein at ", (Math.round(feedrd * mix)/100), " pounds meets requirement of ", (Math.round(feedrd * (pror))/100), " pounds.<br>")
							document.write("TDN at ", (Math.round(feedrd * tndmix / 10)/10), " pounds is short of ", (Math.round(feedrd * tndr / 10)/10), " pounds.<br><br>")
							document.write("<b><font color=\"red\">If TDN (energy) is short it may be best to try to add a little grain to complete the ration.</font></b><br><br>")
							document.write("Cost of ", feeda, " is $", tcosta, "<br>Cost of ", feedb, " is $", tcostb, "<br>Total cost per head per day is $ ", cofpd)
							}
						i=totalr
						}
				i++
				}
			}
		}
		//returnVal = true
		} //end of calculation for 2 feeds
	
//----------------------------------------------------------------- start calculation for 3 feeds ------------------------------
	else {
				//calculate cheepest ration with minimum protien if b is cheepest				
				var z=0
				var totalr = (feedrd*25)
				var mix = 0
				var aaa = 0
				var bbb = 0
				var ccc = 0
				var aa = 0
				var bb = 0
				var cc = 0
				var cheepcost = 1000000
					
				while (z <= totalr) {
					var leftr = (totalr - z)
					var i=1
				
					while (i<= leftr) {
						var pounda = (i/25)
						var poundb = ((leftr/25) - (i/25))
						var poundc = (z/25)

						mix = ((prob * poundb) + (proa * pounda) + (proc * poundc))/feedrd
						var comp = (mix - pror)
					
						if (comp >= "0") {
							var afpounda = pounda / ((100 - rmoista) / 100)
							var afpoundb = poundb / ((100 - rmoistb) / 100)
							var afpoundc = poundc / ((100 - rmoistc) / 100)
							var afcosta = ((costa / 2000) * afpounda)
							var afcostb = ((costb / 2000) * afpoundb)
							var afcostc = ((costc / 2000) * afpoundc)	
							var tndmix = (((tndb * poundb) + (tnda * pounda) + (tndc * poundc))/feedrd)
							var tndcomp = (tndmix - tndr)
							if (tndcomp >= "0") {
								var totalcost = (afcosta + afcostb + afcostc)
								var wam = (cheepcost - totalcost)
								if (wam > "0") {
									cheepcost = totalcost
									aaa = afpounda
									bbb = afpoundb
									ccc = afpoundc
									aa = pounda
									bb = poundb
									cc = poundc

								} //end if (wam > "0")
							} //end if (tndcomp >="0")
						} // end if (comp >="0")
					i++
					}   //end while (i<= totalair)
				z++
				} //end while (z<= totalair)

						
						var afcosta = ((costa / 2000) * aaa)
						var afcostb = ((costb / 2000) * bbb)
						var afcostc = ((costc / 2000) * ccc)
						var afpounda = aaa
						var afpoundb = bbb
						var afpoundc = ccc
						var pounda = aa
						var poundb = bb
						var poundc = cc
						var mix = ((prob * poundb) + (proa * pounda) + (proc * poundc))/feedrd
						var tndmix = (((tndb * poundb) + (tnda * pounda) + (tndc * poundc))/feedrd)
						var tndcomp = tndmix - tndr

									var tcostan = Math.round(afcosta * 100) /100
									var tcosta = tcostan
									var costcheck = (Math.round(tcosta * 10) / 10)
									var costcheck2 = Math.round(tcosta)

									if (tcosta == 0 && afpounda != 0) {
										 var tcosta = "0.00"
									}								
									else if (tcosta == 0 && afpounda == 0) {
										var tcosta = "0.00"
									}
									else if (tcosta == costcheck) {
										var tcosta = (tcostan + "0")
									}
									else if (tcosta == costcheck2) {
										var tcosta = (tcostan + "00")
									}
									else if (tcosta == 0) {
										var tcosta = "0.00"
									}

									var tcostbn = Math.round(afcostb * 100) /100
									var tcostb = tcostbn
									var costcheck3 = (Math.round(tcostb * 10) / 10)
									var costcheck4 = Math.round(tcostb)

									if (tcostb == 0 && afpoundb != 0) {
										 var tcostb = "0.00"
									}								
									else if (tcostb == 0 && afpoundb == 0) {
										var tcostb = "0.00"
									}
									else if (tcostb == costcheck3) {
										var tcostb = (tcostbn + "0")
									}
									else if (tcostb == costcheck4) {
										var tcostb = (tcostbn + "00")
									}
									else if (tcostb == 0) {
										 var tcostb = "0.00"
									}

									var tcostcn = Math.round(afcostc * 100) /100
									var tcostc = tcostcn
									var costcheck7 = (Math.round(tcostc * 10) / 10)
									var costcheck8 = Math.round(tcostc)

									if (tcostc == 0 && afpoundc != 0) {
										 var tcostc = "0.00"
									}								
									else if (tcostc == 0 && afpoundc == 0) {
										var tcostc = "0.00"
									}
									else if (tcostc == costcheck7) {
										var tcostc = (tcostcn + "0")
									}
									else if (tcostc == costcheck8) {
										var tcostc = (tcostcn + "00")
									}
									else if (tcostc == 0) {
										 var tcostc = "0.00"
									}								

									var cofpd = (Math.round((tcostan + tcostbn + tcostcn)*100)/100)
									var costcheck5 = (Math.round(cofpd * 10) / 10)
									var costcheck6 = Math.round(cofpd)

									if (cofpd == costcheck5) {
										var cofpd = (cofpd + "0")
									}
									else if (cofpd == costcheck6) {
										var cofpd = (cofpd + "00")
									}


						if (cheepcost == 1000000) {
							document.write("<div align=\"center\"><br><img src=\"images/ez_ration_logo_sm.gif\" alt=\"\" height=\"58\" width=\"150\"  border=\"0\">")
							document.write("<br><br><br>None of the 3 feeds has enough TDN.<br><br>You need to use another feed with better nutrition.<br><br><br><a href=\"#\" onClick=\"history.go(-1)\"></a><input type=button value=\"Back\" onClick=\"history.go(-1)\"></div>")
							}
						else if (tndcomp >= "0") {
							document.write("<div align=\"center\"><br><img src=\"images/ez_ration_logo_sm.gif\" alt=\"\" height=\"58\" width=\"150\"  border=\"0\">")
							document.write("<br><br>A ", cowweight, " pound ", statecopy, " <br>Requires a Ration mixture of ", feedr, " total pounds at 10% moisture,<br>")
							document.write((Math.round(feedrd * (pror))/100), " pounds of protien and ", (Math.round(feedrd * tndr / 10)/10), " pounds of TDN (energy).<br><br>")
							document.write((Math.round(afpounda*100)/100), " pounds ", feeda, " at ", (Math.round(rmoista*100)/100), "% moisture and <br>", (Math.round(afpoundb*100)/100), " pounds ", feedb, " at ", (Math.round(rmoistb*100)/100), "% moisture and<br>", (Math.round(afpoundc*100)/100), " pounds ", feedc, " at ", (Math.round(rmoistc*100)/100), "% moisture.<br><br>",  "Protein at ", (Math.round(feedrd * mix)/100), " pounds meets requirement of ", (Math.round(feedrd * (pror))/100), " pounds.<br>")
							document.write("TDN at ", (Math.round(feedrd * tndmix / 10)/10), " pounds meets requirement ", (Math.round(feedrd * tndr / 10)/10), " pounds.<br><br>")

							document.write("Cost of ", feeda, " is $ ", tcosta, "<br>Cost of ", feedb, " is $ ", tcostb, "<br>Cost of ", feedc, " is $ ", tcostc,  "<br>Total cost per head per day is $ ", cofpd)
							}
						else {
							document.write("<div align=\"center\"><br><img src=\"images/ez_ration_logo_sm.gif\" alt=\"\" height=\"58\" width=\"150\"  border=\"0\">")
							document.write("<br><br>A ", cowweight, " pound ", statecopy, " <br>Requires a Ration mixture of ", feedr, " total pounds at 10% moisture,<br>")
							document.write((Math.round(feedrd * (pror))/100), " pounds of protien and ", (Math.round(feedrd * tndr / 10)/10), " pounds of TDN (energy).<br><br>")
							document.write((Math.round(afpounda*100)/100), " pounds ", feeda, " at ", (Math.round(rmoista*100)/100), "% moisture and <br>", (Math.round(afpoundb*100)/100), " pounds ", feedb, " at ", (Math.round(rmoistb*100)/100), "% moisture and<br>", (Math.round(afpoundc*100)/100), " pounds ", feedc, " at ", (Math.round(rmoistc*100)/100), "% moisture.<br><br>",  "Protein at ", (Math.round(feedrd * mix)/100), " pounds meets requirement of ", (Math.round(feedrd * (pror))/100), " pounds.<br>")
		
							document.write("TDN at ", (Math.round(feedrd * tndmix / 10)/10), " pounds is short of ", (Math.round(feedrd * tndr / 10)/10), " pounds.<br><br>")
							
							document.write("<font color=\"red\">If TDN (energy) is short a better grain could be used to complete the ration.</font></b><br><br>")

							document.write("Cost of ", feeda, " is $ ", tcosta, "<br>Cost of ", feedb, " is $ ", tcostb, "<br>Cost of ", feedc, " is $ ", tcostc,  "<br>Total cost per head per day is $ ", cofpd)
							}

		} //end  else{   ---------------------------------------------------------- of calculations for 3 feeds--------------------
			
			document.write("<br><br><div align=\"center\">Print this page</div>")
			document.write("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"><tr><td><br></td><td width=\"600\">")
			document.write("<br><br><div align=\"center\"><b>Call 1-800-242-9599 or email us at <a href=\"mailto:ezration@ezration.com\">ezration@ezration.com</a> for more information on the EZ Ration Processor&rsquo;s patented ability to process and blend two different feeds or hays plus add grains &amp; silage</b></div><br><br>")
			document.write("</td><td><br></td></tr><tr><td></td><td width=\"600\">")
			document.write("The pounds of feed/hay are based on the feed/hay being processed <b>(fed through a hay processor).</b> If feed/hay is fed as is (in the bale) it will generally require 20% to 30% more. Some tub grinders grind feed/hay to fine, this can up the total pound requirements by 20% to 30% as well. This ration calculator is designed to try to meet minimum nutrient requirements in minimum dry matter requirements, to be as efficient as possible. Other possible combinations could meet the nutritional requirements as well. Figures are generally considered to be minimums/maintenance rations only. Cattle requirements may increase when, temperature decrease, or feeding on the ground in poor conditions (mud), if feed has a high ADF in test results (38 or higher), the palatability of the feed/hay is poor, and other factors.<br><br>Some nutrition manuals may show slightly different requirements. Cattle should always be on a good free choice mineral program. To increase condition or body score of the cattle, it is usually best to increase the TDN (energy) in a ration along with a small increase in protein. Always check for nitrates-- high nitrate feed can cause abortions and death. Processing and blending of feed/hay generally increases palatability considerably, however cattle may still not consume 100% of extremely unpalatable feed/hay.")
			document.write("</td><td><br></td></tr></table>")
return;
	} //end of function