var ajax = new Array();
var init = true;
var inip = true;

function getYearsList(sel)
{
   var yearCode = sel.options[sel.selectedIndex].value;
   document.getElementById('sel2').options.length = 0;
   if(yearCode.length>0){
      var index = ajax.length;
      ajax[index] = new sack();

      ajax[index].requestFile = 'getYears.php?modelCode='+yearCode;
      ajax[index].onCompletion = function(){ createYears(index) };
      ajax[index].runAJAX();
   }
}

function createYears(index)
{
   var obj = document.getElementById('sel2');
   eval(ajax[index].response);
}

function getModelsList(sel)
{
    if(init){
      document.getElementById('sel1').options.length = 0;
      var index = ajax.length;
      ajax[index] = new sack();

      ajax[index].requestFile = 'getModels.php';
      ajax[index].onCompletion = function(){ createSubCategories(index) };
      ajax[index].runAJAX();
      init = false;
    }
}
function createSubCategories(index)
{
   var obj = document.getElementById('sel1');
   eval(ajax[index].response);
}

function getProducerList(sel)
{
    if(inip){
      document.getElementById('pro').options.length = 0;
      var index = ajax.length;
      ajax[index] = new sack();

      ajax[index].requestFile = 'getProducer.php';
      ajax[index].onCompletion = function(){ createProducers(index) };
      ajax[index].runAJAX();
      inip = false;
    }
}
function createProducers(index)
{
   var obj = document.getElementById('pro');
   eval(ajax[index].response);
}

