function ChangeMark(mark_id, action, id_model_select, mode, id_loading, default_name)
{
 default_name = default_name || '---';
 if (mark_id != 0)
 {
   document.getElementById(id_model_select).disabled = true;
   document.getElementById(id_model_select).selectedIndex = 0;
   if (document.getElementById(id_loading))
       document.getElementById(id_loading).style.display = 'inline-block';

   var xmlhttp_request;
   xmlhttp_request = createRequest();
   xmlhttp_request.onreadystatechange = function(){_get_mark_request(xmlhttp_request, mark_id, action, id_model_select, mode, id_loading, default_name);};
   xmlhttp_request.open("GET", 'http://'+location.host+'/auto/_load_models.php?mode='+mode+'&action='+action+'&mark_id='+mark_id, true);
   xmlhttp_request.send(null);
 }
 else
 {
   document.getElementById(id_model_select).disabled = 1;
   document.getElementById(id_model_select).options.length = 1;
   document.getElementById(id_model_select).options[0].text = default_name;
   document.getElementById(id_model_select).options[0].value = 0;
   document.getElementById(id_model_select).selectedIndex = 0;
 }
}

function _get_mark_request(xmlhttp_request, mark_id, action, id_model_select, mode, id_loading, default_name)
{
  if (xmlhttp_request.readyState == 4)// "complete"
  {
    if (xmlhttp_request.status == 200) // "OK"
    {
      var i;
      var models_str;
      var model_select = document.getElementById(id_model_select);
      models_str = xmlhttp_request.responseText.substr(0, xmlhttp_request.responseText.length-1);
      models_str = '0,'+default_name+';' + models_str;
      if (models_str)
      {
        var model_list = models_str.split(';');
        model_select.options.length = model_list.length;
        for (i = 0; i < model_list.length; i++) {
          model_select.options[i].text = (model_list[i]).split(',')[1];
          model_select.options[i].value = (model_list[i]).split(',')[0];
        }
      }
      model_select.disabled = false;
    }
    if (document.getElementById(id_loading))
      document.getElementById(id_loading).style.display = 'none';
  }
}


