﻿// JavaScript Document

// Basic Roof Framing Calculator

<!-- This code is not in the public domain. It is the sole property of Joseph Fusco.// -->

<!-- Begin Variable List // -->


// Input info

var bl, bw, roof_pitch, ridge_th, overhang, layout_spacing, com_mem_size, hip_val_mem_size, plate_width, roof_type, cheek_cut_type, hip_val_th, hap_type, com_raft_length, jack_diff_1, nj, nj_1, jack_prime, Ply_bev_cut_angle, Ply_cut_angle, h_s;
var ridge_depth_mem_size, sub_fas_th, sub_fas_depth, fas_th, fas_depth_mem_size, build_finish, com_add; // New * * * * * * 06 / 28 / 2008
var building_run_eft,hip_side_cut_ang_bev;// New 08/28/2009

// Square Stops for use with a framing square New*** 09/02/2009
var jack_side_cut_stop, hip_side_cut_stop1, hip_side_cut_stop_bev;
var SC_HMB_in, SC_HMA_in, SC_FMA_in, SC_FHMA_in, SC_HCL_in, SC_HCA_in; //new***** 09/25/2009 Square cuts

// Input Info for square cut tails and inch value representation.
var tail_type, sc_hmb, sc_hma, sc_fma, sc_fhma, sc_hcl, sc_hca;

// Output info
var dsf, building_run, com_plumb_angle, com_seat_angle, com_unit_length, hip_plumb_angle, hip_seat_angle, hip_unit_length, ridge_ht_unadj, ridge_ht,ridge_ht_adj, ridge_ht_pitch_adj, ridge_length, degsign = "\u00B0", inchsign = '"', Hip_drop, hip_backing_angle, build_pl_ln, hap_cut,jack_diff,Numb_of_jacks,jack_numb;

var com_raft_qty, over_hang_pro, hip_inch_rise, crq, crq_1, jack_diff_2, jack_diff_3, hip_Pro, h_run, h_rise, h_angle, hip_jack_offset, hip_jack_locator;
var total_common_length, total_hip_val_length;// NEW * * * * * 06 / 28 / 2008
var jack_side_cut_ang, hip_side_cut_ang; // **** New ****** 08/24/2009

// Array Listings

var fract = ["1/16", "1/8", "3/16", "1/4", "5/16", "3/8", "7/16", "1/2", "9/16", "5/8", "11/16", "3/4", "13/16", "7/8", "15/16", "31/32"]
var decm = [0, .0625, .125, .1875, .2500, .3125, .3750, .4375, .5, .5625, .6250, .6875, .75, .8125, .8750, .9375, 1]
var jack_rafter = new Array(24);
var jack_rafter_r = new Array(24);
plan_angle = Math.atan(1);// Default Plan angle is 45�
<!-- Get information on box // -->
function calc(form)

{
    
   // Gets roof type
   roof_type = document.Get_Info.roof_type.value;
   // Cheek roof type return if it's an Octagon or split pitch.
  if (roof_type =="O")
	{
	    alert("Oops I'm still working on that Script so you can't use this feature just yet. Thanks Joe.");
	    return false;
	}
	
  // Gets Roof Information
   // Gets building length
   bl = 12 * document.Get_Info.bl.value;
   bl = bl + (document.Get_Info.bl_inch.value * 1);
   bl = bl + (document.Get_Info.bl_fract.value * 1);
   
   // Gets building width
   bw = 12 * document.Get_Info.bw.value;
   bw = bw + (document.Get_Info.bw_inch.value * 1);
   bw = bw + (document.Get_Info.bw_fract.value * 1);
   
   if (bw > bl)
	{
		alert("Building Width should not be greater than Building Length");
		return false;
	}

   // Gets roof pitch
   roof_pitch = 1 * document.Get_Info.roof_pitch.value;
   roof_pitch = roof_pitch + (document.Get_Info.roof_pitch_inch.value * 1);
   roof_pitch = roof_pitch + (document.Get_Info.roof_pitch_fract.value * 1);

   // Gets ridge thickness
   ridge_th = 1 * document.Get_Info.ridge_th.value;
   ridge_th = ridge_th + (document.Get_Info.ridge_th_inch.value * 1);
   ridge_th = ridge_th + (document.Get_Info.ridge_th_fract.value * 1);

   // Gets ridge member size NEW * * * * * *
   ridge_depth_mem_size = (document.Get_Info.ridge_depth_mem_size.value * 1);

   // Gets Common Rafter thickness
   com_raft_th = 1 * document.Get_Info.com_raft_th.value;
   com_raft_th = com_raft_th + (document.Get_Info.com_raft_th_inch.value * 1);
   com_raft_th = com_raft_th + (document.Get_Info.com_raft_th_fract.value * 1);

   // Gets Hip / Valley thickness
   hip_val_th = 1 * document.Get_Info.hip_val_th.value;
   hip_val_th = hip_val_th + (document.Get_Info.hip_val_th_inch.value * 1);
   hip_val_th = hip_val_th + (document.Get_Info.hip_val_th_fract.value * 1);

   // Gets roof overhang measurement
   overhang = 12 * document.Get_Info.overhang.value;
   overhang = overhang + (document.Get_Info.overhang_inch.value * 1);
   overhang = overhang + (document.Get_Info.overhang_fract.value * 1);

   // Gets sub fascia thickness NEW * * * *
   sub_fas_th = 1 * document.Get_Info.sub_fas_th.value;
   sub_fas_th = sub_fas_th + (document.Get_Info.sub_fas_th_inch.value * 1);
   sub_fas_th = sub_fas_th + (document.Get_Info.sub_fas_th_fract.value * 1);
   
   // Gets sub fascia member size NEW * * *
   sub_fas_depth = (document.Get_Info.sub_fas_depth.value * 1);

   // Gets fascia thickness NEW * * * *
   fas_th = 1 * document.Get_Info.fas_th.value;
   fas_th = fas_th + (document.Get_Info.fas_th_inch.value * 1);
   fas_th = fas_th + (document.Get_Info.fas_th_fract.value * 1);

   // Gets  fascia member size NEW * * *
   fas_depth_mem_size = (document.Get_Info.fas_depth_mem_size.value * 1);

   // Gets building finishs NEW * * * *
   build_finish = 12 * document.Get_Info.build_finish.value;
   build_finish = build_finish + (document.Get_Info.build_finish_inch.value * 1);
   build_finish = build_finish + (document.Get_Info.build_finish_fract.value * 1);
   
      if (build_finish > overhang)
	{
		alert("Building finishes are great then the proposed overhang. This will result in the overhang projection to be modified to meet them.");
	}	
	
   
   // Gets roof on center spacing
   layout_spacing = (document.Get_Info.layout_spacing.value * 1);

   // Gets roof common rafter size
   com_mem_size = (document.Get_Info.com_mem_size.value * 1);

   // Gets roof framing plate width
   plate_width = (document.Get_Info.plate_width.value * 1);


   // Gets roof cheek cut type
   cheek_cut_type = document.Get_Info.cheek_cut_type.value;

   // Gets roof hap type
   hap_type = document.Get_Info.hap_type.value;
   
   // Gets roof tail cut type
   tail_type = document.Get_Info.tail_type.value;

   // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

   // Main calculations

   dsf = (bl * bw) / 144;   // deck square footage
   building_run = bw / 2;      // Calculate run
   building_run_eft = building_run + overhang - (.5*ridge_th); //Calculates the effective run. New 08/28/2009
   com_add = 6; // Set default to 6 rafters
   com_raft_qty = 0; //Set common rafter total to Zero
   
   // Common Rafter Information
   com_plumb_angle = Math.atan(roof_pitch / 12);   // Converts pitch into radians.
   com_plumb_angle1 = deg(com_plumb_angle);   // Converts Common plumb cut angle into degrees.
   com_seat_angle = 90 - com_plumb_angle1;   // Gets Common seat cut angle by subtraction.
   com_unit_length = roof_pitch / Math.sin(com_plumb_angle);   // gets unit length by use of the sin fuction.
   com_seat_angle1 = deg1(com_seat_angle);   // converts seat angle to radians.
   over_hang_pro = (overhang + build_finish) / Math.cos(com_plumb_angle);  // Changed 06 / 28 / 2008 
   
   ridge_length = (bl - bw) + ridge_th; //Get the right ridge length for double cheek cut
   
   document.Info_out.cheek_cut_type.value = "Double";
          if(cheek_cut_type == "S"){
               plan_angle = Math.atan(1);
               ridge_length = (bl - bw) + ridge_th + (ridge_th / Math.sin(plan_angle)); //Get the right ridge length for single cheek cut
               document.Info_out.cheek_cut_type.value = "Single";
            }
          
   // Check for whick roof type
          if(roof_type =="G"){
               ridge_length = (bl + over_hang_pro);
     }
     
     crq = (ridge_length / layout_spacing);
     crq_1 = crq % 1
     
     if(bl==bw){
               com_add = 4 ;
     }
     
     com_raft_qty = ((crq - crq_1) * 2) + com_add;
              
          if(roof_type =="G"){
               com_raft_qty = ((crq - crq_1) * 2) ;
     }
     
    build_pl_ln = com_mem_size / Math.sin(com_seat_angle1)   // Calculates the build plumb line 
    
    
    
    // HAP Calculations
    
   if (hap_type == "S")// check for standard 2/3 rds type
   {
      hap_cut = build_pl_ln * .666;
   }
   else
   {
      hap_cut = (build_pl_ln - (plate_width * Math.tan(com_plumb_angle)));// applies full bearing
   }

     if(roof_type =="G"){
     document.Info_out.Sel_roof_type.value = "Gable Roof";
     document.Info_out.cheek_cut_type.value = "  ";
     } 
      
    ridge_ht_unadj = ((roof_pitch * building_run) / 12);
    ridge_ht = ((roof_pitch * building_run) / 12) - ((ridge_th * .5) * Math.sin(com_plumb_angle));
    ridge_ht_pitch_adj = (ridge_th * .5) * Math.sin(com_plumb_angle);
    com_raft_length = Math.sqrt(Math.pow(ridge_ht, 2) + Math.pow(building_run - (.5 * ridge_th), 2))//
    total_common_length = com_raft_length + (over_hang_pro - (sub_fas_th + fas_th)); // New * * * *06 / 28 / 2008
    
    Ply_cut_angle = Math.atan(com_unit_length / 12);
    Ply_cut_angle = deg(Ply_cut_angle);   // Convert to degrees
    
jack_Calc()     
     
   // Hip Information
   hip_plumb_angle = Math.atan(roof_pitch / 16.97);   // Converts into radians.
   hip_plumb_angle1 = deg(hip_plumb_angle);   // Converts Hip Plumb cut angle into degrees.
   hip_seat_angle = 90 - hip_plumb_angle1;   // Gets Hip seat cut angle by subtraction.
   hip_unit_length = roof_pitch / Math.sin(hip_plumb_angle);
   Hip_drop = (roof_pitch * (.5 * hip_val_th)) / 16.97;
   hip_length = Math.sqrt(Math.pow(ridge_ht, 2) + Math.pow((building_run * Math.SQRT2), 2));
   h_s = hipShort(h_s);
   hip_length = hip_length - h_s;
   hip_Pro = ((overhang + build_finish) * Math.SQRT2) / Math.cos(hip_plumb_angle);   // Changed 06 / 28 / 2008
   total_hip_val_length = hip_length + (hip_Pro - ((sub_fas_th + fas_th) * Math.SQRT2));   // NEW * * * * * * * 06 / 28 / 2008
   hip_jack_locator = hip_Com_dif(hip_jack_locator);
   hip_jack_offset = hip_jack_locator + (.5 * (.5 * (hip_val_th * Math.SQRT2)))
   hip_inch_rise = (ridge_ht * 12) / hip_length;
   hip_backing_angle = (Math.atan(Math.sin(hip_plumb_angle)));
   hip_backing_angle = deg(hip_backing_angle);
   // Hip/Val Rafter side cut calc
   hip_side_cut_ang = Math.atan(Math.cos(hip_plumb_angle) * Math.tan(plan_angle));
   hip_side_cut_stop1 = Math.tan(hip_side_cut_ang) * 12;// Sets hip side cut stop.
   hip_side_cut_ang = deg(hip_side_cut_ang);   // Convert to degrees
   
   
   
   // Check to see if the tail cut option has been selected?
    
    document.Info_out.tail_type.value = "No";
          if(tail_type == "S"){
               document.Info_out.tail_type.value = "Yes";
               // Calculates initial tail cut angle value and inch value
               sc_hmb = Math.asin(Math.cos(com_plumb_angle) * (Math.SQRT2/2));
               SC_HMB_in = sc_hmb; // Sets inch value to the corrosponing angle value
               sc_hcl = (Math.pow(12,2)/roof_pitch);
               SC_HCL_in = sc_hcl;
               sc_hca = Math.atan(Math.SQRT2/(12/roof_pitch));
               SC_HCA_in = sc_hca;
               sc_hma = (sc_hca - hip_plumb_angle);
               SC_HMA_in = sc_hma
               sc_fma = Math.atan(Math.sin(com_plumb_angle));
               SC_FMA_in = sc_fma;
               sc_fhma = Math.atan(Math.cos(com_plumb_angle));
               SC_FHMA_in = sc_fhma;
              
            }
     
gen_Write() // Writes Information to General Info

com_Write() // Writes Common Rafter information  

     if(roof_type =="H"){
     hip_Write() // Writes Information to  Hip / Valley Info
     jack_Write()   // Write Jacks 
     }   

}

// End of Calc Function

// Rounding Function

function round (x)
{
   return Math.round (x * 100) / 100;
}

// End of round Function

// Converts radians to degrees.

function deg (d)
{
   return  d / ((2 * Math.PI) / 360);
}

// End of deg Function

// Converts degrees to radians.
function deg1 (d1)
{
   return  d1 * ((2 * Math.PI) / 360);
}

// End of deg1 Function

// Converts to Feet & Inches and gets the fraction.
function fract_it(x)
{
   fraction = "";
   number1 = x;
   number2 = number1 % 1;
   number3 = ((x - number2)/ 12);
   
     if (number3 >=1 ){
     
          number4 = number3 % 1;
          feet = number3 - number4;
          inches = number4 / (1/12);
          inches = round(inches);
     
         }
        else {
        
          feet = 0;
          inches = number3 / (1/12);
          inches = round(inches);
        }
     if (number2 == 0)
     {
       number_out = feet + "' " + inches + fraction;
     }
      else
     {
      for (i = 0; i < 16; i ++ )
      {
         if ((number2 >= decm[i]) && (number2 <= decm[i + 1]))
         {
            if (i<15){
               if(fraction >= ((fract[i] + fract[i+1]) /2)){
                 fraction = fract[i + 1]; //Round up strong
                 number_out = feet + "' " + inches + "-" + fraction;
                break;
              }
            }
            fraction = fract[i]; //Round up and not out.
            number_out = feet + "' " + inches + "-" + fraction;
            break;
         }
      }
   }
   return x = number_out;

}

// End of fract_it Function



// Find the Hip Common Difference for locating jacks along the hip of valley rafter
function hip_Com_dif(z)
{
   h_run = jack_diff_3 / (1 / Math.SQRT2);   // good
   h_rise = jack_diff_3 * Math.tan(com_plumb_angle);   // right
   h_angle = Math.atan(h_rise / h_run);   // right

   return h_run / Math.cos(h_angle);   // right
}

// End of hip_Com_dif Function

// Calculate Jack Rafters
function jack_Calc()
{
// Jacks
   jack_diff = layout_spacing / Math.cos(com_plumb_angle);
   jack_diff_1 = jack_diff;
   jack_diff_2 = ((layout_spacing + (.5 * com_raft_th)) - ((Math.SQRT2 * hip_val_th) / 2)) / Math.cos(com_plumb_angle);
   
   // Jack Rafter side cut calc and stop
   jack_side_cut_ang = Math.atan(Math.tan(plan_angle) / Math.cos(com_plumb_angle));
   hip_side_cut_stop_bev = Math.tan(jack_side_cut_ang) * 12; // Set hip bevel side stop to plywood angle.
   jack_side_cut_ang = deg(jack_side_cut_ang);   // Convert to degrees
   jack_side_cut_ang = 90 - jack_side_cut_ang ; // use the complement of the sheating angle
   jack_side_cut_stop = deg1(jack_side_cut_ang); // Convert degrees back to radains
   jack_side_cut_stop = Math.tan(jack_side_cut_stop) * 12;
   
   // finds the true run of the first jack
   jack_diff_3 = ((layout_spacing + (.5 * com_raft_th)) - ((Math.SQRT2 * hip_val_th) / 2));
   nj = (building_run / layout_spacing);
   nj_1 = nj % 1;
   Numb_of_jacks = (nj - nj_1);
   
   // The Prime Jack Rafter run
   jack_prime = ((plate_width + (.5 * com_raft_th)) - ((Math.SQRT2 * hip_val_th) / 2))/ Math.cos(com_plumb_angle);
   }
// End Calculate Jack Rafters

// Find the hip shortening value
function hipShort(x)
{
    var hip_sht = (ridge_th / Math.SQRT2);
    hip_sht = (hip_sht / Math.cos(hip_plumb_angle));           
 return h_s = hip_sht;
}
// End of hipShort Function

function gen_Write(){
 // Writes Information to General Info
     dsf = round(dsf);
   document.Info_out.dsf.value = dsf + " SF";

   building_run = round(building_run);
   building_run = fract_it(building_run);  // fraction function
   document.Info_out.building_run.value = building_run + inchsign;
   
   building_run_eft = round(building_run_eft);
   building_run_eft = fract_it(building_run_eft);  // fraction function
   document.Info_out.building_run_eft.value = building_run_eft + inchsign;
   
   //Ridge height unadjusted
   ridge_ht_unadj = round(ridge_ht_unadj);
   ridge_ht_unadj = fract_it(ridge_ht_unadj);   // fraction function
   document.Info_out.ridge_ht_unadj.value = ridge_ht_unadj + inchsign;
   
   //Ridge height pitch adjustment value
   ridge_ht_pitch_adj = round(ridge_ht_pitch_adj);
   ridge_ht_pitch_adj = fract_it(ridge_ht_pitch_adj);   // fraction function
   document.Info_out.ridge_ht_pitch_adj.value = ridge_ht_pitch_adj + inchsign;
   
   //Ridge height adjusted for pitch
   ridge_ht_adj = ridge_ht + hap_cut;
   ridge_ht = round(ridge_ht);
   ridge_ht = fract_it(ridge_ht);   // fraction function
   document.Info_out.ridge_ht.value = ridge_ht + inchsign;
   
   //Ridge height with HAP cut added.
   ridge_ht_adj = round(ridge_ht_adj);
   ridge_ht_adj = fract_it(ridge_ht_adj);   // fraction function
   document.Info_out.ridge_ht_adj.value = ridge_ht_adj + inchsign;

   ridge_length = round(ridge_length);
   ridge_length = fract_it(ridge_length);   // fraction function
   document.Info_out.ridge_length.value = ridge_length + inchsign;

    hap_cut = round(hap_cut);
   hap_cut = fract_it(hap_cut);   // fraction function
   document.Info_out.hap_cut.value = hap_cut + inchsign;
   
    build_pl_ln = round(build_pl_ln);
   build_pl_ln = fract_it(build_pl_ln);  // fraction function
   document.Info_out.build_pl_ln.value = build_pl_ln + inchsign;
}

function com_Write(){
      //   Write the Common Rafter Information
   com_plumb_angle1 = round(com_plumb_angle1);
   document.Info_out.com_plumb_angle.value = com_plumb_angle1  + degsign;

   com_seat_angle = round(com_seat_angle);
   document.Info_out.com_seat_angle.value = com_seat_angle + degsign;

   com_unit_length = round(com_unit_length);
   com_unit_length = fract_it(com_unit_length);   // fraction function
   document.Info_out.com_unit_length.value = com_unit_length + inchsign;

   com_raft_length = round(com_raft_length);
   com_raft_length = fract_it(com_raft_length);   // fraction function
   document.Info_out.com_raft_length.value = com_raft_length + inchsign;

   document.Info_out.com_raft_qty.value = com_raft_qty;

   total_common_length = round(total_common_length);
   total_common_length = fract_it(total_common_length);   // fraction function
   document.Info_out.total_common_length.value = total_common_length + inchsign;

   over_hang_pro = round(over_hang_pro);
   over_hang_pro = fract_it(over_hang_pro);   // fraction function
   document.Info_out.over_hang_pro.value = over_hang_pro  + inchsign;
   
   //Write Square cut tail  initial info at start to zeroes
   
   document.Info_out.sc_hmb.value = "0.00"  + degsign;
   document.Info_out.sc_hcl.value = "0.00"  + inchsign;
   document.Info_out.sc_hca.value = "0.00"  + degsign;
   document.Info_out.sc_hma.value = "0.00"  + degsign;
   document.Info_out.sc_fma.value = "0.00"  + degsign;
   document.Info_out.sc_fhma.value = "0.00"  + degsign;
   
   document.Info_out.SC_HMB_in.value = "0"  + inchsign;
   document.Info_out.SC_HMA_in.value = "0"  + inchsign;
   document.Info_out.SC_FMA_in.value = "0"  + inchsign;
   document.Info_out.SC_FHMA_in.value = "0"  + inchsign;
   document.Info_out.SC_HCL_in.value = "**************";
   document.Info_out.SC_HCA_in.value = "0"  + inchsign;
   
   if(tail_type == "S"){                 
           
  //Write Square cut tail info if the tail cut is to be square 
       // Saw Bevel Angle
       sc_hmb = deg(sc_hmb); // Converts to degrees
       SC_HMB_in = Math.tan(SC_HMB_in) * 12; // Preform the inch calculation
       sc_hmb = round(sc_hmb); // Rounds the value
       SC_HMB_in = round(SC_HMB_in); // Rounds the value
       SC_HMB_in = fract_it(SC_HMB_in); // Gets the fractional part
       document.Info_out.sc_hmb.value = sc_hmb  + degsign;
       document.Info_out.SC_HMB_in.value = SC_HMB_in  + inchsign; //Write it
       
       // Counter Pitch Length
       sc_hcl = round(sc_hcl); // Converts to degrees
       sc_hcl = fract_it(sc_hcl);   // fraction function
       document.Info_out.sc_hcl.value = sc_hcl  + inchsign;
       
        // Counter Pitch Angle
       sc_hca = deg(sc_hca); // Converts to degrees
       SC_HCA_in = Math.tan(SC_HCA_in) * 12; // Preform the inch calculation
       sc_hca = round(sc_hca); // Rounds the value
       SC_HCA_in = round(SC_HCA_in); // Rounds the value
       SC_HCA_in = fract_it(SC_HCA_in); // Gets the fractional part
       document.Info_out.sc_hca.value = sc_hca  + degsign;
       document.Info_out.SC_HCA_in.value = SC_HCA_in  + inchsign; //Write it
       
       // Hip Miter Angle
       sc_hma = deg(sc_hma); // Converts to degrees
       SC_HMA_in = Math.tan(SC_HMA_in) * 12; // Preform the inch calculation
       sc_hma = round(sc_hma); // Rounds the value
       SC_HMA_in = round(SC_HMA_in); // Rounds the value
       SC_HMA_in = fract_it(SC_HMA_in); // Gets the fractional part
       document.Info_out.sc_hma.value = sc_hma  + degsign;
       document.Info_out.SC_HMA_in.value = SC_HMA_in  + inchsign; //Write it
       
       // Fascia Miter Angle
       sc_fma = deg(sc_fma); // Converts to degrees
       SC_FMA_in = Math.tan(SC_FMA_in) * 12; // Preform the inch calculation
       sc_fma = round(sc_fma); // Rounds the value
       SC_FMA_in = round(SC_FMA_in); // Rounds the value
       SC_FMA_in = fract_it(SC_FMA_in); // Gets the fractional part
       document.Info_out.sc_fma.value = sc_fma  + degsign;
       document.Info_out.SC_FMA_in.value = SC_FMA_in  + inchsign; //Write it
       
       // Fascia & Hip Miter Top Scribe Angle
       sc_fhma = deg(sc_fhma); // Converts to degrees
       SC_FHMA_in = Math.tan(SC_FHMA_in) * 12; // Preform the inch calculation
       sc_fhma = round(sc_fhma); // Rounds the value
       SC_FHMA_in = round(SC_FHMA_in); // Rounds the value
       SC_FHMA_in = fract_it(SC_FHMA_in); // Gets the fractional part
       document.Info_out.sc_fhma.value = sc_fhma  + degsign;
       document.Info_out.SC_FHMA_in.value = SC_FHMA_in  + inchsign; //Write it
        }
   
}


function hip_Write(){
     // Writes Information to  Hip / Valley Info
   
   hip_plumb_angle1 = round(hip_plumb_angle1);
   document.Info_out.hip_plumb_angle.value = hip_plumb_angle1 + degsign;

   hip_seat_angle = round(hip_seat_angle);
   document.Info_out.hip_seat_angle.value = hip_seat_angle + degsign;

   hip_unit_length = round(hip_unit_length);
   hip_unit_length = fract_it(hip_unit_length);   // fraction function
   document.Info_out.hip_unit_length.value = hip_unit_length + inchsign;


   hip_Pro = round(hip_Pro);
   hip_Pro = fract_it(hip_Pro);   // fraction function
   document.Info_out.hip_Pro.value = hip_Pro + inchsign;

   hip_jack_locator = round(hip_jack_locator);
   hip_jack_locator = fract_it(hip_jack_locator);   // fraction function
   document.Info_out.hip_jack_locator.value = hip_jack_locator + inchsign;

   hip_jack_offset = round(hip_jack_offset);
   hip_jack_offset = fract_it(hip_jack_offset);   // fraction function
   document.Info_out.hip_jack_offset.value = hip_jack_offset + inchsign;
    

   Hip_drop = round(Hip_drop);
   Hip_drop = fract_it(Hip_drop);   // fraction function
   document.Info_out.Hip_drop.value = Hip_drop + inchsign;

   hip_backing_angle = round(hip_backing_angle);
   Ply_bev_cut_angle = hip_backing_angle;
   Ply_cut_angle = round(Ply_cut_angle);

   document.Info_out.hip_backing_angle.value = hip_backing_angle + degsign;
   document.Info_out.Ply_cut_angle.value = Ply_cut_angle + degsign;
   document.Info_out.Ply_bev_cut_angle.value = Ply_bev_cut_angle + degsign;
   //write side cut for beveled hip which is the same as the plywood angle. 09/01/2009
   document.Info_out.hip_side_cut_ang_bev.value = Ply_cut_angle + degsign;
   
   total_hip_val_length = round(total_hip_val_length);
   total_hip_val_length = fract_it(total_hip_val_length);   // fraction function
   document.Info_out.total_hip_val_length.value = total_hip_val_length + inchsign;

   hip_length = round(hip_length);
   hip_length = fract_it(hip_length);   // fraction function
   document.Info_out.hip_length.value = hip_length + inchsign;

   hip_inch_rise = round(hip_inch_rise);
   hip_inch_rise = fract_it(hip_inch_rise);  // fraction function
   document.Info_out.hip_inch_rise.value = hip_inch_rise + inchsign;
   
   //Write hip/val rafter side cut and stops
   hip_side_cut_ang = round(hip_side_cut_ang);
   document.Info_out.hip_side_cut_ang.value = hip_side_cut_ang  + degsign;
   
   hip_side_cut_stop1 = round(hip_side_cut_stop1);
   hip_side_cut_stop1 = fract_it(hip_side_cut_stop1);
   document.Info_out.hip_side_cut_stop1.value = hip_side_cut_stop1  + inchsign;
   
   hip_side_cut_stop_bev = round(hip_side_cut_stop_bev);
   hip_side_cut_stop_bev = fract_it(hip_side_cut_stop_bev);
   document.Info_out.hip_side_cut_stop_bev.value = hip_side_cut_stop_bev  + inchsign;
 
}

function jack_Write(){
   // Write Jacks

   jack_diff = round(jack_diff);
   jack_diff = fract_it(jack_diff);   // fraction function
   document.Info_out.jack_diff.value = jack_diff  + inchsign;
   
   //Write jack rafter side cut and stop
   jack_side_cut_ang = round(jack_side_cut_ang);
   document.Info_out.jack_side_cut_ang.value = jack_side_cut_ang  + degsign;
   
   jack_side_cut_stop = round(jack_side_cut_stop);
   jack_side_cut_stop = fract_it(jack_side_cut_stop);
   document.Info_out.jack_side_cut_stop.value = jack_side_cut_stop  + inchsign;
   
   Numb_of_jacks = round(Numb_of_jacks);
   document.Info_out.Numb_of_jacks.value = ((Numb_of_jacks +1)*8) +"   "+ (Numb_of_jacks+1) + " (x 8)";
   
   // Jack loop write

   // Clear all Jark Rafter fields.
   r = 1;
   while (r <= 24)
   {
      jack_rafter_r[r] = "jack_rafter_" + r;
      document.Info_out[jack_rafter_r[r]].value = "  ";
      r ++ ;
   }

   // Calculate jack lengths and round.
   jack_rafter[0] = 0;
   jack_rafter[1] = jack_diff_2;
   jack_rafter[1] = round(jack_rafter[1]);
   r = 2;
   
   while (r <= Numb_of_jacks)
   {
      jack_rafter[r] = jack_diff_1 + jack_rafter[r - 1];
      jack_rafter[r] = round(jack_rafter[r]);
      r ++ ;
   }

  // Convert strings and print to fields.
  
   r = 1;
   jack_rafter[r - 1] = 0
   jack_prime = round(jack_prime);
   jack_prime = fract_it(jack_prime);
   document.Info_out.jack_rafter_1.value = jack_prime;
   while (r <= Numb_of_jacks)
   {
      jack_rafter[r] = fract_it(jack_rafter[r]);   // fraction function
      jack_rafter_r[r] = "jack_rafter_" + r;
      document.Info_out[jack_rafter_r[r+1]].value = jack_rafter[r] + inchsign;
      r ++ ;
   }
  
}

// This will perform all the split pitched calcs.
function splitPitch(){
}

//This will perform all the octagon calcs.
function octagonCalcs(){
}


//  End -->
// -->
