// JavaScript Document

function clearAll() {
	$("#rtype").html("");
	$("#ryear").html("");
	$("#vehyear").html("<option value=''>Year</option>");
	$("#rmake").html("");
	$("#vehmake").html("<option value=''>Make</option>");
	$("#rengine").html("");
	$("#vehengine").html("<option value=''>Engine</option>");	
	$("#rproducttype").html("");
	$("#vehproducttype").html("<option value=''>Product Type</option>");
	$("#rproductkit").html("");
	$("#vehproductkit").html("<option value=''>Product Kit</option>");	
	$("#sugg-products").hide();
	$("#sugg-kits").hide();
	$("#prod-review").hide();
}

function changepic(type) {
	
	if (type.length){
		clearAll();
		$("div.truck-area").html("<img src='/images/wizard/Banks/truck.gif' />");
		$("#rtype").html(type);
		getyears();
	}
	else {
		clearAll();	
	}
		//clearAll();
		//$("div.truck-area").html("<img src='/images/wizard/Banks/truck.gif' />");	
		//$("#rtype").html("Truck");
		//getyears();
	
}

function getyears() {
	$("#vehyear-container").html("<img src='/images/rotating.gif' />");
	$("#ryear").html("");
	$.ajax({
			type: "GET",
			url: "/order/wizard/banksexhaust/ajax/_getyears.cfm",
			data: "",
			success: function(res){
						$("#vehyear-container").html($.trim(res));
					}
		})	
}

function getmakes() {
	var type = $("#vehtype").val()
	var vehyear = $("#vehyear").val()
	
	$("#rengine").html("");
	$("#vehengine").html("<option value=''>Engine</option>");
	$("#rmake").html("");
	$("#rproducttype").html("");
	$("#vehproducttype").html("<option value=''>Product Type</option>");
	$("#rproductkit").html("");
	$("#vehproductkit").html("<option value=''>Product Kit</option>");	
	$("#sugg-products").hide();
	$("#sugg-kits").hide();
	$("#prod-review").hide();
		
	if (vehyear != "") {
		$("#vehmake-container").html("<img src='/images/rotating.gif' />");
		$.ajax({
			type: "GET",
			url: "/order/wizard/banksexhaust/ajax/_getmakes.cfm",
			data: "type=" + type + "&year=" + vehyear,
			success: function(res){
						$("#ryear").html(vehyear);
						$("#vehmake-container").html($.trim(res));
					}
			})	
	}
	else {
		$("#ryear").html("");
		$("#rmake").html("");
		$("#vehmake").html("<option value=''>Make</option>");
		$("#rproducttype").html("");
		$("#vehproducttype").html("<option value=''>Product Type</option>");
		$("#rproductkit").html("");
		$("#vehproductkit").html("<option value=''>Product Kit</option>");	
		$("#sugg-products").hide();
		$("#prod-review").hide();
	}
}

function getengines() {
	var type = $("#vehtype").val()
	var vehyear = $("#vehyear").val()
	var vehmake = $("#vehmake").val()
	
	$("#sugg-products").hide();
	$("#prod-review").hide();
	$("#rproducttype").html("");
	$("#vehproducttype").html("<option value=''>Product Type</option>");
	$("#rproductkit").html("");
	$("#vehproductkit").html("<option value=''>Product Kit</option>");	
	
	if (vehmake != "") {
		$("#vehmodel-container").html("<img src='/images/rotating.gif' />");
		$.ajax({
			type: "GET",
			url: "/order/wizard/banksexhaust/ajax/_getengines.cfm",
			data: "type=" + type + "&year=" + vehyear + "&make=" + vehmake,
			success: function(res){
						$("#rmake").html(vehmake);
						$("#vehengine-container").html($.trim(res));
					}
			})	
	}
	else {
		$("#rengine").html("");
		$("#vehengine").html("<option value=''>Engine</option>");
		$("#rproducttype").html("");
		$("#vehproducttype").html("<option value=''>Product Type</option>");
		$("#rproductkit").html("");
		$("#vehproductkit").html("<option value=''>Product Kit</option>");	
		$("#rmake").html("");
		$("#sugg-products").hide();
		$("#prod-review").hide();
	}
}


function getproducts() {
	var type = $("#vehtype").val()
	var vehyear = $("#vehyear").val()
	var vehmake = $("#vehmake").val()
	var vehengine = $("#vehengine").val()
	
	$("#sugg-products").hide();
		$("#prod-review").hide();
	$("#rproductkit").html("");
	$("#vehproductkit").html("<option value=''>Product Kit</option>");	
	
	if (vehengine != "") {
		$.ajax({
			type: "GET",
			url: "/order/wizard/banksexhaust/ajax/_getproducts.cfm",
			data: "type=" + type + "&year=" + vehyear + "&make=" + vehmake + "&engine=" + vehengine,
			success: function(res){
						$("#rengine").html(vehengine);
						$("#vehproducttype-container").html($.trim(res));
					}
			})	
	}
	else {
		$("#rproducttype").html("");
		$("#vehproducttype").html("<option value=''>Product Type</option>");
		$("#rengine").html("");
		$("#sugg-products").hide();
		$("#prod-review").hide();
	}
}

function getkits() {
	var type = $("#vehtype").val()
	var vehyear = $("#vehyear").val()
	var vehmake = $("#vehmake").val()
	var vehengine = $("#vehengine").val()
	var vehproducttype = $("#vehproducttype").val()
	
	$("#sugg-products").hide();
		$("#prod-review").hide();
		$("#rproductkit").html("");
		
	if (vehproducttype != "") {
		$.ajax({
			type: "GET",
			url: "/order/wizard/banksexhaust/ajax/_getkits.cfm",
			data: "type=" + type + "&year=" + vehyear + "&make=" + vehmake + "&engine=" + vehengine + "&producttype=" + vehproducttype,
			success: function(res){
						$("#rproducttype").html(vehproducttype);
						$("#vehproductkit-container").html($.trim(res));
					}
			})	
	}
	else {
		
		$("#rproductkit").html("");
		$("#vehproductkit").html("<option value=''>Product Kit</option>");
		$("#rproducttype").html("");
		$("#sugg-products").hide();
		$("#prod-review").hide();
		
	}
}

function getskus() {
	var type = $("#vehtype").val()
	var vehyear = $("#vehyear").val()
	var vehmake = $("#vehmake").val()
	var vehengine = $("#vehengine").val()
	var vehproducttype = $("#vehproducttype").val()
	var vehproductkit = $("#vehproductkit").val()
	
	if (vehproductkit != "") {
		$.ajax({
			type: "GET",
			url: "/order/wizard/banksexhaust/ajax/_getskus.cfm",
			data: "type=" + type + "&year=" + vehyear + "&make=" + vehmake + "&engine=" + vehengine + "&producttype=" + vehproducttype + "&productkit=" + vehproductkit,
			success: function(res){
						$("#rproductkit").html(vehproductkit);
						$("#sugg-products").show();
						$("#sugg-products-results").html($.trim(res));
					}
			})	
	}
	else {
		
		$("#rproductkit").html("");
		$("#sugg-products").hide();
		$("#prod-review").hide();
	}
}

function productreview(skunum) {
	$.ajax({
		type: "GET",
		url: "/order/wizard/banksexhaust/ajax/_prodreview.cfm",
		data: "skunum=" + skunum,
		success: function(res){
					$("#prod-review").show();
					$("#prod-review-detail").html($.trim(res));
					location.href="#prod-review";
				}
		})	
}

function buyit(skunum) {
	$.ajax({
		type: "GET",
		url: "/order/wizard/banksexhaust/ajax/_buyit.cfm",
		data: "skunum=" + skunum,
		success: function(res){
					location.href="/order/";
				}
		})	
}