var material_specifications = new Array();
  material_specifications.push(new Array("1", "1018", "5"));
  material_specifications.push(new Array("1", "13-8PH per AMS 5629", "4"));
  material_specifications.push(new Array("1", "15-5PH per AMS 5659", "3"));
  material_specifications.push(new Array("1", "17-4PH per AMS 5643", "2"));
  material_specifications.push(new Array("2", "2024", "11"));
  material_specifications.push(new Array("1", "300M", "9"));
  material_specifications.push(new Array("1", "410", "8"));
  material_specifications.push(new Array("1", "4140", "6"));
  material_specifications.push(new Array("1", "4340", "7"));
  material_specifications.push(new Array("2", "6061-T6XX", "12"));
  material_specifications.push(new Array("2", "7075-T7XX", "13"));
  material_specifications.push(new Array("5", "Cent Cast Tube per AMS4880 (UNS C95510)", "20"));
  material_specifications.push(new Array("3", "Soild Bar per AMS4533 (UNS C17200)", "15"));
  material_specifications.push(new Array("5", "Solid Bar per AMS4640 (UNS C63000)", "19"));
  material_specifications.push(new Array("4", "Toughmet", "18"));
  material_specifications.push(new Array("3", "Tube per AMS4535 (UNS C17200)", "16"));
  material_specifications.push(new Array("1", "other...", "10"));
  material_specifications.push(new Array("2", "other...", "14"));
  material_specifications.push(new Array("3", "other...", "17"));
  material_specifications.push(new Array("6", "other...", "21"));
  material_specifications.push(new Array("7", "other...", "22"));
  material_specifications.push(new Array("8", "other...", "23"));
  material_specifications.push(new Array("4", "other...", "24"));
  material_specifications.push(new Array("5", "other...", "25"));
     

function materialTypeSelected() {
  material_type_id = $('order_material_type_id').getValue();
  options = $('order_material_specification_id').options;
   
  options.length = 1;
  material_specifications.each(function(material_specification) {
    if (material_specification[0] == material_type_id) {
      options[options.length] = new Option(material_specification[1], material_specification[2]);
    }
  });

  if (options.length == 1) {
    $('order_my_material_specification').hide();
  } else {
    $('order_material_specification_id').show();
  }
  
  if (material_type_id != 8) {
    $('order_my_material_type').hide();
    $('order_my_material_specification').hide();
  } else {
    $('order_my_material_type').show();
  }
}

function materialSpecificationSelected() {
  material_specification_id = $('order_material_specification_id').getValue();
  
  if (material_specification_id == 10 || material_specification_id == 14 || material_specification_id == 17 || 
      material_specification_id == 21 || material_specification_id == 22 || material_specification_id == 23 || 
      material_specification_id == 24 || material_specification_id == 25) {
    $('order_my_material_specification').show();
  } else {
    $('order_my_material_specification').hide();
  }
}
  
document.observe('dom:loaded', function() {
  materialTypeSelected();
  materialSpecificationSelected();
  $('order_material_type_id').observe('change', materialTypeSelected);
  $('order_material_specification_id').observe('change', materialSpecificationSelected);
});
    

