$(function(){
  var
    products = [
      'fast-r',
	  'hilite',
      'hifibre',
      'redi-render',
      'polymer',
      'baseboard',
      'sydney-fine',
      'panel-patch'
    ],
    substrates = {
      'Select Substrate': products.join(','),
      'Brick (level & true)': 'fast-r,redi-render',
      'Brick (Uneven or deep rake joints)': 'fast-r,hilite',
      'Cement block': 'fast-r,hilite,redi-render',
      'Bagged Brick': 'fast-r,polymer',
      'Painted Brick': 'fast-r,polymer',
      'Painted Concrete': 'fast-r,polymer',
      'Glazed Brick': 'fast-r,polymer',
      'AAC Porous Block or Panel': 'fast-r,hilite',
      'Pre-Cast Panel': 'panel-patch',
      'In-Situ Concrete': 'fast-r,polymer',
      'FCS (Fibrous-Cement Sheet)': 'fast-r,polymer',
      'Insulation Board (Foam Sheet)': 'hifibre,polymer',
      'Foam Block': 'hifibre,polymer',
      'Uni-Base Board (Precoated Foam Sheet)': 'hifibre,baseboard',
      'Textured Wall': 'fast-r,polymer',
      'Tiled': 'fast-r,polymer'
    },
    sel = $('#products-select'),
    table = $('table.products');
  $.each(substrates, function(substrate){
    var option = document.createElement('option');
    option.value = this;
    option.appendChild(document.createTextNode(substrate));
    sel[0].appendChild(option);
  });
  sel.change(function(e){
    table.find('tr').hide();
    table.find('tr.head').show();
    $.each(this.options[this.selectedIndex].value.split(','), function(i){
      table.find('tr.' + this).show();
    });
  });
});