<!--

//  -----  Conversion functions  -----
        function cuin_calc(){
            document.forms.cctocu.cuin_res.value =  Math.round((document.forms.cctocu.cc.value * .06102)*100)/100;  
        }        
        function cucc_calc(){
            document.forms.cutocc.cc2.value =  Math.round((document.forms.cutocc.cuin_res2.value * 16.39)*100)/100;
        }
                       
                   
        function gal_calc(){
            document.forms.ltog.gal_res.value =  Math.round((document.forms.ltog.lt.value * .2642)*100)/100; 
        }           
        function lt_calc(){
            document.forms.gtol.lt2.value =  Math.round((document.forms.gtol.gal_res2.value * 3.785)*100)/100;
        }
 
       function in_calc(){
            document.forms.ctoi.in_res.value =  Math.round((document.forms.ctoi.cm.value * 0.3937008)*100)/100;
        }
 
       function cm_calc(){
            document.forms.itoc.cm_res.value =  Math.round((document.forms.itoc.in2.value * 2.54)*100)/100;
        }
        
        
        function psi_calc(){
            document.forms.bartopsi.psi_res.value =  Math.round((document.forms.bartopsi.bar.value * 14.5)*10)/10;
        } 
                      
        function bar_calc(){
            document.forms.psitobar.bar_res.value =  Math.round((document.forms.psitobar.psi.value * .06896)*10)/10;
        }
 
 
        function power_calc() {
            var fromto =  document.forms.powerconv.pin.value + document.forms.powerconv.pout.value;    
            var conv = [];
            conv[11] = 1;
            conv[12] = 0.0003926652;
            conv[13] = 0.0002928104;
            conv[22] = 1;
            conv[21] = 2546.699;
            conv[23] = 0.7456999;
            conv[33] = 1;
            conv[31] = 3415.179;
            conv[32] = 1.341022;             
            
            document.forms.powerconv.powerto.value =  Math.round((document.forms.powerconv.pwfrom.value * conv[fromto])*100)/100;
        }
      
                
        function lbin_calc(){
            document.forms.nmtolbin.lbin_res.value =  Math.round((document.forms.nmtolbin.nm.value * 8.85075)*100)/100;
        }                
        function nm_calc(){
            document.forms.lbintonm.nm_res.value =  Math.round((document.forms.lbintonm.lbin.value * .1129848)*100)/100;
        }
        
                        
        function lbft_calc(){
            document.forms.ntolbft.lbft_res.value =  Math.round((document.forms.ntolbft.n.value * 0.2248089)*100)/100;
        }                
        function n_calc(){
            document.forms.lbftton.n_res.value =  Math.round((document.forms.lbftton.lbft.value * 4.448222)*100)/100;
        }
        
                        
        function visc(){
            sus = document.forms.viscosity1.sus.value;
            if(sus > 32 && sus <= 100){
                document.forms.viscosity1.cs_res.value =  Math.round(((.2253 * sus) - (194.4 / sus))*10)/10;
                }else{
                if(sus >= 100 && sus <= 240){
                    document.forms.viscosity1.cs_res.value =  Math.round(((.2193 * sus) - (134.6 / sus))*10)/10;
                    }else{
                    if(sus > 240){
                        document.forms.viscosity1.cs_res.value =  Math.round((sus / 4.635)*10)/10;
                        }
                    }
                }
        }         
                       
        function visc2(){
            cs = document.forms.viscosity2.cs.value;
            if(cs > 20.5){
                document.forms.viscosity2.sus_res.value =  Math.round(((Math.sqrt((cs*cs)+118.8)+1*cs)*2.272 )*10)/10;
                }else{
                document.forms.viscosity2.sus_res.value =  Math.round(((Math.sqrt((cs*cs)+176.28)+1*cs)*2.212 )*10)/10;
                }
        }     
                    

        
                
        function fs_calc(){
            document.forms.cstofs.fs_res.value =  Math.round((document.forms.cstofs.cs.value * 0.0328084)*100)/100;
        }                     
        
        function cs_calc(){
            document.forms.fstocs.cs_res.value =  Math.round((document.forms.fstocs.fs.value * 30.48)*10)/10;
        }
            

        function heate_calc() {
            var fromto =  document.forms.heateconv.pin.value + document.forms.heateconv.pout.value;    
            var conv = [];
            conv[11] = 1;
            conv[12] = 0.0003926652;
            conv[13] = 0.0002930711;
            conv[14] = 1.055056;
            conv[22] = 1;
            conv[21] = 2546.699;
            conv[23] = 0.7456999;
            conv[24] = 2684.52;
            conv[33] = 1;
            conv[31] = 3415.179;
            conv[32] = 1.341022;
            conv[34] = 3600;
            conv[44] = 1;
            conv[41] = 0.9478171;
            conv[42] = 0.0003725061;
            conv[43] = 0.0002777778;             
            
            document.forms.heateconv.powerto.value =  Math.round((document.forms.heateconv.pwfrom.value * conv[fromto])*100)/100;
        }

        
                
        function ftemp_calc(){
            document.forms.ctof.ftemp_res.value =  Math.round(((document.forms.ctof.ctemp.value * 9 / 5) + (1*32))*10)/10;
        }                     
        
        function ctemp_calc(){
            document.forms.ftoc.ctemp_res.value =  Math.round(((document.forms.ftoc.ftemp.value - 32) / 9 * 5)*10)/10;
        }                                   
        
               
        //  -----  Formula functions  -----       
        
        function pf_formu(){  
            var flow = document.forms.pumpflow.pf_gpm.value;
            var rpm = document.forms.pumpflow.pf_rpm.value;
            var disp = document.forms.pumpflow.pf_disp.value;
            
            if (flow == '' && rpm > 0 && disp > 0){
                document.forms.pumpflow.pf_gpm.value = Math.round(((rpm * disp)/231)*100)/100;
                }else{
                    if (flow > 0 && rpm > 0 && disp == ''){
                        document.forms.pumpflow.pf_disp.value = Math.round(((flow * 231)/rpm)*100)/100;
                        }else{
                            if (flow > 0 && rpm == '' && disp > 0){
                                document.forms.pumpflow.pf_rpm.value = Math.round(((flow * 231) / disp)*100)/100;
                                }else{
                                    alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                                }
                        }
                } 
        }
        
        function hpf_formu(){              
            var hp = document.forms.hp_form.hpf_hp.value;
            var psi = document.forms.hp_form.hpf_psi.value;
            var gpm = document.forms.hp_form.hpf_gpm.value;
            var eff = document.forms.hp_form.hpf_eff.value;
            
            if (hp == '' && psi > 0 && gpm > 0 && eff > 0){
                document.forms.hp_form.hpf_hp.value = Math.round((psi * gpm)/(1714*(eff/100))*100)/100;
                }else{
                    if (hp > 0 && psi == '' && gpm > 0 && eff > 0){
                        document.forms.hp_form.hpf_psi.value = Math.round(((hp * (1714*(eff/100)))/gpm)*10)/10;
                        }else{
                            if (hp > 0 && psi > 0 && gpm == '' && eff > 0){
                                document.forms.hp_form.hpf_gpm.value = Math.round(((hp * (1714*(eff/100)))/psi)*100)/100;
                                }else{
                                    if (hp > 0 && psi > 0 && gpm >  0 && eff == ''){
                                        document.forms.hp_form.hpf_eff.value = Math.round((((psi * gpm / 1714) / hp) * 100)*100)/100;
                                        }else{
                                            alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                                        }
                                }
                        }
                }
        }
        
        function t1f_formu(){              
            var tq = document.forms.torque1.t1f_tq.value;
            var psi = document.forms.torque1.t1f_psi.value;
            var disp = document.forms.torque1.t1f_disp.value;
            
            if (tq == '' && psi > 0 && disp > 0){
                document.forms.torque1.t1f_tq.value = Math.round(((psi * disp)/6.28)*100)/100;
                }else{
                    if (tq > 0 && psi == '' && disp > 0){
                        document.forms.torque1.t1f_psi.value = Math.round(((tq * 6.28)/disp)*10)/10;
                        }else{
                            if (tq > 0 && psi > 0 && disp == ''){
                                document.forms.torque1.t1f_disp.value = Math.round(((tq * 6.28)/psi)*100)/100;
                                }else{
                                    alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                                }
                        }
                }
        }
        
        function t2f_formu(){              
            var tq = document.forms.torque2.t2f_tq.value;
            var hp = document.forms.torque2.t2f_hp.value;
            var rpm = document.forms.torque2.t2f_rpm.value;
            
            if (tq == '' && hp > 0 && rpm > 0){
                document.forms.torque2.t2f_tq.value = Math.round(((hp * 63025)/rpm)*100)/100;
                }else{
                    if (tq > 0 && hp == '' && rpm > 0){
                        document.forms.torque2.t2f_hp.value = Math.round(((tq * rpm)/63025)*10)/10;
                        }else{
                            if (tq > 0 && hp > 0 && rpm == ''){
                                document.forms.torque2.t2f_rpm.value = Math.round((hp * 63025)/tq);
                                }else{
                                    alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                                }
                        }
                }
        }
        
        function cpabl_formu(){              
            var a = document.forms.cylarea_bl.cpa1_a.value;
            var d = document.forms.cylarea_bl.cpa1_d.value;
            if (a == '' && d > 0){
                document.forms.cylarea_bl.cpa1_a.value = Math.round((Math.pow(d,2) * .7854)*100)/100;
                }else{
                    if (a > 0 && d == ''){
                        document.forms.cylarea_bl.cpa1_d.value = Math.round(Math.sqrt((a / .7854))*100)/100;
                        }else{ 
                                alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                        }
                }
        }
        
        function cpard_formu(){              
            var a = document.forms.cylarea_rd.cpa2_a.value;
            var d = document.forms.cylarea_rd.cpa2_d.value;
            var r = document.forms.cylarea_rd.cpa2_r.value;
            
            if (a == '' && d > 0 && r > 0){
                document.forms.cylarea_rd.cpa2_a.value = Math.round(((Math.pow(d,2) * .7854) - (Math.pow(r,2) * .7854))*100)/100;
                }else{
                    if (a > 0 && d == '' && r > 0){
                        document.forms.cylarea_rd.cpa2_d.value = Math.round(Math.sqrt(((Math.pow(r,2) * .7854) + (a * 1)) / .7854)*100)/100;
                        }else{
                            if (a > 0 && d > 0 && r == ''){
                                document.forms.cylarea_rd.cpa2_r.value = Math.round(Math.sqrt(((Math.pow(d,2) * .7854) - (a * 1)) / .7854)*100)/100;
                                    }else{  
                                        alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                                    }
                        }
                }
        }
        
        function cylforce_formu(){              
            var f = document.forms.cylforce.cf_f.value;
            var p = document.forms.cylforce.cf_p.value;
            var a = document.forms.cylforce.cf_a.value;
            
            if (f == '' && p > 0 && a > 0){
                document.forms.cylforce.cf_f.value = Math.round((p*a)*100)/100;
                }else{
                    if (f > 0 && p == '' && a > 0){
                        document.forms.cylforce.cf_p.value = Math.round((f / a)*100)/100;
                        }else{
                            if (f > 0 && p > 0 && a == ''){
                                document.forms.cylforce.cf_a.value = Math.round((f / p)*100)/100;
                                    }else{  
                                        alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                                    }
                        }
                }
        }
        
        function cylflow_formu(){              
            var f = document.forms.cylflow.cfl_f.value;
            var a = document.forms.cylflow.cfl_a.value;
            var s = document.forms.cylflow.cfl_st.value;
            var t = document.forms.cylflow.cfl_t.value;
            
            if (f == '' && a > 0 && s > 0 && t > 0){
                document.forms.cylflow.cfl_f.value = Math.round(((a * s * 60) / (t * 231))*100)/100;
                }else{
                    if (f > 0 && a == '' && s > 0 && t > 0){
                        document.forms.cylflow.cfl_a.value = Math.round((f / (s * 60 / (t * 231)))*100)/100;
                        }else{
                            if (f > 0 && a > 0 && s == '' && t > 0){
                                document.forms.cylflow.cfl_st.value = Math.round((f / (a * 60 / (t * 231)))*100)/100;
                                    }else{
                                        if (f > 0 && a > 0 && s > 0 && t == ''){
                                            document.forms.cylflow.cfl_t.value = Math.round(((a * 60 * s / 231) / f)*100)/100;
                                                }else{  
                                                    alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                                                }
                                    }
                        }
                }
        }
        
        function cylvol_formu(){              
            var v = document.forms.cylvol.cv_v.value;
            var a = document.forms.cylvol.cv_a.value;
            var s = document.forms.cylvol.cv_s.value;
            
            if (v == '' && a > 0 && s > 0){
                document.forms.cylvol.cv_v.value = Math.round(((a * s) / 231)*100)/100;
                }else{
                    if (v > 0 && a == '' && s > 0){
                        document.forms.cylvol.cv_a.value = Math.round((v * 231 / s)*100)/100;
                        }else{
                            if (v > 0 && a > 0 && s == ''){
                                document.forms.cylvol.cv_s.value = Math.round((v * 231 / a)*100)/100;
                                    }else{  
                                        alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                                    }
                        }
                }
        }

        
        function pressloss_formu(){              
            var p = document.forms.pressloss.psift.value;
            var v = document.forms.pressloss.pl_vc.value;
            var f = document.forms.pressloss.pl_f.value;
            var d = document.forms.pressloss.pl_id.value;
            
            if (p == '' && v > 0 && f > 0 && d > 0){
                document.forms.pressloss.psift.value = Math.round((v * f) / (18300 * Math.pow(d,4))*1000)/1000;
                }else{
                    if (p > 0 && v == '' && f > 0 && d > 0){
                        document.forms.pressloss.pl_vc.value = Math.round((18300 * Math.pow(d,4) * p / f)*100)/100;
                        }else{
                            if (p > 0 && v > 0 && f == '' && d > 0){
                                document.forms.pressloss.pl_f.value = Math.round((18300 * Math.pow(d,4) * p / v)*100)/100;
                                    }else{
                                        if (p > 0 && v > 0 && f > 0 && d == ''){
                                            document.forms.pressloss.pl_id.value = Math.round(Math.pow((v * f / p / 18300),1/4)*100)/100;
                                                }else{  
                                                    alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");
                                                }
                                    }            
                        }
                }
        }                                    
        
        function oilvelocity_formu(){
            var v = document.forms.oilvelocity.oilv.value;
            var f = document.forms.oilvelocity.ov_f.value;
            var d = document.forms.oilvelocity.ov_id.value;
            
            if (v == '' && f > 0 && d > 0){
                document.forms.oilvelocity.oilv.value = Math.round((f * .3208) / (Math.pow(d,2) * .7854)*1000)/1000;
                }else{
                    if (v > 0 && f == '' && d > 0){
                        document.forms.oilvelocity.ov_f.value = Math.round(((Math.pow(d,2) * .7854 * v) / .3208)*100)/100;
                        }else{
                            if (v > 0 && f > 0 && d == ''){
                                document.forms.oilvelocity.ov_id.value = Math.round(Math.sqrt((f * .3208 / .7854 / v))*100)/100;
                                    }else{  
                                        alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");                  
                                    }            
                        }
                }
        }
           
    

        function is_numeric (mixed_var) {
            return (typeof(mixed_var) === 'number' || typeof(mixed_var) === 'string') && mixed_var !== '' && !isNaN(mixed_var);
        }
        
        function rescool_formu(){
            var h = document.forms.rescool.rc_BTU.value;
            var a = document.forms.rescool.rc_a.value;
            var rt = document.forms.rescool.rc_rt.value;
            var at = document.forms.rescool.rc_at.value;
            
            if (h == '' && a > 0 && is_numeric(rt) && is_numeric(at)){
                document.forms.rescool.rc_BTU.value = Math.round((2 * a * (rt-at))*10)/10;
                }else{
                    if (h >= 0 && a == '' && is_numeric(rt) && is_numeric(at)){
                        document.forms.rescool.rc_a.value = Math.round((h / (2 * (rt-at)))*100)/100;
                        }else{
                            if (h >= 0 && a > 0 && rt == '' && at != ''){
                                document.forms.rescool.rc_rt.value = Math.round(((h / (2 * a)) + (at * 1))*10)/10;
                                    }else{                                    
                                        if (h >= 0 && a > 0 && rt != '' && at == ''){
                                            document.forms.rescool.rc_at.value = Math.round((rt - (h / (2 * a)))*10)/10;
                                                }else{  
                                                    alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");                  
                                                }
                                    }      
                        }                  
                }
        }                                   
        
        function heatunused_formu(){
            var h = document.forms.heatunused.hu_BTU.value;
            var f = document.forms.heatunused.hu_GPM.value;
            var p = document.forms.heatunused.hu_PSI.value;
            
            if (h == '' && f > 0 && p > 0){
                document.forms.heatunused.hu_BTU.value = Math.round((f * 1.485 * p)*100)/100;
                }else{
                    if (h >= 0 && f == '' && p > 0){
                        document.forms.heatunused.hu_GPM.value = Math.round((h / (1.485 * p))*100)/100;
                        }else{
                            if (h >= 0 && f > 0 && p == ''){
                                document.forms.heatunused.hu_PSI.value = Math.round((h / (1.485 * f))*10)/10;
                                    }else{  
                                        alert("Leave only one field blank and use the \"Calculate\" button to find it's result."); 
                                    }      
                        }                  
                }
        }
        
        function heatcap_formu(){
            var h = document.forms.heatcap.hc_btu.value;
            var f = document.forms.heatcap.hc_gpm.value;
            var pt = document.forms.heatcap.hc_pt.value;
            var rt = document.forms.heatcap.hc_rt.value;
            
            if (h == '' && f > 0 && pt > 0 && rt > 0){
                document.forms.heatcap.hc_btu.value = Math.round((f * 210 * (rt-pt))*100)/100;
                }else{
                    if (h >= 0 && f == '' && pt > 0 && rt > 0){
                        document.forms.heatcap.hc_gpm.value = Math.round((h / (210 * (rt-pt)))*100)/100;
                        }else{
                            if (h >= 0 && f > 0 && pt == '' && rt > 0){
                                document.forms.heatcap.hc_pt.value = Math.round((rt - (h / (210 * f)))*10)/10;
                                    }else{                                    
                                        if (h >= 0 && f > 0 && pt > 0 && rt == ''){
                                            document.forms.heatcap.hc_rt.value = Math.round(((pt * 1) + (h / (210 * f)))*10)/10;
                                                }else{  
                                                    alert("Leave only one field blank and use the \"Calculate\" button to find it's result.");                  
                                                }
                                    }      
                        }                  
                }
        }                                    
        
        function heatreq_formu(){
            var h = document.forms.heatreq.hr_kwh.value;
            var lb = document.forms.heatreq.hr_lb.value;
            var sh = document.forms.heatreq.hr_sh.value;
            var bt = document.forms.heatreq.hr_bt.value;
            var et = document.forms.heatreq.hr_et.value;
            var test = et - bt;
            
            if (test < 0 && et != ''){
                alert("The beginning temperature must be less than or equal to the ending temperature.");
                return false;
            }
            
            if (h == '' && lb > 0 && sh > 0 && bt > 0 && et > 0){
                document.forms.heatreq.hr_kwh.value = Math.round((lb * sh * (et - bt) / 3413)*100)/100;
                }else{
                    if (h >= 0 && lb == '' && sh > 0 && bt > 0 && et > 0){
                        document.forms.heatreq.hr_lb.value = Math.round(h / (sh * ((et - bt) / 3413))*100)/100;
                        }else{
                            if (h >= 0 && lb > 0 && sh == '' && bt > 0 && et > 0){
                                document.forms.heatreq.hr_sh.value = Math.round((h / (lb * (et - bt) / 3413))*100)/100;
                                    }else{
                                        if (h >= 0 && lb > 0 && sh > 0 && bt == '' && et > 0){
                                            document.forms.heatreq.hr_bt.value = Math.round((et - h / (lb * sh  / 3413))*10)/10;
                                                }else{
                                                    if (h >= 0 && lb > 0 && sh > 0 && bt > 0 && et == ''){
                                                        document.forms.heatreq.hr_et.value = Math.round(((1 * bt) + h / (lb * sh / 3413))*10)/10;
                                                            }else{  
                                                                alert("Leave only one field blank and use the \"Calculate\" button to find it's result."); 
                                                            }
                                                }
                                    }      
                        }                  
                }
        }                                   
                                                
                                                
                                                

    function showhideitems(myitem, mybutton){
        var myitem=document.getElementById(myitem);  
        var mybutton=document.getElementById(mybutton);
        if (myitem.style.display != "none"){
            myitem.style.display="none";  
            swapimage(mybutton,"hide");
        }
        else{
            myitem.style.display="block";
            swapimage(mybutton,"show");
        }
    }
                                            
    function swapimage(myimage, state){
        if(state=="show"){
            myimage.src="images/resources/show.png";
        }
        else{
            myimage.src="images/resources/hide.png";
        }
    }                                                
                                                 

    function showhideitems2(myitem){
        var myitem=document.getElementById(myitem);
        if (myitem.style.display != "none"){
            myitem.style.display="none";    
        }
        else{
            myitem.style.display="block";       
        }
    }    

-->
