function sbv_init_custom(name) {	
        document.write("<table border='0' width='100%'>");
        document.write("<tr><td><select name='year' id='shop_by_vehicle_year_custom'></select></td></tr>");
        document.write("<tr><td><select name='make' id='shop_by_vehicle_make_custom'><option value=''>Select Make</option></select></td></tr>");
        document.write("<tr><td><select name='model' id='shop_by_vehicle_model_custom'><option value=''>Select Model</option></select></td></tr>");
        document.write("<tr><td><select name='submodel' id='shop_by_vehicle_submodel_custom'><option value=''>Select Sub Model</option></select></td></tr>");
        document.write("<tr><td><select name='engine' id='shop_by_vehicle_engine_custom'><option value=''>Select Engine</option></select></td></tr>");
        document.write("</table>");
        $("#shop_by_vehicle_year_custom").removeAttr("disabled","disabled");
    	$("#shop_by_vehicle_make_custom").attr("disabled","disabled");
    	$("#shop_by_vehicle_model_custom").attr("disabled","disabled");

        sbv_loadyears_custom(name);
}
function sbv_loadyears_custom(name) {
	var CatalogName = name;
	$('#shop_by_vehicle_year_custom').append($('<option></option>').val("").html("Select Year"));
    $.getJSON("/_scripts/AjaxShopByVehicleCustom.cfm?RequestType=GetYears&Name="+CatalogName, function(data) {
    	$.each(data, function(i,year){
    		$('#shop_by_vehicle_year_custom').append(
    			$('<option></option>').val(year).html(year)
    		);
          });
    });
    
    $('#shop_by_vehicle_year_custom').change(function(event) {
        var selectedYear = $('#shop_by_vehicle_year_custom').val();
        $('#shop_by_vehicle_make_custom').empty();
        $('#shop_by_vehicle_make_custom').append($('<option></option>').val("").html("Select Make"));

        $.getJSON("/_scripts/AjaxShopByVehicleCustom.cfm?Name="+escape(CatalogName)+"&RequestType=GetMakes&Year="+escape(selectedYear), function(data) {
        	$.each(data, function (i, make) {
	        	$('#shop_by_vehicle_make_custom').append(
	        			$('<option></option>').val(make).html(make)
	        	);
        	});
            $("#shop_by_vehicle_make_custom").removeAttr("disabled","disabled");
            $("#shop_by_vehicle_model_custom").attr("disabled","disabled");
            $("#shop_by_vehicle_submodel_custom").attr("disabled","disabled");
            $("#shop_by_vehicle_engine_custom").attr("disabled","disabled");            
       });     
    });
    $('#shop_by_vehicle_make_custom').change(function(event) {    	
        var selectedYear = $('#shop_by_vehicle_year_custom').val();
        var selectedMake = $('#shop_by_vehicle_make_custom').val();
        $('#shop_by_vehicle_model_custom').empty();
        $('#shop_by_vehicle_model_custom').append($('<option></option>').val("").html("Select A Model"));
        $.getJSON("/_scripts/AjaxShopByVehicleCustom.cfm?Name="+escape(CatalogName)+"&RequestType=GetModels&Year="+escape(selectedYear)+"&Make="+escape(selectedMake), function(data) {
        	$.each(data, function (i, model) {
	        	$('#shop_by_vehicle_model_custom').append(
	        			$('<option></option>').val(model).html(model)
	        	);
        	});        	
            $("#shop_by_vehicle_model_custom").removeAttr("disabled","disabled");
            $("#shop_by_vehicle_submodel_custom").attr("disabled","disabled");
            $("#shop_by_vehicle_engine_custom").attr("disabled","disabled");            
       });               
    });
    $('#shop_by_vehicle_model_custom').change(function(event) {
        var selectedYear = $('#shop_by_vehicle_year_custom').val();
        var selectedMake = $('#shop_by_vehicle_make_custom').val();
        var selectedModel = $('#shop_by_vehicle_model_custom').val();
        $("#shop_by_vehicle_engine_custom").attr("disabled","disabled");
        $('#shop_by_vehicle_submodel_custom').empty();
        $('#shop_by_vehicle_submodel_custom').append($('<option></option>').val("").html("Select A Sub Model"));
        $("#shop_by_vehicle_submodel_custom").show();
        $("#shop_by_vehicle_submodel_custom").css("visibility","visible");
        
        
        $.getJSON("/_scripts/AjaxShopByVehicleCustom.cfm?Name="+escape(CatalogName)+"&RequestType=GetSubModels&Year="+escape(selectedYear)+"&Make="+escape(selectedMake)+"&Model="+escape(selectedModel), function(data) {
        	if (data=="") {
        		$('#shop_by_vehicle_submodel_custom').append($('<option selected></option>').val("").html("BASE"));
        		$("#shop_by_vehicle_submodel_custom").change(); 
        		$("#shop_by_vehicle_engine_custom").removeAttr("disabled","disabled");
        	}
        	else {
        		$.each(data, function (i, submodel) {
        			if (submodel=="") {
        				$('#shop_by_vehicle_submodel_custom').append(
	    	        			$('<option></option>').val("").html("BASE")
	    	        	);        				
        			}
        			else {
	    	        	$('#shop_by_vehicle_submodel_custom').append(
	    	        			$('<option></option>').val(submodel).html(submodel)
	    	        	);
        			}
            	});
        		$("#shop_by_vehicle_engine_custom").attr("disabled","disabled");
        	}
            $("#shop_by_vehicle_submodel_custom").removeAttr("disabled","disabled");
                        
       });                
    });
    $('#shop_by_vehicle_submodel_custom').change(function(event) {
        var selectedYear = $('#shop_by_vehicle_year_custom').val();
        var selectedMake = $('#shop_by_vehicle_make_custom').val();
        var selectedModel = $('#shop_by_vehicle_model_custom').val();
        var selectedSubModel = $('#shop_by_vehicle_submodel_custom').val();
        $("#shop_by_vehicle_engine_custom").removeAttr("disabled","disabled");        
        $('#shop_by_vehicle_engine_custom').empty();
        $("#shop_by_vehicle_engine_custom").show();
        $("#shop_by_vehicle_engine_custom").css("visibility","visible");
        
        totalEngines = 0;
        $.getJSON("/_scripts/AjaxShopByVehicleCustom.cfm?Name="+escape(CatalogName)+"&RequestType=GetEngines&Year="+escape(selectedYear)+"&Make="+escape(selectedMake)+"&Model="+escape(selectedModel)+"&SubModel="+escape(selectedSubModel), function(data) {
        	$.each(data, function (i, engine) {
    	        	$('#shop_by_vehicle_engine_custom').append(
    	        			$('<option></option>').val(i).html(engine)
    	        	);
    	        	totalEngines++;
        	});
	       if (totalEngines==1) {
	            $("#shop_by_vehicle_engine_custom").change(); 
	       }
	       else {
	           $('#shop_by_vehicle_engine_custom').prepend($('<option></option>').val("").html("Select A Engine"));
	           $("#shop_by_vehicle_engine_custom option:eq(0)").attr("selected", "selected");
	           
	       }        	
       });
              
    });
    $('#shop_by_vehicle_engine_custom').change(function(event) {
        var selectedVehicleId = $('#shop_by_vehicle_engine_custom').val();
        var selectedVehicleText = $('#shop_by_vehicle_engine_custom :selected').text();
        var url = "/ECatalogCustom.cfm?CatalogName="+CatalogName+"&RequestType=GetCategories&VehicleId=" +selectedVehicleId + "&EngineName=" + selectedVehicleText;
        $("#shop_by_vehicle_year_custom").attr("disabled","disabled");
        $("#shop_by_vehicle_make_custom").attr("disabled","disabled");
        $("#shop_by_vehicle_model_custom").attr("disabled","disabled");
        $("#shop_by_vehicle_submodel_custom").attr("disabled","disabled");
        $("#shop_by_vehicle_engine_custom").attr("disabled","disabled");
        window.location.href=(url);
        
    });
    
    $("#shop_by_vehicle_make").attr("disabled","disabled");
    $("#shop_by_vehicle_model").attr("disabled","disabled");
    $("#shop_by_vehicle_submodel").attr("disabled","disabled");
    $("#shop_by_vehicle_engine").attr("disabled","disabled");
    $("#shop_by_vehicle_submodel").hide();
    $("#shop_by_vehicle_engine").hide();    
    }
function sbv_expandCategory_custom(CategoryId) {
    $("#Category_"+CategoryId).toggle(300);       
}
