    function WB_ValidateInput()
    {
      with (document.WBCalc)
      {
        return !(isNaN(Number(frontWeight.value))  ||
                 isNaN(Number(rearWeight.value))   ||
                 isNaN(Number(fuelWeight.value))   ||
                 isNaN(Number(baggageWeight.value)));
      }
    }

    function WB_Plot(weight, moment)
    {
      // Left-margin on the graph is 65 pixels...
      

var x = Math.round(65 + ((moment - 45000) / 10000) * 80) - 16;
      
var y = 357 - Math.round(((weight - 1500) / 100) * 32) - 16;

	  
with (document.images.crossHairImage.style)
	  
{

	    
left = x + 'px';
	 top  = y + 'px';
	   	
visibility = "visible";

	  
}
    }

    function WB_Calculate()
    
{
      with (document.WBCalc)
      {
        totalWeight.value = WB_ValidateInput() ?
          (Number(emptyWeight.value) +
           Number(frontWeight.value) +
           Number(rearWeight.value)  +
           Number(fuelWeight.value)  +
           Number(baggageWeight.value)).toString() : "???";

        emptyMoment.value =
          (Math.round(Number(emptyWeight.value)   * Number(emptyLever.value))).toString();
        frontMoment.value =
          (Math.round(Number(frontWeight.value)   * Number(frontLever.value))).toString();
        
rearMoment.value =
          (Math.round(Number(rearWeight.value)    * Number(rearLever.value))).toString();
        fuelMoment.value =
          (Math.round(Number(fuelWeight.value)    * Number(fuelLever.value))).toString();
        baggageMoment.value =
          (Math.round(Number(baggageWeight.value) * Number(baggageLever.value))).toString();

        totalMoment.value =
          (Number(emptyMoment.value) +
           Number(frontMoment.value) +
           Number(rearMoment.value)  +
           Number(fuelMoment.value)  +
           Number(baggageMoment.value)).toString();

        

// Show the crosshair on the graph...
        
WB_Plot(Number(totalWeight.value), Number(totalMoment.value));
      }
    }

    function WB_Reset()
    {
      with (document.WBCalc)
      
{
        

// Set the fields to their default values...
        
emptyWeight.value   = "1489";
        
frontWeight.value   = "";
        
rearWeight.value    = "";
        
fuelWeight.value    = "240";  

// Full fuel by default
        baggageWeight.value = "";

        
emptyLever.value    = "39.74";
        
frontLever.value    = "34.00";
        
rearLever.value     = "73.00";
        
fuelLever.value     = "48.00";
        
baggageLever.value  = "95.00";
      
}

      

// Hide the crosshair on the graph...

//      document.images.crossHairImage.style.visibility = "hidden";

      
// Calculate based on empty values...
      
WB_Calculate();
    
}

