function createOption(strValue, intNum, intCurLen)
{
  if (intNum < intCurLen)
  {
    window.document.formAutoSell.selectModels.options[intNum].text = strValue;
    window.document.formAutoSell.selectModels.options[intNum].value = strValue;
  }
  else
  {
    window.document.formAutoSell.selectModels.options[intNum] = new Option(strValue, strValue, false, false);
  }
}
function changeMake()
{
  intCurLength = window.document.formAutoSell.selectModels.length;
  if (!intCurLength)
    intCurLength = 0;
  
  intCurMake = window.document.formAutoSell['bi_make'].selectedIndex;
  strCurMake = window.document.formAutoSell['bi_make'].options[intCurMake].text;
  if (intCurMake < arrCarMakes.length)
  {
    createOption("All Models", 0, intCurLength);
    for (i = 0; i < arrCarModels[strCurMake].length; i++)
    {
      createOption(arrCarModels[strCurMake][i], i+1, intCurLength);
    }
    i++;
    createOption('',i,intCurLength)
    i++;
    createOption('===================', i, intCurLength);
    i++;
    intDiff = intCurLength - i;
    if (intDiff)
    {
      intStart = i;
      for (i = 0; i < intDiff; i++)
      {
        window.document.formAutoSell.selectModels.options[intStart] = null;
      }
    }
  }
  window.document.formAutoSell.selectModels.selectedIndex = 0;
}

function init()
{
  changeMake();
}

function checkFields(strMake, strModel)
{
  for (i = 0; i < arrCarMakes.length; i++)
  {
    if (strMake == arrCarMakes[i])
      window.document.formAutoSell['bi_make'].selectedIndex = i;
  }  

  changeModel()
  intCurMake = window.document.formAutoSell['bi_make'].selectedIndex;
  strCurMake = window.document.formAutoSell['bi_make'].options[intCurMake].text;

  for (i = 0; i < arrCarModels[strCurMake].length; i++)
  {
    if (strModel == arrCarModels[strCurMake][i])
      window.document.formAutoSell.selectModels.selectedIndex = i + 1;
  }
}


