﻿// Function Settings()
// Parameters: none
// Return type: none
// Purpose: This is the constructor function for the Settings object type
function Settings()
{
    private:
        // local variables to get and hold return values from set functions
        var tmpApplication, tmpOrientation, tmpSeries;
        var strApplication, strOrientation, objSeries, bAutoCalc;
        tmpApplication = setApplication();
        tmpOrientation = setOrientation();
    
        // member variables:    
        strApplication = tmpApplication; // disk, sphere, plate, rod, point load
        strOrientation = tmpOrientation; // disk on end, rod off-center, etc.
        objSeries      = new Series();
        bAutoCalc      = element("cbAutoCalc").checked; // bool
    
    // member functions:
    public:
        this.getApplication = function(){ return strApplication;};
        this.getOrientation = function(){ return strOrientation;};
        this.getSeries      = function(){ return objSeries;};
        this.getAutoCalc    = function(){ return bAutoCalc;};
        this.getChecked     = objSeries.getChecked;

}

var sOrientation;
var App2sOrientation;

function getOrientation(col)
{
    var or;
    if(col == "App2")
        or = App2sOrientation;
    else
        or = sOrientation; 
    if (or.substr(0,4) == "App2")
        or = or.substr(4);
        
    var retVal;       
    
    if (or == "divDiskOnCenter")
    {
        retVal = "R1";
    }
    else if (or == "divDiskEndOnCenter")
    {
        retVal = "R2";
    }
    else if (or == "divSphere")
    {
        retVal = "R3";
    }
    else if (or == "divPlateOnCenter")
    {
        retVal = "R4";
    }
    else if (or == "divRodOnCenter")
    {
        retVal = "R5";
    }
    else if (or == "divPointLoad")
    {
        retVal = "R6";
    }
    else if (or == "divPlateOffCenter")
    {
        retVal = "R7";
    }    
    
    else if (or == "divRodOffCenter")
    {
        retVal = "R8";
    }
    
    
    else
    {
        retVal = "unknown";
    }
    return retVal;
}

    
    
/// Function setApplication()
/// Parameters: none
/// Return type: string
/// Purpose: Updates current unit application data- gathers info from leftCol radio buttons
function setApplication()
{// disk, sphere, plate, rod, point load
    var sApplication;
    
    var rbDisk, rbSphere, rbPlate, rbRod, rbPointLoad;
    rbDisk = element("rbDisk");
    rbSphere = element("rbSphere");
    rbPlate = element("rbPlate");
    rbRod = element("rbRod");
    rbPointLoad = element("rbPointLoad");
    
    if (rbDisk.checked)
    {
        sApplication = "Disk";
    }   
    else if (rbSphere.checked)
    {
        sApplication = "Sphere";
    }
    else if (rbPlate.checked)
    {
        sApplication = "Plate";
    }
    else if (rbRod.checked)
    {
        sApplication = "Rod";
    }
    else if (rbPointLoad.checked)
    {
        sApplication = "PointLoad";
    }   
    else
    {
        sApplication = "unknown";
    }   
    return sApplication;
}

/// Function setOrientation()
/// Parameters: none
/// Return type: string
/// Purpose: Updates current unit orientation data- gathers info from leftCol radio buttons
function setOrientation(clicked, col)
{
    // var sOrientation;
    
    if (col == "App2")
        App2sOrientation = clicked;
    else
        sOrientation = clicked;
        
    // need to tell centerCol that it needs to display different input fields
    selectedOrientation(clicked);
    
    InputChanged();
    
    return clicked;
}

/// Function getSeries()
/// Parameters: none
/// Return type: none
/// Purpose: Updates active series data- gathers info from leftCol checkboxes
function getSeries()
{    
    var objSeries;
    objSeries = new Series();
    
    return objSeries;
}


function setUOM(col)
{
    
    var rbMetricInputs;
    if ((compMode) && (col == ""))
    {       
        rbMetricInputs = element("rbMetricInputs");
    }
    else
        rbMetricInputs = element(col + "rbMetricInputs");
     
//    // inputs:
    element(col + "spnUCAOR").SetMetric(rbMetricInputs.checked) ;
    element(col + "spnUCRotTime").SetMetric(rbMetricInputs.checked) ;
    element(col + "spnUCPressure").SetMetric(rbMetricInputs.checked) ;
    element(col + "spnUCTSF").SetMetric(rbMetricInputs.checked) ;
    element(col + "spnUCFTL").SetMetric(rbMetricInputs.checked) ;
    element(col + "spnUCRadius").SetMetric(rbMetricInputs.checked) ;
    element(col + "spnUCShortLength").SetMetric(rbMetricInputs.checked) ;
    element(col + "spnUCLength").SetMetric(rbMetricInputs.checked) ;
    element(col + "spnUCHeight").SetMetric(rbMetricInputs.checked) ;    
    element(col + "spnUCShortLoad").SetMetric(rbMetricInputs.checked) ; 
    element(col + "spnUCLoad").SetMetric(rbMetricInputs.checked) ; 
    element(col + "spnUCInertiaAdd").SetMetric(rbMetricInputs.checked) ; 
    element(col + "spnUCTorqueAdd").SetMetric(rbMetricInputs.checked) ;     
    element(col + "spnUCCycleRate").SetMetric(rbMetricInputs.checked) ; 
    
 if ((compMode) && (col == ""))
    {
        col = "CompMode";       
    }
    element(col + "spnUCInertia").SetMetric(rbMetricInputs.checked) ; 
    element(col + "spnUCTotalInertia").SetMetric(rbMetricInputs.checked);
    element(col + "spnUCReqTorque").SetMetric(rbMetricInputs.checked) ; 
    element(col + "spnUCTotalReqTorque").SetMetric(rbMetricInputs.checked) ; 
    element(col + "spnUCPeakVelocity").SetMetric(rbMetricInputs.checked) ; 
    element(col + "spnUCAcceleration").SetMetric(rbMetricInputs.checked) ; 
    element(col + "spnUCKineticEnergy").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCBacklash").SetMetric(rbMetricInputs.checked) ; 
//    
//    element(col + "spnUCAxialBearingCapacity").SetMetric(rbMetricInputs.checked) ;     
//    element(col + "spnUCRadialBearingCapacity").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCExpectedBacklash").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCRotationalTolerancePlus").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCRotationalToleranceMinus").SetMetric(rbMetricInputs.checked) ;     
//   // element("spnUCBreakawayPressure").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCApproxTorqueOutput").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCDeviceWeight").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCCv").SetMetric(rbMetricInputs.checked) ;     
//    element(col + "spnUCSCFM").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCPlainUnitKe").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCPlainUnitFastestRotation").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCShockpadKe").SetMetric(rbMetricInputs.checked) ;     
//    element(col + "spnUCShockpadFastestRotation").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCCushionKe").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCCushionFastestRotation").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCShockAbsorberKe").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCShockAbsorberFastestRotation").SetMetric(rbMetricInputs.checked) ; 
//    element(col + "spnUCTemperature").SetMetric(rbMetricInputs.checked) ;
    
   // InputChanged();
    return;
}


