<!--
// checks to see if valid numeric values are in questions 1 and 2 before multiplying them to return the value for #3
function changeExpectedValue(){
  if (!((document.cwt_herd.numberCows.value - 0) == 0) && !((document.cwt_herd.averageValue.value - 0) == 0)){
	document.cwt_herd.expectedValue.value = (document.cwt_herd.numberCows.value - 0) * (document.cwt_herd.averageValue.value - 0);
  }
  else {
  	document.cwt_herd.expectedValue.value = 0;
  }
}

function compareCowSlaughterValue(){
  // checks to see if valid numberic values are in questions 4 and 5 before checking to see if results is less than question 2 value.  If yes, proceed with calculations defined in functions.  If not, then alert
  if ((document.cwt_herd.averageValue.value - 0) >= ((document.cwt_herd.averageWeight.value - 0) * (document.cwt_herd.slaughterPrice.value - 0))){
	if (!((document.cwt_herd.averageWeight.value - 0) == 0) && !((document.cwt_herd.slaughterPrice.value - 0) == 0)){
	  // checks to see if valid numeric values are in questions 4 and 5 before proceeding with the following functions
	  changeSlaughterValue();
	  checkCowSlaughterPrice();
	  changeTotalSlaughterValue();
	  changeExpectedPayment();
	}
  }
  else{
	//  displays error message if total slaughter value of herd is more than total expected value of herd
	alert("The Slaughter Value per cow (#6) must be less than the Expected Value Per Cow/Herd (#2). The values you have entered for the Average Weight per cow (#4) and Slaughter Price per pound (#5) produce a total greater than the Expected Value Per Cow/Herd (#2).  Please change one of the values to continue finding your CWT herd retirement bid.")
	//  resets pertinent form field values
	//document.cwt_herd.averageWeight.value = "";
	//document.cwt_herd.slaughterPrice.value = "";
	document.cwt_herd.cowSlaughterValue.value = "";
	document.cwt_herd.totalSlaughterValue.value = "";
	document.cwt_herd.expectedPayment.value = "";
	document.cwt_herd.milkMarketings.value = "";
	document.cwt_herd.milkMarketingsCwt.value = "";
	document.cwt_herd.prodBid.value = "";
	//  defaults cursor into first editable field in series
	document.cwt_herd.averageValue.select();
	document.cwt_herd.averageValue.focus();
  }
}

function checkCowSlaughterPrice(){
  // checks to see if valid numberic values are in questions 4 and 5 before checking to see if results is less than question 2 value.  If yes, proceed with calculations defined in functions.  If not, then alert
  if (document.cwt_herd.slaughterPrice.value == '') {
  	document.cwt_herd.slaughterPrice.value = 0; 
  }
}
//  multiplies the value in questions 4 and 5 and returns the value in question 6
function changeSlaughterValue(){
  document.cwt_herd.cowSlaughterValue.value = (document.cwt_herd.averageWeight.value - 0) * (document.cwt_herd.slaughterPrice.value - 0);
}

//  takes value of question 6, multiplies it by value in question 1 and places answer in question 7
function changeTotalSlaughterValue(){
  document.cwt_herd.totalSlaughterValue.value = (document.cwt_herd.numberCows.value - 0) * (document.cwt_herd.averageWeight.value - 0) * (document.cwt_herd.slaughterPrice.value - 0);
}

//  takes value of question 3 and subtracts the value of question 7 and places answer in question 8
function changeExpectedPayment(){
  document.cwt_herd.expectedPayment.value = (document.cwt_herd.expectedValue.value - 0) - (document.cwt_herd.numberCows.value - 0) * (document.cwt_herd.averageWeight.value - 0) * (document.cwt_herd.slaughterPrice.value - 0); 
}

// takes the value entered in question 9 and divides by 100 to get value for question 10
function changeMilkMarketingsCwt(){
  if (!((document.cwt_herd.milkMarketings.value - 0) == 0)){
	document.cwt_herd.milkMarketingsCwt.value = (document.cwt_herd.milkMarketings.value - 0) / 100;
  }
}

//  changes the "grand total" entry for question 11 by taking vakue in question 8 and dividing that by the value in question 10
function changeProdBid(){
  if (!((document.cwt_herd.expectedPayment.value - 0) == 0) && !((document.cwt_herd.milkMarketings.value - 0) == 0)){
	var bid = ((document.cwt_herd.expectedValue.value - 0) - (document.cwt_herd.numberCows.value - 0) * (document.cwt_herd.averageWeight.value - 0) * (document.cwt_herd.slaughterPrice.value - 0)) / ((document.cwt_herd.milkMarketings.value - 0) / 100);
	document.cwt_herd.prodBid.value = roundToPennies(bid);
  }
  else{
	if (!((document.cwt_herd.milkMarketings.value - 0) == 0) && (document.cwt_herd.expectedPayment.value - 0 == 0)){
	  document.cwt_herd.prodBid.value = "0.00";
	}
  }
}
//-->