﻿//////////////////////////////////////////////////////////////////////////////////////////////////
// John Warner (warnerj5000@gmail.com)
// PHD, Inc 2007
// Purpose: This javascript file handles the RotCenterCol.html file.
//          RotCenterCol.html contains the inputs for the rotary sizing.
//          Units of measure, Orientation, Positions, Power, and the various inputs.
//          All DHTML for the center column of rotary.html will be handled 
//          within this javascript file.
//////////////////////////////////////////////////////////////////////////////////////////////////

//var length,
//    height,
//    load,
//    shortLength,
//    shortLoad,
//    longLength,
//    longLoad;
//    
//function setupInputLabels()
//{
//    length = element(col + "lblLength").innerHTML;
//    height = element(col + "lblHeight").innerHTML;
//    load = element(col + "lblLoad").innerHTML;
//}

function inputUCSetup(colName)
{
    var pressureLimit = element("rbPneumatic").checked ? 150 : 1500;
    SetupUC("imgAORMinus", "txtAOR", "imgAORPlus", "spnUCAOR", "angle", element("hidDegree").value, "90", 1, 5.0, 4, 0, Infinity, false) ;    
    SetupUC("imgRotTimeMinus", "txtRotTime", "imgRotTimePlus", "spnUCRotTime", "time", element("hidSec").value, "0.5", 1, 0.1, 4, 0, Infinity, false) ;
    SetupUC("imgPressureMinus", "txtPressure", "imgPressurePlus", "spnUCPressure", "pressure", element("hidPSI").value, "87", 1, 1, 4, 0, pressureLimit, false) ;
    SetupUC("imgTSFMinus", "txtTSF", "imgTSFPlus", "spnUCTSF", "", "", "2", 1, 1, 4, 1, Infinity, false) ;
    SetupUC("imgFTLMinus", "txtFTL", "imgFTLPlus", "spnUCFTL", "length", element("hidIn").value, "0", 1, 0.5, 4, 0, Infinity, false) ;
    SetupUC("imgRadiusMinus", "txtRadius", "imgRadiusPlus", "spnUCRadius", "length", element("hidIn").value, "0.1", 1, 1, 4, 0, Infinity, false) ;
    SetupUC("imgShortLengthMinus", "txtShortLength", "imgShortLengthPlus", "spnUCShortLength", "length", element("hidIn").value, "0.1", 1, 1, 4, 0, Infinity, false) ;
    SetupUC("imgLengthMinus", "txtLength", "imgLengthPlus", "spnUCLength", "length", element("hidIn").value, "0.1", 1, 1, 4, 0, Infinity, false) ;
    SetupUC("imgHeightMinus", "txtHeight", "imgHeightPlus", "spnUCHeight", "length", element("hidIn").value, "0.1", 1, 1, 4, 0, Infinity, false) ;
    SetupUC("imgShortLoadMinus", "txtShortLoad", "imgShortLoadPlus", "spnUCShortLoad", "weight", element("hidLb").value, "0.1", 1, 1, 4, 0, Infinity, false) ;
    SetupUC("imgLoadMinus", "txtLoad", "imgLoadPlus", "spnUCLoad", "weight", element("hidLb").value, "1", 1, 1, 4, 0, Infinity, false) ;
    SetupUC("imgInertiaAddMinus", "txtInertiaAdd", "imgInertiaAddPlus", "spnUCInertiaAdd", "inertia", element("hidInLbS2").value, "0", 1, 1, 4, 0, Infinity, false) ;
    SetupUC("imgTorqueAddMinus", "txtTorqueAdd", "imgTorqueAddPlus", "spnUCTorqueAdd", "torque", element("hidInLb").value, "0", 1, 1, 4, 0, Infinity, false) ;        
    SetupUC("imgCycleRateMinus", "txtCycleRate", "imgCycleRatePlus", "spnUCCycleRate", "cyclerate", element("hidPerMin").value, "60", 1, 1, 4, 0, Infinity, false) ;        
    SetupUC("imgTemperatureMinus", "txtTemperature", "imgTemperaturePlus", "spnUCTemperature", "temperature", element("hidFahrenheit").value, "70", "F", 1, 1, -20, 180, false) ;        
    
    return;
}

function selectedOrientation(selected)
{
    var col = getColName(selected);
    var trRadius = element(col + "trRadius");
    var trLength = element(col + "trLength");
    var trShortLength = element(col + "trShortLength");
    var trShortLoad = element(col + "trShortLoad");
    var trHeight = element(col + "trHeight");
    
    var lblLength = element(col + "lblLength");
    var lblLoad = element(col + "lblLoad");
        
    if (selected == col + "divDiskOnCenter")
    {          
        element(col + "trRadius").style.visibility = "visible";        
         element(col + "trHeight").style.visibility = "hidden";
         element(col + "trLength").style.visibility = "hidden";
         element(col + "trShortLength").style.visibility = "hidden";
         element(col + "trShortLoad").style.visibility = "hidden";
         //element(col + "trRadius").style.display = "";
         element(col + "trRadius").style.display = "";
         element(col + "trHeight").style.display = "none";
         element(col + "trLength").style.display = "none";
         element(col + "trShortLength").style.display = "none";
         element(col + "trShortLoad").style.display = "none";
//         element(col + "lblLength").innerHTML = "Length";
//         element(col + "lblHeight").innerHTML = "Height (L)";
//         element(col + "lblLoad").innerHTML = "Load (Fg)";
         
         element(col + "lblLength").innerHTML = element("hidLength").value;
         element(col + "lblHeight").innerHTML = element("hidHeight").value + " (L)";
         element(col + "lblLoad").innerHTML = element("hidLoad").value + " (Fg)";
    }
    else if (selected == col + "divDiskEndOnCenter")
    {
         element(col + "trRadius").style.visibility = "visible";
         element(col + "trHeight").style.visibility = "visible";
         element(col + "trLength").style.visibility = "hidden";
         element(col + "trShortLength").style.visibility = "hidden";
         element(col + "trShortLoad").style.visibility = "hidden";
        
         //element(col + "trRadius").style.display = "";
         element(col + "trRadius").style.display = "";
         //element(col + "trHeight").style.display = "";
         element(col + "trHeight").style.display = "";
         element(col + "trLength").style.display = "none";
         element(col + "trShortLength").style.display = "none";
         element(col + "trShortLoad").style.display = "none";
//         element(col + "lblLength").innerHTML = "Length";
//         element(col + "lblHeight").innerHTML = "Height (L)";
//         element(col + "lblLoad").innerHTML = "Load (Fg)";
         
         element(col + "lblLength").innerHTML = element("hidLength").value;
         element(col + "lblHeight").innerHTML = element("hidHeight").value + " (L)";
         element(col + "lblLoad").innerHTML = element("hidLoad").value + " (Fg)";
        
    }
    else if (selected == col + "divSphere")
    {
         element(col + "trRadius").style.visibility = "visible";
         element(col + "trHeight").style.visibility = "hidden";        
         element(col + "trShortLength").style.visibility = "hidden";
         element(col + "trShortLoad").style.visibility = "hidden";
        
         //element(col + "trRadius").style.display = "";
         element(col + "trRadius").style.display = "";
         element(col + "trHeight").style.display = "none";       
         element(col + "trShortLength").style.display = "none";
         element(col + "trShortLoad").style.display = "none";
        
         element(col + "trLength").style.visibility = "hidden";
         element(col + "trLength").style.display = "none";
        
//         element(col + "lblLength").innerHTML = "Length";
//         element(col + "lblLoad").innerHTML = "Load (Fg)";
         
         element(col + "lblLength").innerHTML = element("hidLength").value;
         element(col + "lblLoad").innerHTML = element("hidLoad").value + " (Fg)";
    }   
    else if (selected == col + "divPlateOnCenter")
    {
         element(col + "trRadius").style.visibility = "hidden";
         element(col + "trHeight").style.visibility = "visible";
         element(col + "trShortLength").style.visibility = "hidden";
         element(col + "trShortLoad").style.visibility = "hidden";
        
         element(col + "trRadius").style.display = "none";
         //element(col + "trHeight").style.display = "";
         element(col + "trHeight").style.display = "";
         element(col + "trShortLength").style.display = "none";
         element(col + "trShortLoad").style.display = "none";
        
         element(col + "trLength").style.visibility = "visible";
         element(col + "trLength").style.display = "";
        
//         element(col + "lblLength").innerHTML = "Plate Length (a)";
//         element(col + "lblHeight").innerHTML = "Plate Height (b)";
//         element(col + "lblLoad").innerHTML = "Load (Fg)";
         
         element(col + "lblLength").innerHTML = element("hidPlateLength").value + " (a)";
         element(col + "lblHeight").innerHTML = element("hidPlateHeight").value + " (b)";
         element(col + "lblLoad").innerHTML = element("hidLoad").value + " (Fg)";
    }
    else if (selected == col + "divRodOnCenter")
    {   
         element(col + "trRadius").style.visibility = "visible";
         element(col + "trHeight").style.visibility = "hidden";
         element(col + "trShortLength").style.visibility = "hidden";
         element(col + "trShortLoad").style.visibility = "hidden";
        
         //element(col + "trRadius").style.display = "";
         element(col + "trRadius").style.display = "";
         element(col + "trHeight").style.display = "none";
         element(col + "trShortLength").style.display = "none";
         element(col + "trShortLoad").style.display = "none";
        
         element(col + "trLength").style.visibility = "visible";
         element(col + "trLength").style.display = "";
        
//         element(col + "lblLength").innerHTML = "Length (a)";
//         element(col + "lblLoad").innerHTML = "Load (Fg)";
         
         element(col + "lblLength").innerHTML = element("hidLength").value + " (a)";
         element(col + "lblLoad").innerHTML = element("hidLoad").value + " (Fg)";
    }
    else if (selected == col + "divPointLoad")
    {
         element(col + "trRadius").style.visibility = "hidden";
         element(col + "trHeight").style.visibility = "hidden";
         element(col + "trShortLength").style.visibility = "hidden";
         element(col + "trShortLoad").style.visibility = "hidden";
        
         element(col + "trRadius").style.display = "none";
         element(col + "trHeight").style.display = "none";
         element(col + "trShortLength").style.display = "none";
         element(col + "trShortLoad").style.display = "none";
        
         element(col + "trLength").style.visibility = "visible";
         element(col + "trLength").style.display = "";
        
//         element(col + "lblLength").innerHTML = "Length of Support (k)";
//         element(col + "lblLoad").innerHTML = "Load (Fg)";
         
         element(col + "lblLength").innerHTML = element("hidLengthSupport").value + " (k)";
         element(col + "lblLoad").innerHTML = element("hidLoad").value + " (Fg)";
         
    }
    else if (selected == col + "divPlateOffCenter")
    {
         element(col + "trRadius").style.visibility = "hidden";
         element(col + "trHeight").style.visibility = "visible";
         element(col + "trShortLength").style.visibility = "visible";
         element(col + "trShortLoad").style.visibility = "visible";
        
         element(col + "trRadius").style.display = "none";
         element(col + "trHeight").style.display = "";
         element(col + "trShortLength").style.display = "";
         element(col + "trShortLoad").style.display = "";
        
         element(col + "trLength").style.visibility = "visible";
         element(col + "trLength").style.display = "";
        
//         element(col + "lblHeight").innerHTML = "Height (c)";  
//         element(col + "lblShortLength").innerHTML ="Short Side Length (a)";
//         element(col + "lblLength").innerHTML = "Long Side Length (b)";
//         element(col + "lblShortLoad").innerHTML = "Short Side Load (Fg1)";
//         element(col + "lblLoad").innerHTML = "Long Side Load (Fg2)";
         
         element(col + "lblHeight").innerHTML = element("hidHeight").value + " (c)"; 
         element(col + "lblShortLength").innerHTML =element("hidShortLength").value + " (a)";
         element(col + "lblLength").innerHTML = element("hidLongLength").value + " (b)";
         element(col + "lblShortLoad").innerHTML = element("hidShortLoad").value + " (Fg1)";
         element(col + "lblLoad").innerHTML = element("hidLongLoad").value + " (Fg2)";
    }
    else if (selected == col + "divRodOffCenter")
    {
         element(col + "trRadius").style.visibility = "visible";
         element(col + "trHeight").style.visibility = "hidden";
         element(col + "trShortLength").style.visibility = "visible";
         element(col + "trShortLoad").style.visibility = "visible";
        
         //element(col + "trRadius").style.display = "";
         element(col + "trRadius").style.display = "";
         element(col + "trHeight").style.display = "none";
         element(col + "trShortLength").style.display = "";
         element(col + "trShortLoad").style.display = "";
        
         element(col + "trLength").style.visibility = "visible";
         element(col + "trLength").style.display = "";
        
         element(col + "lblHeight").innerHTML = "Height (c)";        
       
//         element(col + "lblShortLength").innerHTML ="Short Side Length (a)";
//         element(col + "lblLength").innerHTML = "Long Side Length (b)";
//         element(col + "lblShortLoad").innerHTML = "Short Side Load (Fg1)";
//         element(col + "lblLoad").innerHTML = "Long Side Load (Fg2)";
         
         element(col + "lblShortLoad").innerHTML = element("hidShortLoad").value + " (Fg1)";
         element(col + "lblLoad").innerHTML = element("hidLongLoad").value + " (Fg2)";
         element(col + "lblShortLength").innerHTML =element("hidShortLength").value + " (a)";
         element(col + "lblLength").innerHTML = element("hidLongLength").value + " (b)";
    }
    else
    {
         element(col + "trRadius").style.visibility = "hidden";
         element(col + "trHeight").style.visibility = "hidden";
         element(col + "trShortLength").style.visibility = "hidden";
         element(col + "trShortLoad").style.visibility = "hidden";
        
         element(col + "trRadius").style.display = "none";
         element(col + "trHeight").style.display = "none";
         element(col + "trShortLength").style.display = "none";
         element(col + "trShortLoad").style.display = "none";
        
         element(col + "trLength").style.visibility = "hidden";
         element(col + "trLength").style.display = "none";
    }
    return;
}

function centerLoad()
{
    compMode = false;    
    return;
}

function AddInertia(e)
{
   var col= getColName(Sender(e).id);
   var inert;
   var torque;
   
   if ((compMode) && (col == ""))
        col = "CompMode";
    //var col = getColName(id);
    if (col != "CompMode")
    {
        inert = (element(col + "spnUCInertiaAdd").ActualValue / element(col + "spnUCInertiaAdd").ConvFact) * element(col + "spnUCInertia").ConvFact + element(col + "spnUCInertia").ActualValue;
        torque = (element(col + "spnUCTorqueAdd").ActualValue / element(col + "spnUCTorqueAdd").ConvFact) * element(col + "spnUCReqTorque").ConvFact + element(col + "spnUCReqTorque").ActualValue;
    
        SetupUC(col + "imgInertiaAddMinus", col + "txtInertiaAdd", col + "imgInertiaAddPlus",  col + "spnUCInertiaAdd", "inertia", element(col + "spnUCInertiaAdd").Units, inert, element(col + "spnUCInertia").ConvFact, 1, 4, 0, Infinity, false) ; 
        SetupUC(col + "imgTorqueAddMinus", col + "txtTorqueAdd", col + "imgTorqueAddPlus", col + "spnUCTorqueAdd", "torque", element(col + "spnUCTorqueAdd").Units, torque, element(col + "spnUCReqTorque").ConvFact, 1, 4, 0, Infinity, false) ;
    }
    else
    {
        inert = (element("spnUCInertiaAdd").ActualValue / element("spnUCInertiaAdd").ConvFact) * element(col + "spnUCInertia").ConvFact + element(col + "spnUCInertia").ActualValue;
        torque = (element("spnUCTorqueAdd").ActualValue / element("spnUCTorqueAdd").ConvFact) * element(col + "spnUCReqTorque").ConvFact + element(col + "spnUCReqTorque").ActualValue;
    
        SetupUC("imgInertiaAddMinus", "txtInertiaAdd", "imgInertiaAddPlus",  "spnUCInertiaAdd", "inertia", element("spnUCInertiaAdd").Units, inert, element(col + "spnUCInertia").ConvFact, 1, 4, 0, Infinity, false) ; 
        SetupUC("imgTorqueAddMinus", "txtTorqueAdd", "imgTorqueAddPlus", "spnUCTorqueAdd", "torque", element("spnUCTorqueAdd").Units, torque, element(col + "spnUCReqTorque").ConvFact, 1, 4, 0, Infinity, false) ;        
    }
    
    //element(col + "trTotalInertia").style.display = "block";
    //element(col + "trTotalReqTorque").style.display = "block";
    InputChanged(e);

}

function ClearInertia(e)
{

    var col = getColName(Sender(e).id);
    if ((compMode) && (col == ""))
        col = "CompMode";
   
    if (col != "CompMode")
    {
        SetupUC(col + "imgInertiaAddMinus", col + "txtInertiaAdd", col + "imgInertiaAddPlus", col + "spnUCInertiaAdd", "inertia", element("hidInLbS2").value, "0", 1, 1, 4, 0, Infinity, false) ;
        SetupUC(col + "imgTorqueAddMinus", col + "txtTorqueAdd", col + "imgTorqueAddPlus", col + "spnUCTorqueAdd", "torque", element("hidInLb").value, "0", 1, 1, 4, 0, Infinity, false) ;   
    }
    else
    {
        SetupUC("imgInertiaAddMinus", "txtInertiaAdd", "imgInertiaAddPlus", "spnUCInertiaAdd", "inertia", element("hidInLbS2").value, "0", 1, 1, 4, 0, Infinity, false) ;
        SetupUC("imgTorqueAddMinus", "txtTorqueAdd", "imgTorqueAddPlus", "spnUCTorqueAdd", "torque", element("hidInLb").value, "0", 1, 1, 4, 0, Infinity, false) ;   
    }
    element(col + "trTotalInertia").style.display = "none";
    element(col + "trTotalReqTorque").style.display = "none";
    
    element(col + "trResultsDivider").style.display = "none";
    element(col + "trResultsDivider1").style.display = "none";
    element(col + "trResultsDivider2").style.display = "none";
    InputChanged(e);     
}