

function head_height(){
	
	MM_showHideLayers('long_short_butts','','hide');
	
	var A = total_stair_rise;
	var B = run;
	var C = total_stair_run;
	var X = document.calc_form_1.head_restriction_x.value; //height of obstruction (user input)
	var Y = document.calc_form_1.head_restriction_y.value; //distance to restriction (user input)
	var D = 79;
	var E = RISE_Height;
	
	var L1 = Number(C) + Number(B);
	var F = A - (X - D);
	L2 = (A * Y) / F;
	
	//alert(L1);
	//salert(L2);
	
	if(Number(L1 > L2)){
		var R = Math.ceil(Number(A / 8.25)); //new number of rizers
		var E2 = Number(A / R); //new rize height
		var B2 = Number((L2 * E2) / A); //new run
		var C2 = Number((R - 1) * B2); //new total run
		
		number_of_RISERS = R;
		run = Math.round(B2 * 100)/100;
		total_stair_run = Math.round(C2 * 100)/100;
		Number_of_RUNS = Number(R -1);
		RISE_Height = Math.round(E2 * 100)/100;
		stringer_length_func();	
		spacer_settings_func();

		//if single rize is greater than 8.25 inches is bad
		if((A / R) > 8.25){
			alert("Does not comply with IBC Code");
		}
		
		//if single run is less that 9 inches is bad
		if(B2 < 9){
			alert("Does not comply with IBC Code");
		}
	}
	
	//put new values in collum 2
	//alt stuff
	document.getElementById('number_of_RISERS_text_alt').innerHTML = number_of_RISERS;
	document.getElementById('RISE_Height_text_alt').innerHTML = RISE_Height;
	document.getElementById('Number_of_RUNS_text_alt').innerHTML = Number_of_RUNS;
	document.getElementById('RUN_text_alt').innerHTML = run;
	document.getElementById('total_RUN_text_alt').innerHTML = total_stair_run;
	document.getElementById('Stringer_Length_text_alt').innerHTML = stringer_wood_feet;
	document.getElementById('Spacer_Setting_text_alt').innerHTML = spacer_setting_x;
		
		
	//alert(R);
	//alert(B2);
	//alert(C2);
	
}

/*
A = total stair rize (user input)
B = single run (user input)
C = total stair run (user input)
X = height of obstruction (user input)
Y = distance to restriction (user input)
D = 79 (constant)
E = single stair rize

L1 = C + B

F = A - (X - D)

L2 = (A * Y) / F

if L1 > L2 then::
R = round up to whole number(A / 8.25)
B2 = (L2 * E) / A
C2 = (R - 1) * B2

Example input that will need to be recalculated due to obstructions.
A = 93
B = 10.5
C = 115.5
X = 85
Y = 110
D = 79
E = 7.75

L1  || 115.5 + 10.5 = 126
F    || 93 - (85 - 79) = 87
L2  || (93 * 110) /  87 = 117.58
126 > 117.58 = True
R   || 93 / 8.25 = 11.27 round to 12
B2 || (117.58 * 7.75) / 93 =  9.79
C2 || (12 - 1) * 9.79 = 107.69
*/
