function updateWineTypes(id){
  var typeId = id.value;
  if ( id == undefined ){
    typeId = id.value;
  }
  url = 'value=' + typeId;

  $.ajax({
      data: 'value=' + typeId,
      url:'/utils/prototype_select_wine_type.php',
      type: "POST",
      dataType: "script",
      success: function(t) {
            building_select(t)},
      error: function(){alert('Error')}
  });
}

function building_select(arr){
  document.catalog.wine_subtypes.length = 0;
  if(arr.length>0)
  {
    document.catalog.wine_subtypes.length = 0;
    document.catalog.wine_subtypes.disabled = false;
    document.catalog.wine_subtypes.options[0] = new Option('-- All --', 0);

    for( i = 1 ; i < out.length ; i++ )
    {
      document.catalog.wine_subtypes.options[i] = new Option(out[i]['title'],out[i]['id']);
    }
  }
  else
  {
    document.catalog.wine_subtypes.length = 0;
    document.catalog.wine_subtypes.disabled = true;
    document.catalog.wine_subtypes.options[0] = new Option('-- All --', 0);

  }
}

