﻿function IsNumeric(input){return (input - 0)==input&&input.length > 0;}function profile_check(){switch ($("#profile_name option:selected").val()){case "0":case "1":case "2":case "3":case "5":if (IsNumeric($('#a').attr("value"))&&IsNumeric($('#h').attr("value"))&&IsNumeric($('#t').attr("value"))&&IsNumeric($('#t1').attr("value"))){return false;}break;case "4":if (IsNumeric($('#d').attr("value"))&&IsNumeric($('#t').attr("value"))){return false;}break;case "6":if (IsNumeric($('#a').attr("value"))&&IsNumeric($('#h').attr("value"))){return false;}break;}return true;}function firedefence_check(){if (IsNumeric($('#tred_ogne_edit').attr("value")))return false;return true;}function ShowArrow(show){if (show==true){$('.arrow_hide').toggleClass("arrow arrow_hide");}else{$('.arrow').toggleClass("arrow arrow_hide");}}$(document).ready(function(){var profile_name=[["Двутавр","images/dv.png",true,true,true,true,true,true,false],["Швеллер","images/sv.png",true,true,true,true,true,true,false],["Тавр","images/tv.png",false,false,true,true,true,true,false],["Уголок","images/ug.png",false,false,true,true,true,true,false],["Труба круглая","images/tr_kr.png",false,false,false,false,true,false,true],["Труба квадратная","images/tr_kv.png",false,false,true,true,true,true,false],["Лист","images/list.png",false,false,true,true,false,false,false]];var profile_type1=[["ГОСТ 8239","ГОСТ 26020","IPE EN 10034","IPN EN 10024","HEA EN 10034","HEB EN 10034","HEM EN 10034"],["ГОСТ 8240"]];var profile_type2=[["10","12","14","16","18","20","22","24","27","30","33","36","40","45","50","55","60"],["10Б1","12Б1","12Б2","14Б1","14Б2","16Б1","16Б2","18Б1","18Б2","20Б1","23Б1","26Б1","26Б2","30Б1","30Б2","35Б1","35Б2","40Б1","40Б2","45Б1","45Б2","50Б1","50Б2","55Б1","55Б2","60Б1","60Б2","70Б1","70Б2","80Б1","80Б2","90Б1","90Б2","100Б1","100Б2","100Б3","100Б4","20Ш1","23Ш1","26Ш1","26Ш2","30Ш1","30Ш2","30Ш3","35Ш1","35Ш2","35Ш3","40Ш1","40Ш2","40Ш3","50Ш1","50Ш2","50Ш3","50Ш4","60Ш1","60Ш2","60Ш3","60Ш4","70Ш1","70Ш2","70Ш3","70Ш4","70Ш5","20К1","20К2","23К1","23К2","26К1","26К2","26К3","30К1","30К2","30К3","35К1","35К2","35К3","40К1","40К2","40К3","40К4","40К5","24ДБ1","27ДБ1","36ДБ1","35ДБ1","40ДБ1","45ДБ1","45ДБ2","30ДШ1","40ДШ1","50ДШ1"],["IPE 80","IPE 100","IPE 120","IPE 140","IPE 160","IPE 180","IPE 200","IPE 220","IPE 240","IPE 270","IPE 300","IPE 330","IPE 360","IPE 400","IPE 450","IPE 500","IPE 550","IPE 600"],["IPN 80","IPN 100","IPN 120","IPN 140","IPN 160","IPN 180","IPN 200","IPN 220","IPN 240","IPN 260","IPN 280","IPN 300","IPN 320","IPN 340","IPN 360","IPN 380","IPN 400","IPN 450","IPN 500","IPN 550"],["HEA 100","HEA 120","HEA 140","HEA 160","HEA 180","HEA 200","HEA 220","HEA 240","HEA 260","HEA 280","HEA 300","HEA 320","HEA 340","HEA 360","HEA 400","HEA 450","HEA 500","HEA 550","HEA 600","HEA 650","HEA 700","HEA 800","HEA 900","HEA 1000"],["HEB 100","HEB 120","HEB 140","HEB 160","HEB 180","HEB 200","HEB 220","HEB 240","HEB 260","HEB 280","HEB 300","HEB 320","HEB 340","HEB 360","HEB 400","HEB 450","HEB 500","HEB 550","HEB 600","HEB 650","HEB 700","HEB 800","HEB 900","HEB 1000"],["HEM 100","HEM 120","HEM 140","HEM 160","HEM 180","HEM 200","HEM 220","HEM 240","HEM 260","HEM 280","HEM 300","HEM 320","HEM 340","HEM 360","HEM 400","HEM 450","HEM 500","HEM 550","HEM 600","HEM 650","HEM 700","HEM 800","HEM 900","HEM 1000"],["5У","6,5У","8У","10У","12У","14У","16У","16аУ","18У","18аУ","20У","22У","24У","27У","30У","33У","36У","40У","5П","6,5П","8П","10П","12П","14П","16П","16аП","18П","18аП","20П","22П","24П","27П","30П","33П","36П","40П","5Э","6,5Э","8Э","10Э","12Э","14Э","16Э","18Э","20Э","22Э","24Э","27Э","30Э","33Э","36Э","40Э","12Л","14Л","16Л","18Л","20Л","22Л","24Л","27Л","30Л","8С","14С","14Са","16С","16Са","18С","18Са","18Сб","20С","20Са","20Сб","24С","26С","26Са","30С","30Са","30Сб"]];for (var key in profile_name){$("#profile_name").append($("<option value=\""+key+"\">"+profile_name[key][0]+"</option>"));}$("#profile_name")[0].selectedIndex=-1;$("#profile_img").attr("src",profile_name[0][1]);$("#material").change(function(){$("#ptk").show();$("#firedefence #r0").text("");$("#firedefence #df").text("");$("#firedefence #rash").text("");});$("#tred_button").click(function(){$("#tred_ogne_edit").attr("value",$("#profile_output #tred").text());});$('#profile_name').change(function(){ShowArrow(true);$("#profile_output .value").text("");$("#tred_button").hide();$("#a").attr("value","");$("#h").attr("value","");$("#t").attr("value","");$("#t1").attr("value","");$("#profile_type1").empty();$("#profile_type2").empty();var select_index=Number($("#profile_name option:selected").val());if (profile_name[select_index][2]){var index_undo=0;for (var i=0;i<select_index;++i){index_undo+=profile_type1[i].length;}for (var key in profile_type1[select_index]){var index=index_undo+Number(key);$("#profile_type1").append($("<option value=\""+index+"\">"+profile_type1[select_index][key]+"</option>"));}$("#profile_type1")[0].selectedIndex=-1;$("#profile_type1").show();}else{$("#profile_type1").hide();}if (profile_name[select_index][3]){$("#profile_type2").show();}else{$("#profile_type2").hide();}if (profile_name[select_index][4]){$("#a_container").show();}else{$("#a_container").hide();}if (profile_name[select_index][5]){$("#h_container").show();}else{$("#h_container").hide();}if (profile_name[select_index][6])$("#t_container").show();else{$("#t_container").hide();}if (profile_name[select_index][7]){$("#t1_container").show();}else{$("#t1_container").hide();}if (profile_name[select_index][8]){$("#d_container").show();}else{$("#d_container").hide();}$("#profile_img").attr("src",profile_name[select_index][1]);$("#imagebox").show();});$('#profile_type1').change(function(){$("#profile_output .value").text("");$("#tred_button").hide();$("#a").attr("value","");$("#h").attr("value","");$("#t").attr("value","");$("#t1").attr("value","");$("#profile_type2").empty();var select_index=Number($("#profile_type1 option:selected").val());var index_undo=0;for (var i=0;i<select_index;++i){index_undo+=profile_type2[i].length;}for (var key in profile_type2[select_index]){var index=index_undo+Number(key);$("#profile_type2").append($("<option value=\""+index+"\">"+profile_type2[select_index][key]+"</option>"));}$("#profile_type2")[0].selectedIndex=-1;});$('#profile_type2').change(function(){$("#profile_output .value").text("");$("#tred_button").hide();$.post("work.php",{"id":"profile","index":$("#profile_type2 option:selected").val()},function(data){if (data==null){$("#loading").hide();}else{$("#a").attr("value",data.a);$("#h").attr("value",data.h);$("#t").attr("value",data.t);$("#t1").attr("value",data.t1);}},"json");});$("#a,#h,#d,#t,#t1").change(function(){$("#profile_output .value").text("");$("#tred_button").hide();});$('#profile_input #send').click(function(){if (profile_check())return;var right_arrow=false,left_arrow=false,top_arrow=false,bottom_arrow=false;$("#profile_output .value").text("");$("#tred_button").hide();if ($("#top_obogrev").attr("class")=="arrow")top_arrow=true;if ($("#left_obogrev").attr("class")=="arrow")left_arrow=true;if ($("#right_obogrev").attr("class")=="arrow")right_arrow=true;if ($("#bottom_obogrev").attr("class")=="arrow")bottom_arrow=true;$.post("work.php",{"id":"calculate","type":$("#profile_name option:selected").val(),"top":top_arrow,"left":left_arrow,"right":right_arrow,"bottom":bottom_arrow,"a":$('#a').attr("value"),"h":$('#h').attr("value"),"t":$('#t').attr("value"),"t1":$('#t1').attr("value"),"d":$('#d').attr("value")},function(data){if (data==null){$("#loading").hide();}else{$("#profile_output #p").text(data.p);$("#profile_output #s").text(data.s);$("#profile_output #tred").text(data.tred);$("#profile_output #av").text(data.av);$("#tred_ogne_edit").attr("value",$("#profile_output #tred").text());$("#tred_button").show();}},"json");});$('#profile_input #clear').click(function(){ShowArrow(false);$("#imagebox").hide();$("#profile_output .value").text("");$("#tred_button").hide();$("#a").attr("value","");$("#h").attr("value","");$("#t").attr("value","");$("#t1").attr("value","");$("#d").attr("value","");$("#a_container").hide();$("#h_container").hide();$("#t_container").hide();$("#t1_container").hide();$("#d_container").hide();$("#profile_name")[0].selectedIndex=-1;$("#profile_type1").empty();$("#profile_type2").empty();$("#profile_type1").hide();$("#profile_type2").hide();});$('#firedefence_button_send').click(function(){if (firedefence_check())return;$("#firedefence #r0").text("");$("#firedefence #df").text("");$("#firedefence #rash").text("");$.post("work.php",{"id":"ogne","material":$("#material option:selected").val(),"tred":$('#tred_ogne_edit').attr("value"),"r":$("#firedefence #R option:selected").val()},function(data){if (data==null){$("#loading").hide();}else{$("#firedefence #r0").text(data.r0);$("#firedefence #df").text(data.df);$("#firedefence #rash").text(data.rashod);}},"json");});$('#firedefence_button_clear').click(function(){$("#firedefence #r0").text("");$("#firedefence #df").text("");$("#firedefence #rash").text("");});$('.arrow,.arrow_hide').click(function(){$(this).toggleClass("arrow arrow_hide");$("#profile_output .value").text("");$("#tred_button").hide();});$("#loading").bind("ajaxSend",function(){$(this).show();}).bind("ajaxComplete",function(){$(this).hide();}).bind("success",function(){$(this).hide();});});