  var alert_message = "";

  function show_alert() 
  {
    if (alert_message != "") 
    {
      alert("\n ---------------------------------\n" +
      alert_message +
      "\n ---------------------------------\n");
      alert_message = "";
      return false;
    }
    return true;
  }
  
  function refresh_manufacturers (what, v_man, curr_veh_type)
  {
    if (v_man == '')
      v_man = '-Any-';

  if (!curr_veh_type) {
		curr_veh_type = "C";
	}

    what.maker_F.length = 0;
    if (manufacturer_any == 'Y')
    {
      what.maker_F.length++;
      what.maker_F.options[0].text = 'MAKE';
      what.maker_F.options[0].value = '-Any-';
      var m_start = 1;
    }
    else
    {
      var m_start = 0;
    }

    if (curr_veh_type == 'C') {
      for (m = 0; m < man_used.length; m++)
      {
        what.maker_F.length++;
        what.maker_F.options[m + m_start].text = man_used[m];
        what.maker_F.options[m + m_start].value = man_used[m];
        if (man_used[m] == v_man) {
          what.maker_F.selectedIndex = m + m_start;
        }
      }
    }
    else if (curr_veh_type == 'N'){
      for (m = 0; m < man_new.length; m++)
      {
        what.maker_F.length++;
        what.maker_F.options[m + m_start].text = man_new[m];
        what.maker_F.options[m + m_start].value = man_new[m];
        if (man_new[m] == v_man) {
          what.maker_F.selectedIndex = m + m_start;
        }
      }
    }
	else if (curr_veh_type == 'V'){
      for (m = 0; m < man_van.length; m++)
      {
        what.maker_F.length++;
        what.maker_F.options[m + m_start].text = man_van[m];
        what.maker_F.options[m + m_start].value = man_van[m];
        if (man_van[m] == v_man) {
          what.maker_F.selectedIndex = m + m_start;
        }
      }
    }
    //Dmitriy Tsoy 2007-11-15
    else if (curr_veh_type == 'CV'){
      //Used array
      for (m = 0; m < man_used.length; m++)
      {
        what.maker_F.length++;
        what.maker_F.options[m + m_start].text = man_used[m];
        what.maker_F.options[m + m_start].value = man_used[m];
      }
      //Used array end
      
      //Commercial array
      var man_van_add = new Array ();
      var index = 0;
      for (vv = 0; vv < man_van.length; vv++)
      {
        var repeated = false;
        for (cc = 0; cc < man_used.length; cc++)
        {
          if (man_used[cc] == man_van[vv]) {
            repeated = true;
          }
        }
        if (!repeated) {
          man_van_add[index] = man_van[vv];
          index = index + 1;
        }
      }
      var man_used_length = man_used.length + m_start;
      var man_van_length = man_van_add.length;
      for (mm = 0; mm < man_van_length; mm++)
      {
        what.maker_F.length++;
        what.maker_F.options[mm + man_used_length].text = man_van_add[mm];
        what.maker_F.options[mm + man_used_length].value = man_van_add[mm];
      }
      //Commercial array end
      
      //Sorting
      var temp_text = '';
      var temp_value = '';
      for (xx = 1; xx < what.maker_F.options.length-1; xx++) {
        for (yy = xx+1; yy < what.maker_F.options.length; yy++) {
          if (what.maker_F.options[xx].text > what.maker_F.options[yy].text) {
            temp_text = what.maker_F.options[yy].text;
            temp_value = what.maker_F.options[yy].value;
            
            what.maker_F.options[yy].text = what.maker_F.options[xx].text;
            what.maker_F.options[yy].value = what.maker_F.options[xx].value;
            
            what.maker_F.options[xx].text = temp_text;
            what.maker_F.options[xx].value = temp_value;
          }
        }
      }
      //Sorting End
    }
    //Dmitriy Tsoy 2007-11-15 End
  }

  function refresh_model3 (what, curr_veh_type, v_mdl)  
  { 
    var v_man = what.maker_F.options[what.maker_F.selectedIndex].value;
    if (v_mdl == '')
      v_mdl = '-Any-';

    var option_selected = new Array;
    var selected_num = 0;
    
    //Dmitriy Tsoy 2007-11-16
    var contain = false;
		for (dd = 1; dd < model_options.length; dd++) {
		  if (model_options[dd][0] == v_man && model_options[dd][2] == curr_veh_type)
      {
        contain = true;
      }
		}
		
		if (!contain) {
		  curr_veh_type = 'V';
		}
    //Dmitriy Tsoy 2007-11-16 End
    
    for (i = 1; i < model_options.length; i++)
    {
      if ( model_options[i][0] == v_man )
      {
        new_yn = 1;
        for (j = 1; j<= selected_num; j++)
        {
          if (option_selected[j] == model_options[i][1])
          { 
            new_yn = 0;
            break;
          }
        }
        if (new_yn == 1)
        {

          //curr_veh_type = "C";

          if (model_options[i][2] == curr_veh_type)
          {
            selected_num++;
            option_selected[selected_num] = model_options[i][1];
          }
        }
      }
    }
    what.model_F.length=0;
    selected = 0;
    j = 0;
    if (model_any == 'Y')
    {
      what.model_F.length++;
      what.model_F.options[j].text = 'MODEL';
      what.model_F.options[j].value = '-Any-';
      j++;
    }
    
    for (i = 1; i <= selected_num; i++)
    {  
      what.model_F.length++;
      if (curr_veh_type != 'N')
      {
        what.model_F.options[j].text = option_selected[i];
      }
      else if (option_selected[i].length > 3 && what.maker_F.options[what.maker_F.selectedIndex].value != 'MG')
      {
        //what.model_F.options[j].text = option_selected[i].charAt(0).toUpperCase();
        
        var model_arr = option_selected[i].split(" ");
        
        if (model_arr.length > 1) {
          var txtOption = '';
          for (c = 0; c < model_arr.length; c++) {
            txtOption = txtOption + model_arr[c].charAt(0).toUpperCase();
            for (sc = 1; sc < model_arr[c].length; sc++) {
              txtOption = txtOption + model_arr[c].charAt(sc).toLowerCase();
            }
            txtOption = txtOption + ' ';
          }
          txtOption = txtOption.substr(0, txtOption.length-1);
          what.model_F.options[j].text = txtOption;
        } else {
          what.model_F.options[j].text = option_selected[i].charAt(0).toUpperCase();
          what.model_F.options[j].text = what.model_F.options[j].text + option_selected[i].substr(1).toLowerCase();
        }
        /*
        for (c = 1; c < option_selected[i].length; c++) {
          if (option_selected[i].charAt(c-1) == ' ')
          {
            //alert ('space: ' + option_selected[i].charAt(c).toUpperCase());
            what.model_F.options[j].text = what.model_F.options[j].text + option_selected[i].charAt(c).toUpperCase();
          }
          else
          {
            //alert ('nospace: ' + option_selected[i].charAt(c).toUpperCase());
            what.model_F.options[j].text = what.model_F.options[j].text + option_selected[i].charAt(c).toLowerCase();
          }
        }
        */
      }
      else
      {
        what.model_F.options[j].text = option_selected[i].toUpperCase();
      }
      if (curr_veh_type != 'N') {
        what.model_F.options[j].value = option_selected[i];
      } else {
        if (what.model_F.options[j].text == 'Vx220')
          what.model_F.options[j].text = 'VX220';
        what.model_F.options[j].value = what.model_F.options[j].text;
      }
      if (what.model_F.options[j].text == v_mdl)
      { 
        selected = 1;
        what.model_F.selectedIndex = j;
      }
      j++;  
    }
    if (selected == 0)
      what.model_F.selectedIndex = 0;

  }

  function update_man_options4 (what, curr_veh_type, v_mdl) 
  { 
    var v_man = what.maker_F.options[what.maker_F.selectedIndex].value;
    if (v_man != '-Any-') 
    {
    	refresh_model3(what, curr_veh_type, v_mdl); return;
    } 
    else 
    {
      if (what.model_F) 
      {
      	what.model_F.length = 1;
  	    what.model_F.options[0].text = 'MODEL';
  	    what.model_F.options[0].value = '-Any-';
  	    what.model_F.selectedIndex = 0;
      } 
    }
  }

  function update_manmod (what, curr_veh_type) 
  {
    var v_man = what.maker_F.options[what.maker_F.selectedIndex].value;
    refresh_manufacturers(what, '', curr_veh_type);
    if (v_man != '-Any-') { refresh_model3(what, curr_veh_type); return; }

    what.model_F.length = 1;
    what.model_F.options[0].text = 'MODEL';
    what.model_F.options[0].value = '-Any-';
    what.model_F.selectedIndex = 0;
  }

  function create_models3 (what, curr_veh_type, v_man, v_mdl) 
  {
    if (v_man == '')
      v_man = '-Any-';
    var i_mdl = what.model_F.selectedIndex;

    refresh_manufacturers(what, v_man, curr_veh_type);

    if (v_man != '-Any-' || curr_veh_type == 'V') { 
      update_man_options4(what, curr_veh_type, v_mdl); 
      if (what.model_F.selectedIndex == 0) what.model_F.selectedIndex = i_mdl;
      return;
    }
		if (what.model_F.options.length <= 1) {
	    what.model_F.length = 1;
	    what.model_F.options[0].selected = true;
	    what.model_F.options[0].text = 'MODEL';
	    what.model_F.options[0].value = '-Any-';
		}
  }
  
  function create_models4 (what, curr_veh_type, v_man, v_mdl) 
  {
    if (v_man == '')
      v_man = '-Any-';

    refresh_manufacturers(what, v_man, curr_veh_type);

    if (v_man != '-Any-' || curr_veh_type == 'V') { 
      update_man_options4(what, curr_veh_type, ''); 
    }
  }

  function create_models_only_maker(what, curr_veh_type, v_man, v_mdl) 
  {
    if (v_man == '')
      v_man = '-Any-';

    refresh_manufacturers(what, v_man, curr_veh_type);
  }
