function SearchParamsOk()
{
  //if (document.getElementById('id-part-id').value == 0)
  //  return false;
  var notice = '';
  if ((document.getElementById('idmark_id').value == 0))
    notice += 'Выберите марку!\n';
  if ((document.getElementById('idmodel_id').value == 0))
    notice += 'Выберите модель!\n';
  if ((document.getElementById('id-parts-cond').value == 0))
    notice += 'Выберите состояние запчастей!\n';
  if ((document.getElementById('id-part-id').value == 0) && (document.getElementById('id-part-name').value == ""))
    notice += 'Введите название запчасти!\n';
  else if ((document.getElementById('id-part-id').value == 0) && (document.getElementById('id-part-name').value != ""))
    notice += 'Такой запчасти не найдено!\n';

  if (notice) {
    alert(notice);
    return false;
  }
  else {
    return true;
  }
}

function ShowPartsBlock(parttype_id)
{
  if ((document.getElementById('idmark_id').value == 0) || (document.getElementById('idmodel_id').value == 0))
  {
    alert('Сначала выберите марку и модель!');
    return false;
  }
  parts_ar = parts[parttype_id];
  parts_block_str = '';
  if (parts_ar != null)
  {
    parts_ar = '0;все запчасти|' + parts_ar;
    document.getElementById('idpart_id').value = 0;
    if (document.getElementById('idparttype_id').value != 0)
    {
      document.getElementById('id_lnkparttype_' + document.getElementById('idparttype_id').value).className = 'catalog';
      document.getElementById('id_parttype_radio_' + document.getElementById('idparttype_id').value).checked = false;
    }
    document.getElementById('idparttype_id').value = parttype_id;
    document.getElementById('id_lnkparttype_' + parttype_id).className = 'red_link';
    document.getElementById('id_parttype_radio_' + parttype_id).checked = true;
    var i = 0;
    var part_list = parts_ar.split('|');
    var num_in_row = Math.ceil((part_list.length - 1) / 3);

    parts_block_str =
    '<table>' +
    '<tr><td colspan=2 class="field_name">Выберите наименование:</td></tr>' +
    '<tr height=1><td class="repeat_bg_x" background="/images/pix_l.gif" colspan=3></td></tr>' +
    '<tr height=15><td>' +
    '<table height=25>' +
    '<tr><td class="small_content padding5" width="180">';

    for(i = 0; i < part_list.length-1; i++)
    {
      part_id = part_list[i].split(';')[0];
      part_name = part_list[i].split(';')[1];
      if (((i % num_in_row) == 0)&&(i != 0))
        parts_block_str += '</td><td width="3" class="repeat_bg_y" background="../images/pix_l.gif"></td><td class="small_content padding5" width="180">';
      if (i == 0)
        parts_block_str += '<table><tr><td width=15><input type="radio" id="id_part_radio_' + part_id + '" onclick="return SetPart(' + part_id + ')" checked></td><td class=\"small_content padding3\"><a onclick="return SetPart(' + part_id + ')" href="index.php?action=search&parttype_id=' + parttype_id + '&part_id=' + part_id + '" id="id_lnkpart_' + part_id + '" class="red_link">' + part_name + '</a></td></tr></table>';
      else
        parts_block_str += '<table><tr><td width=15><input type="radio" id="id_part_radio_' + part_id + '" onclick="return SetPart(' + part_id + ')"></td><td class=\"small_content padding3\"><a onclick="return SetPart(' + part_id + ')" href="index.php?action=search&parttype_id=' + parttype_id + '&part_id=' + part_id + '" id="id_lnkpart_' + part_id + '" class="catalog">' + part_name + '</a></td></tr></table>';
    }

    parts_block_str +=
    '</td><td>&nbsp;</td></tr>' +
    '</table>' +
    '</td></tr>' +
    '<tr height=1><td class="repeat_bg_x" background="/images/pix_l.gif" colspan=3></td></tr>' +
    '</table>';
    document.getElementById('id_search_parts').innerHTML = parts_block_str;
    document.getElementById('id_search_parts').style['visibility'] = 'visible';
  }
  else
  {
//    document.search_parts_form.parttype_id.value = 0;
//    document.search_parts_form.part_id.value = 0;
  }
  return false;
}

function SetPart(part_id)
{
  if ((document.getElementById('idmark_id').value == 0) || (document.getElementById('idmodel_id').value == 0))
  {
    alert('Сначала выберите марку и модель!');
    return false;
  }

//  document.getElementById('id_submitcell').bgColor = '#FFDDDD';
//  if (document.getElementById('idpart_id').value != 0)
  document.getElementById('id_lnkpart_' + document.getElementById('idpart_id').value).className = 'catalog';
  document.getElementById('id_part_radio_' + document.getElementById('idpart_id').value).checked = false;
  document.getElementById('idpart_id').value = part_id;
  document.getElementById('id_lnkpart_' + part_id).className = 'red_link';
  document.getElementById('id_part_radio_' + part_id).checked = true;

//  document.getElementById('id_search_form').submit();
  return false;
}
