var m_steel = new Array('3сп','35гс','1пс','3сп','1сп');

var s_steel = new Array();
s_steel[0] = new Array(2,6, 3,6.5, 4,8, 5,10, 6,12, 7,14, 8,16);
s_steel[1] = new Array(2,6, 4,8, 5,10, 6,12, 7,14, 8,16);
s_steel[2] = new Array(0,4, 1,5);
s_steel[3] = new Array(2,6, 4,8, 5,10, 6,12, 7,14, 8,16);
s_steel[4] = new Array(0,4, 1,5, 2,6, 4,8, 5,10, 6,12);

var a_steel = new Array(4, 5, 6, 6.5, 8, 10, 12, 14, 16);

var a_weight = new Array();
a_weight[0] = new Array(1, 2, 2, 2, 3);
a_weight[1] = new Array(0.092, 0.144, 0.222, 0.26, 0.395, 0.616, 0.888, 1.21, 1.58);
a_weight[2] = new Array(0.092, 0.144, 0.222, 0.26, 0.395, 0.617, 0.888, 1.21, 1.58);
a_weight[3] = new Array(0.099, 0.154, 0.222, 0.26, 0.395, 0.616, 0.888, 1.208, 1.578);

var pack = new Array(11,50, 13.5,40, 17,30, 21,25, 25,20);


function reload_select(sel_obj, s_st)
{
eval ("obj=document.calc." + sel_obj);
for (i = obj.length-1; i >=0 ; i--) {obj.options[i]=null;}
for (t=0; t < s_steel[s_st].length/2; t++) {obj.options[t] = new Option(s_steel[s_st][2*t+1],s_steel[s_st][2*t],false, false);}
obj.options[0].selected=true;
}



function sel_steel(obj,sel_code,obj_selected)
{
reload_select(obj_selected ,sel_code.value);
eval ("thisobj=document.calc." + obj);
thisobj.value=m_steel[sel_code.value];
}

function calc_c19()
{
c_19=(document.calc.c28.value-document.calc.c29.value-document.calc.c30.value)/document.calc.c14.value+1
if (c_19-Math.round(c_19)!=0)  {
document.calc.c19.value=Math.round(c_19*100)/100;
document.calc.c19.style.backgroundColor='#E93800';
document.calc.c28.style.backgroundColor='#FF9A7A';
document.calc.c29.style.backgroundColor='#FF9A7A';
document.calc.c30.style.backgroundColor='#FF9A7A';
document.calc.c14.style.backgroundColor='#FF9A7A';
document.all.dc19.style.display='inline'} 
else {
document.calc.c19.value=c_19; 
document.calc.c19.style.backgroundColor='white';
document.calc.c28.style.backgroundColor='white';
document.calc.c29.style.backgroundColor='white';
document.calc.c30.style.backgroundColor='white';
document.calc.c14.style.backgroundColor='white';
document.all.dc19.style.display='none'}
}


function calc_c27()
{
c_27=(document.calc.c20.value-document.calc.c21.value-document.calc.c22.value)/document.calc.c13.value+1
if (c_27-Math.round(c_27)!=0)  {
document.calc.c27.value=Math.round(100*c_27)/100;
document.calc.c27.style.backgroundColor='#E93800';
document.calc.c20.style.backgroundColor='#FF9A7A';
document.calc.c21.style.backgroundColor='#FF9A7A';
document.calc.c22.style.backgroundColor='#FF9A7A';
document.calc.c13.style.backgroundColor='#FF9A7A';
document.all.dc27.style.display='inline'} 
else {
document.calc.c27.value=c_27;
document.calc.c27.style.backgroundColor='white';
document.calc.c20.style.backgroundColor='white';
document.calc.c21.style.backgroundColor='white';
document.calc.c22.style.backgroundColor='white';
document.calc.c13.style.backgroundColor='white';
document.all.dc27.style.display='none'}
}

function calc_s()
{
document.all.u13.innerText='';
document.all.s13.innerText='';
document.all.u12.innerText='';
document.all.q12.innerText='';
document.all.s12.innerText='';
document.all.t12.innerText='';

if (1*document.calc.c20.value>6000) {scolor=document.calc.c20.style.backgroundColor; document.calc.c20.value=6000; document.calc.c20.style.backgroundColor='green'; alert ('Длина 1 шт. (L) не может быть больше 6000 мм'); document.calc.c20.style.backgroundColor=scolor; return ;}

if (1*document.calc.c20.value<2000) {scolor=document.calc.c20.style.backgroundColor; document.calc.c20.value=2000; document.calc.c20.style.backgroundColor='green'; alert ('Длина 1 шт. (L) не может быть меньше 2000 мм'); document.calc.c20.style.backgroundColor=scolor; return ;}


if (1*document.calc.c21.value>200) {scolor=document.calc.c21.style.backgroundColor; document.calc.c21.value=200; document.calc.c21.style.backgroundColor='green'; alert ('Размер первого выпуска (c2.1) не может быть больше 200 мм'); document.calc.c21.style.backgroundColor=scolor; return ;}

if (1*document.calc.c21.value<50)  {scolor=document.calc.c21.style.backgroundColor; document.calc.c21.value=50; document.calc.c21.style.backgroundColor='green'; alert ('Размер первого выпуска (c2.1) не может быть меньше 50 мм'); document.calc.c21.style.backgroundColor=scolor; return ;}



if (1*document.calc.c22.value>500) {scolor=document.calc.c22.style.backgroundColor; document.calc.c22.value=500; document.calc.c22.style.backgroundColor='green'; alert ('Размер последнего выпуска (c2.2) не может быть больше 500 мм'); document.calc.c22.style.backgroundColor=scolor; return ;}

if (1*document.calc.c22.value<50)  {scolor=document.calc.c22.style.backgroundColor; document.calc.c22.value=50; document.calc.c22.style.backgroundColor='green'; alert ('Размер последнего выпуска (c2.2) не может быть меньше 50 мм'); document.calc.c22.style.backgroundColor=scolor; return ;}




if (1*document.calc.c28.value>2400) {scolor=document.calc.c28.style.backgroundColor; document.calc.c28.value=2400; document.calc.c28.style.backgroundColor='green'; alert ('Длина 1 шт. (B) не может быть больше 2400 мм'); document.calc.c28.style.backgroundColor=scolor; return ;}

if (1*document.calc.c28.value<1000) {scolor=document.calc.c28.style.backgroundColor; document.calc.c28.value=1000; document.calc.c28.style.backgroundColor='green'; alert ('Длина 1 шт. (B) не может быть меньше 1000 мм'); document.calc.c28.style.backgroundColor=scolor; return ;}



if (1*document.calc.c29.value<10)  {scolor=document.calc.c29.style.backgroundColor; document.calc.c29.value=10; document.calc.c29.style.backgroundColor='green'; alert ('Размер первого выпуска (c1.1) не может быть меньше 10 мм'); document.calc.c29.style.backgroundColor=scolor; return ;}

if (1*document.calc.c30.value<10)  {scolor=document.calc.c30.style.backgroundColor; document.calc.c30.value=10; document.calc.c30.style.backgroundColor='green'; alert ('Размер последнего выпуска (c1.2) не может быть меньше 10 мм'); document.calc.c30.style.backgroundColor=scolor; return ;}


calc_c19();
calc_c27();
f_10=document.calc.c28.value*document.calc.c20.value/1000000;
document.calc.f10.value=Math.round(100*f_10)/100;
document.calc.f11.value=Math.round(100*document.calc.c12.value*f_10)/100;

h_25=a_weight[(a_weight[0][document.calc.c16.value])][document.calc.c17.value];
h_26=a_weight[(a_weight[0][document.calc.c24.value])][document.calc.c25.value];

vc_7=h_26*document.calc.c27.value*document.calc.c28.value/1000
vc_15=h_25*document.calc.c20.value*document.calc.c19.value/1000

f_12=vc_7+vc_15;
document.calc.f12.value=Math.round(100*f_12)/100;

f_13=f_12*document.calc.c12.value;
document.calc.f13.value=Math.round(100*f_13)/100;


f_141=a_steel[document.calc.c17.value]+a_steel[document.calc.c25.value];

ic=0;
while (ic<5) {
	f_14=pack[2*ic+1];
	if (pack[2*ic]>=f_141) break;
	ic++;
} 
document.calc.f14.value=f_14;
document.calc.f15.value=Math.round(1000*f_14*f_12)/1000;

if (document.calc.c25.value<6&&document.calc.c17.value<6) {j_31=4; e_37=true;} else {
	if (document.calc.c17.value>document.calc.c25.value) {j_31=1}
	if (document.calc.c17.value<document.calc.c25.value) {j_31=3}
	if (document.calc.c17.value==document.calc.c25.value) {j_31=2}
	e_37=false;
}
document.all.q12.innerText=j_31+'C';
document.all.s12.innerText=a_steel[document.calc.c17.value]+document.calc.c16.options[document.calc.c16.value].text+"-"+document.calc.c14.value;
document.all.s13.innerText=a_steel[document.calc.c25.value]+document.calc.c24.options[document.calc.c24.value].text+"-"+document.calc.c13.value;
document.all.t12.innerText=document.calc.c28.value/10+"x"+document.calc.c20.value/10

u_12=document.calc.c21.value;
if (document.calc.c21.value!=document.calc.c22.value) {u_12=u_12+"-"+document.calc.c22.value;}
document.all.u12.innerText=u_12;

u_13=document.calc.c29.value;
if (document.calc.c29.value!=document.calc.c30.value) {u_13=u_13+"-"+document.calc.c30.value;}
document.all.u13.innerText=u_13;
}

