<!--
    var vHerbicide
    var vAmount
    var vAppUnit
    var vAppUnitPer
    var vBulkUnit
    var vEPA = ""
    var vMixOrder = 0
    var vOutput = ""
    var dataArray = new Array()
    var datHerbArray = new Array()
    var datBulkArray = new Array()
    var datAmountArray = new Array()
    var datAppArray = new Array()
    var datEPAArray = new Array()
    var datMixOrderArray = new Array()
    var ndx = 0
    
    //associative array of
    // Herbicides names and EPA nums.
    //var herbEPAArray = new Array()
    
    //associative array of
    // Herbicides names and Mix orders
    //var herbOrderArray = new Array()
    
    var useCustomVol = false;
    
    function init()
    {
      getHerbicide();
      getAppUnit();
      getBulkUnit();
    }

    function getHerbicide()
    {
      if(document.forms[0].herbicides.value != "SelectHerb")
      {
      	vHerbicide = document.forms[0].herbicides.value;      
        getEPA(vHerbicide)
        showEPA()
        getMixOrder(vHerbicide)
      }
    }
    
    function getEPA()
    {
      if(herbEPAArray.length != 0)
      {
        vEPA = herbEPAArray[vHerbicide]
      }
    }
    
    function showEPA()
    {
        var temp 
        var thisDIV
        //temp = "<input name='EPAText' type='text' value='"
        //temp = temp + vEPA + "'>"
        temp = "EPA Reg. No. " + vEPA;
        
				thisDIV = document.getElementById('EPA');
        thisDIV.innerHTML = temp
    }
    
    function getMixOrder()
    {
		  if(herbOrderArray.length != 0)
		  {
			  vMixOrder = herbOrderArray[vHerbicide];
			}
		}
    
    function getAmount()
    {
        //vAmount = document.forms[0].Amount.value;
        vAmount = document.forms[0].appamount.value;
    }
    
    function getAppUnit()
    {
        //vAppUnit = document.forms[0].AppUnit.value;
				vAppUnit = document.forms[0].AppUnit.options[document.forms[0].AppUnit.options.selectedIndex].value;
        vAppUnitPer = document.forms[0].AppUnit.options[document.forms[0].AppUnit.options.selectedIndex].text;
        
    }
    
    function getBulkUnit()
    {
        vBulkUnit = document.forms[0].BulkUnit.value;
    }
       			
    function setHerbArray(frm)
    {
      //this converts the js array to String
      // and sets the hidden form field to the string value
      frm.herbArray.value=datHerbArray.join("|");
      frm.bulkArray.value=datBulkArray.join("|");
      frm.amountArray.value=datAmountArray.join("|");
      frm.appArray.value=datAppArray.join("|");
      frm.epaArray.value=datEPAArray.join("|");
      frm.mixOrderArray.value=datMixOrderArray.join("|");
            
    }
    
    //herbData Object for dataArray
    function herbData(herbicide, amt, unit, bulk)
    {
      this.herbicide = herbicide
      this.amt = amt
      this.unit = unit
      this.bulk = bulk
    }
    
    //called from the Add button
    //  onCLick event
    //  Adds harbicide data to the
    //  dataArray and calls
    //  showSelectedHerbTable() to
    //  show data
    function addHerbToArray()
    {         
      if(document.forms[0].herbicides.value == "SelectHerb")
      {
        //No Herb selected
			  return;
			}
      var message = "";
			document.getElementById('errMsg').innerHTML = message;
      if(document.inputForm.appamount.value == 0)
		  {
			  message = "Please enter an Amount to Apply.<BR>";
			  document.getElementById('errMsg').innerHTML = message;
			  return;
			}			
						
			if(document.inputForm.AppUnit.value == "GAL")
			{
		    var amt = parseInt(document.inputForm.Amount.value, 10);
	      if(amt > document.inputForm.carriervol.value)
			  {
				  message = "Amount to Apply must be less than Carrier Vol.<BR>";
				  document.getElementById('errMsg').innerHTML = message;
				  return;
				}			
			}
			else if(document.inputForm.AppUnit.value == "QT")
			{
		    var amt = parseInt(document.inputForm.Amount.value, 10);
		    amt = amt / 4;
	      if(amt > document.inputForm.carriervol.value)
			  {
				  message = "Amount to Apply must be less than Carrier Vol.<BR>";
				  document.getElementById('errMsg').innerHTML = message;
				  return;
				}			
			  
			}
			else if(document.inputForm.AppUnit.value == "PT")
			{
		    var amt = parseInt(document.inputForm.Amount.value, 10);
		    amt = amt / 8;
	      if(amt > document.inputForm.carriervol.value)
			  {
				  message = "Amount to Apply must be less than Carrier Vol.<BR>";
				  document.getElementById('errMsg').innerHTML = message;
				  return;
				}			
			  
			}
			
			if((document.inputForm.appamount.value != "") && (!isNumber(document.inputForm.appamount.value)))
			{
			  message = "Amount to Apply is NOT a Valid Number.<BR>"
			  document.getElementById('errMsg').innerHTML = message;
			  return;
			}
						
			if(vBulkUnit == "LB")
			{
			  if((vAppUnit == "LB") || (vAppUnit == "LB/100GAL") || (vAppUnit == "OZ"))
			  {
				  //OK - Do nothing
				}
				else
			  {
			  message = "App Unit Does NOT Match the Selected Bulk Unit.<BR>"
			  document.getElementById('errMsg').innerHTML = message;
			  return;				  
				}
			}
			if(vBulkUnit != "LB")
			{
			  if((vAppUnit == "LB") || (vAppUnit == "LB/100GAL"))
			  {
			  message = "App Unit Does NOT Match the Selected Bulk Unit.<BR>"
			  document.getElementById('errMsg').innerHTML = message;
			  return;				  
				}
			}		
			
			//check to see if there are
			//currently items in the array
			// so we can append data to the array
			var cur = datHerbArray.length;
			if(cur != 0)
				ndx = cur;		
					
      getAmount()
      //getMixOrder()
      dataArray[ndx] = new herbData(vHerbicide, vAmount, vAppUnitPer, vBulkUnit)
      datHerbArray[ndx]= vHerbicide
      datBulkArray[ndx]= vBulkUnit
      datAmountArray[ndx]= vAmount
      datAppArray[ndx]= vAppUnit
      datEPAArray[ndx]= vEPA
      datMixOrderArray[ndx]= vMixOrder
      ndx++
      showSelectedHerbTable()
      resetHerbControls(document.inputForm)
    }

    //show the selected herbicides in a table
    // in the DIV area
    //Called by addHerbToArray()
    function showSelectedHerbTable()
    {
      var thisDIV
      var temp
      var H = ""
      var A = 0
      var U = ""
      var B = ""           
      
      temp = "<TABLE RULES=ALL bordercolor='#FF0000' WIDTH='75%'>"
      temp = temp + "<TH>Selected Herbicide</TH><TH>Amount</TH><TH>App Unit</TH><TH>Bulk Unit</TH>"
      for(var i = 0; i < datHerbArray.length; i++)
      {
        H = datHerbArray[i]
        A = datAmountArray[i]
        U = datAppArray[i]
        B = datBulkArray[i]
        temp = temp + "<TR><TD WIDTH='50%'>" + H + "</TD><TD WIDTH='10%'>" + A
            + "</TD><TD WIDTH='20%'>" + U
            + "</TD><TD WIDTH='20%'>" + B + "</TD></TR>"
      }
      temp = temp + "</TABLE>"
      
      thisDIV = document.getElementById('selectedItems');
      thisDIV.innerHTML = temp
    }
    
    function ReloadHerbTable(frm)
    {
      var thisDIV
      var temp
      var H = ""
      var A = 0
      var U = ""
      var B = ""
      
      datHerbArray = frm.herbArray.value.split("|");
      datAmountArray = frm.amountArray.value.split("|");
      datAppArray = frm.appArray.value.split("|");
      datBulkArray = frm.bulkArray.value.split("|");
      datMixOrderArray = frm.mixOrderArray.value.split("|");
      datEPAArray = frm.epaArray.value.split("|");
                 
      temp = "<TABLE RULES=ALL bordercolor='#FF0000' WIDTH='75%'>"
      temp = temp + "<TH>Selected Herbicide</TH><TH>Amount</TH><TH>App Unit</TH><TH>Bulk Unit</TH>"
      for(var i = 0; i < datHerbArray.length; i++)
      {
        H = datHerbArray[i]
        A = datAmountArray[i]
        U = datAppArray[i]
        B = datBulkArray[i]
        temp = temp + "<TR><TD WIDTH='50%'>" + H + "</TD><TD WIDTH='10%'>" + A
            + "</TD><TD WIDTH='20%'>" + U
            + "</TD><TD WIDTH='20%'>" + B + "</TD></TR>"
      }
      temp = temp + "</TABLE>"
            
      thisDIV = document.getElementById('selectedItems');
      thisDIV.innerHTML = temp		  
		}
    
    function resetHerbControls(frm)
    {
		  frm.Amount.value = "";
		  frm.herbicides.selectedIndex = 0;
		  frm.BulkUnit.selectedIndex = 3;
		  getBulkUnit();
		  frm.AppUnit.selectedIndex = 0;
		  getAppUnit();
		  var EPADIV = document.getElementById('EPA');
		  EPADIV.innerHTML = "EPA Reg. N0. ";
		}
		
		function resetForm(frm)
    {		  
		  var EPADIV = document.getElementById('EPA');
		  EPADIV.innerHTML = "EPA Reg. N0. ";
		  var HERBDIV = document.getElementById('selectedItems');
		  HERBDIV.innerHTML = "Selected Herbicides";
						
	    dataArray = new Array()
	    datHerbArray = new Array()
	    datBulkArray = new Array()
	    datAmountArray = new Array()
	    datAppArray = new Array()
	    datEPAArray = new Array()
	    datMixOrderArray = new Array()
	    //herbEPAArray = new Array()
	    //herbOrderArray = new Array()
	    ndx = 0			  
	    
	    //reset FORM variables
	    frm.herbArray.value = "";
	    frm.bulkArray.value = "";
	    frm.amountArray.value = "";
	    frm.appArray.value = "";
	    frm.epaArray.value = "";
	    frm.mixOrderArray.value = "";
	    
	    ReloadHerbTable(frm);
	    resetHerbControls(frm);
	    init();
		}
    
    function FieldSizeChanged(frm)
    {
		  if(frm.FieldSize.value == "")
		  {
			  frm.fieldsize.value = 0;
			}
			else
			{
			  frm.fieldsize.value = frm.FieldSize.value;
			}
		}
		
		function TankSizeChanged(form)
		{
		  if(form.TankSize.value == "")
		  {
			  form.tanksize.value = 0;
			}
			else
			{
			  form.tanksize.value = form.TankSize.value;
			}		  
		}
		
		function AppAmountChanged(form)
		{
		  if(form.Amount.value == "")
		  {
			  form.appamount.value = 0;
			  vAmount = 0;
			}
			else
			{
			  form.appamount.value = form.Amount.value;
			  vAmount = form.Amount.value;
			}		  
		}
		
		function CarrierVolChanged(form, val)
		{
		  if(val == 0)
		  {
		    useCustomVol = true;
		    //use Custom Volume
		    if(form.CustomVol.value == "")
		    {
				  form.carriervol.value = 0;
				}
				else
				{
				  form.CustomVol.value = val;
				  form.carriervol.value = form.CustomVol.value;
				}
			}
			else
			{			  
			  useCustomVol = false;
			  form.carriervol.value = val;
			  form.CarrierVol.value = val;
			  form.CustomVol.value = 0;
				form.customvol.value = 0;
			}
			//CustomVolChanged(form);
			
		}
		
		function CustomVolChanged(form)
		{
		  if(useCustomVol == true)
		  {
			  if(form.CustomVol.value == "")
			  {
				  form.carriervol.value = 0;
				  form.customvol.value = 0;
				}
				else
				{
				  form.carriervol.value = form.CustomVol.value;
				  form.customvol.value = form.CustomVol.value;
				}		  
			}
			else
			{			  
			  if((form.CustomVol.value != "") || (form.CustomVol.value != 0))
			  {
			    for (i=0;i<document.forms[0].CarrierVol.length;i++)
					{
						if (document.forms[0].CarrierVol[i].value == 0)
						{
						  document.forms[0].CarrierVol[i].checked = true;
						}
					}
				  form.carriervol.value = form.CustomVol.value;
				  form.customvol.value = form.CustomVol.value;
				}
			}			
		}

    function validate(frm)
		{
		  var message = "";
		  var ret = false;
		  var i = 0;
		  var errors = new Array();
		  
		  setHerbArray(frm);
		  		  
		  if(frm.fieldsize.value == 0)
		  {
			  message = "Please Enter a Field Size.<BR>";
			  errors[i] = message;
			  i++;
			}			
			if((frm.fieldsize.value != "") && (!isNumber(frm.fieldsize.value)))
			{
			  message = "Field Size is NOT a Valid Number.<BR>"
			  errors[i] = message;
			  i++;
			}
			
		  if(frm.tanksize.value == 0)
		  {
			  message = "Please Enter a Tank Size.<BR>";
			  errors[i] = message;
			  i++;
			}			
			if((frm.tanksize.value != "") && (!isNumber(frm.tanksize.value)))
			{
			  message = "Tank Size is NOT a Valid Number.<BR>"
			  errors[i] = message;
			  i++;
			}
					  	
			if(useCustomVol == true)
			{
			  if(frm.carriervol.value == 0)
			  {
				  message = "Please Enter an Amount for Custom Volume.<BR>";
				  errors[i] = message;
				  i++;
				}			
				if((frm.CarrierVol.value == 0) && (!isNumber(frm.carriervol.value)))
				{
				  message = "Custom Volume is NOT a Valid Number.<BR>"
				  errors[i] = message;
				  i++;
				}
			}
			
			if(frm.herbArray.length == 0)
			{
				  message = "No Herbicides Have Been Selected.<BR>";
				  errors[i] = message;
				  i++;			  
			}
			
			if(errors.length == 0)
			{
			  //everything OK
			  ret = true;
			}
			else
			{
			  var msg = "";
			  //show errors
			  for(var n = 0; n < errors.length; n++)
			  {
				  msg += errors[n];
				}			  
				document.getElementById('errMsg').innerHTML = msg;
				ret = false;
			}
			return ret;
		}
		
		function isPosInteger(inputVal)
		{
		  inputStr = inputVal.toString();
		  for(var i = 0; i < inputStr.length; i++)
		  {
			  var oneChar = inputStr.charAt(i);
			  if(oneChar < "0" || oneChar > "9")
			  	return false;
			}
			return true;
		}
		
		function isNumber(inputVal)
		{
		  oneDecimal = false;
		  inputStr = inputVal.toString();
		  for(var i = 0; i < inputStr.length; i++)
		  {
			  var oneChar = inputStr.charAt(i);
			  if(i == 0 && oneChar == "-")
			  {
				  continue;
				}
				if(oneChar == "." && !oneDecimal)
				{
				  oneDecimal = true;
				  continue;
				}
				if(oneChar < "0" || oneChar > "9")
				{
				  return false;
				}
			}
			return true;
		}
		
		// open a new window called msgWindow
		// which will display a popup for
		// a suggested Herbicide to add
		function windowOpener()
		{
			msgWindow=window.open("","displayWindow","width=400,height=300")
		  msgWindow.focus();	// bring opened window to front
		  msgWindow.document.write("<HTML><HEAD><TITLE>Add a Herbicide</TITLE></HEAD>")
		  msgWindow.document.write("<BODY bgcolor='#FFFFF0'>")
			msgWindow.document.write("You may enter a suggested Herbicide in the box below.  Your suggestion will be sent to the database administrator to be added to the Herbicide list.<BR><BR>")
			msgWindow.document.write("We reserve the right to limit the compounds added to the database. Only valid Herbicides Registered in the United States will be accepted. Also, due to the enormous number of available adjuvents, we will only list 'generic' additives.<BR><BR>")  
      msgWindow.document.write("Thank you for your submission.<BR><BR>")
			
			msgWindow.document.write("<FORM NAME='submitForm' METHOD='POST' action='EmailHerbicide.php'><CENTER>")
			msgWindow.document.write("<input name='SuggestedHerb' type='text' value=''><BR><BR>")
			msgWindow.document.write("<input type='submit' value='Send Herbicide'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
			msgWindow.document.write("<INPUT TYPE='Button' NAME='Close_Window' value='Close this window' onclick='window.close()'>")
		
			msgWindow.document.write("</CENTER></FORM></BODY></HTML>")
		}

	-->