<!--
var CP = "";
var _year;
var _make;
var _model;
var _sub=0;
function getResults(year, make, model) {
        var url = '/apps/sentry/jdao.jsp'; 
        var params = 'year='+year+'&make='+make+'&model='+model.replace("&", "___")+'&r='+Math.random ( );
        var myAjax = new Ajax.Request(url,{method:'post',parameters:params,onComplete:evalData});
		//alert('calling....');
}

function evalData(originalRequest) {
        //alert('eval....'+originalRequest.responseText);
        try {
            eval(originalRequest.responseText);
        } catch(Ex) {
            return;
        }
		var theyear= document.drop_list.year.options[document.drop_list.year.selectedIndex].value;
		var themake= document.drop_list.make.options[document.drop_list.make.selectedIndex].value;
		var themodel= document.drop_list.model.options[document.drop_list.model.selectedIndex].value;
		removeAllOptions(document.drop_list.year);
		fillYear(year_array, theyear);
		removeAllOptions(document.drop_list.make);
		fillMake(make_array,themake);
		removeAllOptions(document.drop_list.model);
		fillModel(model_array,themodel);
		if(!isEmpty(document.drop_list.elements['year'].value)
		&& !isEmpty(document.drop_list.elements['make'].value)
		&& !isEmpty(document.drop_list.elements['model'].value)
              && _sub
		){
		//alert("----------");
		document.drop_list.uc_rateindex.value = data_array[0];
		
		document.drop_list.htr_flag.value = data_array[1];
		//alert(htr_flag);
		document.drop_list.dynamco_partno.value = data_array[2];
		document.drop_list.i_store_url.value = data_array[3];
		/*
		var qs='?year='+year+'&make='+escape(make)+'&model='+escape(model)
		      +'&uc_rateindex='+escape(document.drop_list.uc_rateindex.value)
			  +'&htr_flag='+escape(document.drop_list.htr_flag.value)
			  +'&dynamco_partno='+escape(document.drop_list.dynamco_partno.value);
	    self.location.href='fit2.shtml'+qs;
		alert('fit2.shtml'+qs);
		*/
		var int_uc_rateindex= parseInt(data_array[0]);
		var int_htr_flag= parseInt(data_array[0]);
		var str_dynamco_partno= data_array[2];
		if(isEmpty(str_dynamco_partno)){
                if(isNaN(int_uc_rateindex)) {
		    document.drop_list.action='vehicle-sorry.shtml';
                } else {
		    document.drop_list.action='vehicle-sorry_rates.shtml';
                }
		}else{
		    if(int_uc_rateindex > 100){
		        document.drop_list.action='vehicle-over.shtml';
		    }else {
		        document.drop_list.action='vehicle-under.shtml';
		    }
		}
		//alert('--------'+document.drop_list.action);
		document.drop_list.submit();
		}
		//alert(document.drop_list.dynamco_partno.value);
		//alert(year_array.length);
}

function fillYear(year_array,theyear){ 
 // this function is used to fill the category list on load
    for (var i=0; i < year_array.length;++i){
	if(theyear == year_array[i]){
	addOption(document.drop_list.year, year_array[i], year_array[i],true);
	}else{
	addOption(document.drop_list.year, year_array[i], year_array[i],false);
	}
    }
}
function fillMake(make_array, themake){ 
 // this function is used to fill the category list on load
    for (var i=0; i < make_array.length;++i){
	if(themake == make_array[i]){
	addOption(document.drop_list.make, make_array[i], make_array[i],true);
	}else{
	addOption(document.drop_list.make, make_array[i], make_array[i],false);
	}
    }
}

function fillModel(model_array,themodel){ 
 // this function is used to fill the category list on load
    for (var i=0; i < model_array.length;++i){
	if(themodel == model_array[i]){
	addOption(document.drop_list.model, model_array[i], model_array[i],true);
	}else{
	addOption(document.drop_list.model, model_array[i], model_array[i],false);
	}
    }
}

function selectYear(){
// ON selection of category this function will work
//getResults(document.drop_list.year.options[document.drop_list.year.selectedIndex].value,'','');
getResults(document.drop_list.year.options[document.drop_list.year.selectedIndex].value,document.drop_list.make.options[document.drop_list.make.selectedIndex].value,'');
//

}

function selectMake(){
// ON selection of category this function will work
getResults(document.drop_list.year.options[document.drop_list.year.selectedIndex].value,document.drop_list.make.options[document.drop_list.make.selectedIndex].value,'');
//

}

function selectModel(){
// ON selection of category this function will work
//getResults(document.drop_list.year.options[document.drop_list.year.selectedIndex].value,document.drop_list.make.options[document.drop_list.make.selectedIndex].value,document.drop_list.model.options[document.drop_list.model.selectedIndex].value);
//
}

function checkForm(){
// validate the form
    msg = "";
	
    if(isEmpty(document.drop_list.elements['year'].value)){
        msg += "    Year\n";
    }
    if(isEmpty(document.drop_list.elements['make'].value)){
        msg += "    Make\n";
    }
	if(isEmpty(document.drop_list.elements['model'].value)){
        msg += "    Model\n";
    }
    if (msg != "") {
        alert("You forgot to enter the following information:  \n"+msg);
        return false;
    }else{
		_sub=1;
	    getResults(document.drop_list.year.options[document.drop_list.year.selectedIndex].value,document.drop_list.make.options[document.drop_list.make.selectedIndex].value,document.drop_list.elements['model'].value);
		//alert(document.drop_list.dynamco_partno.value);
	    //document.drop_list.submit();
	}
	return false;
//
}
function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '')
};

function isEmpty(strng) {
  strng = trim(strng);
  if (strng.length == 0 || strng == 'null') {
     return true;
  }
return false;	  
}

////////////////// 

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=1;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}


function addOption(selectbox, value, text,selected )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	optn.selected = selected;
	selectbox.options.add(optn);
}

//-->