arrmodels=new Array();
arrmakes=new Array();
	
	function initMake_form(){
		var oList2 = document.theform_1.ddMake_form;
		clearDynaList(oList2);
		oList2[oList2.length]= new Option("All Makes");
	}
	function initModel_form(){
		var oList3 = document.theform_1.ddModel_form;
		clearDynaList(oList3);
		oList3[oList3.length]= new Option("All Models");
	}
	function initYear_form(){
		var oList4 = document.theform_1.ddYear_form;
		clearDynaList(oList4);
		oList4[oList4.length]= new Option("All Years","0");
	}

	function  searchInventory_default_form(){
		changenewused_form();
	}
	function changenewused_form(){
		var oList2 = document.theform_1.ddMake_form;
		var status=""; 
 
	initMake_form();
	initModel_form();
	initYear_form();
	//get the new/used cars array
	//status=document.theform_1.ddNewused_form.options[document.theform_1.ddNewused_form.selectedIndex].value
  for(var i=0;i<2;i++){
      if (document.theform_1.ddNewused_form[i].checked){
        status=document.theform_1.ddNewused_form[i].value 
    }
  }
	arr_cars=return_array(cars,status);
	populateDynaList(oList2, arr_cars);
 	return true;
}
	function changemakes_form(){
		var oList2=document.theform_1.ddMake_form;
		var oList3=document.theform_1.ddModel_form;
		var arrList="";
		var status="";
		var make="";
		if (oList2.selectedIndex==-1){
  		oList2.selectedIndex = 0;
		 }
	initModel_form();
	initYear_form();
	//get the models for the selected make car;
	if (oList2.selectedIndex!=0){
	//status=document.theform_1.ddNewused_form.options[document.theform_1.ddNewused_form.selectedIndex].value
	if (document.theform_1.ddNewused_form[0].checked){
    status=document.theform_1.ddNewused_form[0].value 
  }
  if (document.theform_1.ddNewused_form[1].checked){
    status=document.theform_1.ddNewused_form[1].value 
  }
	make=document.theform_1.ddMake_form.options[document.theform_1.ddMake_form.selectedIndex].value	
	arr_models=return_array(arrmakes[make],status);
	populateDynaList(oList3, arr_models);
	return true;
	}
}

	function changemodels_form(){
		var oList4=document.theform_1.ddYear_form;
		var oList3=document.theform_1.ddModel_form;
		var arrList="";
		var status="";
		var make="";
		if (oList3.selectedIndex==-1){
  		oList3.selectedIndex = 0;
		 }
	initYear_form();
	//get the years for the selected make model;
	if (oList3.selectedIndex!=0){
	//status=document.theform_1.ddNewused_form.options[document.theform_1.ddNewused_form.selectedIndex].value
	if (document.theform_1.ddNewused_form[0].checked){
    status=document.theform_1.ddNewused_form[0].value 
  }
  if (document.theform_1.ddNewused_form[1].checked){
    status=document.theform_1.ddNewused_form[1].value 
  }
	model=document.theform_1.ddModel_form.options[document.theform_1.ddModel_form.selectedIndex].value	
	arr_years=return_array(arrmodels[model],status);
	populateDynaList(oList4, arr_years);
	return true;
	}
}
	//get the arrays from the string
	function return_array(cars,status){
	if (status=='n'){
	var j=0;
	arr_cars=new Array();
	apairs=cars.split(',');
	for(var i=0;i<apairs.length;i++){
		singleapair=apairs[i].split('#');
		   if(singleapair[1]=='1'||singleapair[1]=='3'){
			arr_cars[j]=singleapair[0];
			j++;		  
		   }
	}
	return arr_cars
        }//end of new car array
        if(status=='u') {
	var j=0;
	arr_cars=new Array();
	apairs=cars.split(',');
	for(var i=0;i<apairs.length;i++){
		singleapair=apairs[i].split('#');
		   if(singleapair[1]=='2'||singleapair[1]=='3'){
			arr_cars[j]=singleapair[0];
			j++;		  
		   }
	}
	return arr_cars
	}//end of used car array
}
	//clear the list
	function clearDynaList(oList){
 		for (var i = oList.options.length; i >= 0; i--){
 		oList.options[i] = null;
 		} 
		oList.selectedIndex = -1;
}
	//added options to the list
	function populateDynaList(oList, aArray){
 		for (var i = 0; i < aArray.length; i= i + 1){
   			oList.options[oList.options.length] = new Option(aArray[i], aArray[i]);
  		}
 		oList.selectedIndex = 0; 		
}


