///////////////////////////////////////////////////////////////////
// Ovalpin Script Copyright (c) 2002 Jock Dempsey, anvilfire.com //
// Test error corrected 1/11/2004 - reported by Bob              //
///////////////////////////////////////////////////////////////////

function stringandpin()
    {

    var strL = 0;
    var pinD = 0;

    if ((document.ovalpin.height.value == 0) || (document.ovalpin.width.value == 0)) { return; }

    if (parseFloat(document.ovalpin.height.value) > parseFloat(document.ovalpin.width.value) ) 
        { 
        
        alert('Width must be greater than height');

        document.ovalpin.width.focus(); 
        
        return; 
                
        }

    var a = document.ovalpin.height.value / 2

    var b = document.ovalpin.width.value / 2
    
    var pinD = Math.sqrt(Math.pow(b, 2) - Math.pow(a, 2)); 

    document.ovalpin.pin_distance.value = local_round(pinD * 2);

    var strL = (2 * b) + (2 * pinD);
    
    document.ovalpin.string_length.value = local_round(strL);

    }

function local_round (aFloat)
    {
  
    var rounded = Math.round (aFloat * 1000) / 1000;

    aFloat = 0;
    
    return rounded;
    
    }
