$(document).ready(function () {
$("#selectManufacturer").change(function() {
$("#selectEngineSize").html('');
$("#selectEngineSize").attr("disabled", "disabled");
$("#selectColour").html('');
$("#selectColour").attr("disabled", "disabled");
if ($(this).val() == "") {
$("#selectModel").html('');
$("#selectModel").attr("disabled", "disabled");
return;
}
$.getJSON("/javascript/cascade_models.js",{manufacturer_id: $(this).val()}, function(j) {
options = '';
for (var i = 0; i < j.length; i++) {
if (typeof j[i] == 'object') {
options += '';
}
}
if (j.length) {
$("#selectModel").html(options);
$("#selectModel").removeAttr("disabled");
$("#selectModel option:first").attr("selected", "selected");
}
else {
$("#selectModel").html('');
$("#selectModel").attr("disabled", "disabled");
}
})
})
$("#selectModel").change(function() {
$("#selectColour").html('');
$("#selectColour").attr("disabled", "disabled");
$.getJSON("/javascript/cascade_models.js",{model_id: $(this).val()}, function(j) {
options = '';
for (var i = 0; i < j.length; i++) {
if (typeof j[i] == 'object') {
options += '';
}
}
if (j.length) {
$("#selectEngineSize").html(options);
$("#selectEngineSize").removeAttr("disabled");
$("#selectEngineSize option:first").attr("selected", "selected");
}
else {
$("#selectEngineSize").html('');
$("#selectEngineSize").attr("disabled", "disabled");
}
})
})
$("#selectEngineSize").change(function() {
$.getJSON("/javascript/cascade_models.js",{engine_size_id: $(this).val()}, function(j) {
options = '';
for (var i = 0; i < j.length; i++) {
if (typeof j[i] == 'object') {
options += '';
}
}
if (j.length) {
if (j.length > 1) {
options = '' + options;
}
$("#selectColour").html(options);
$("#selectColour").removeAttr("disabled");
$("#selectColour option:first").attr("selected", "selected");
}
else {
$("#selectColour").html('');
$("#selectColour").attr("disabled", "disabled");
}
})
})
// quick search
$("#selectModel2").attr("disabled", "disabled");
$("#selectManufacturer2").change(function() {
if ($(this).val() == "") {
$("#selectModel2").html('');
$("#selectModel2").attr("disabled", "disabled");
return;
}
$.getJSON("/javascript/cascade_models.js",{manufacturer_id: $(this).val()}, function(j) {
options = '';
for (var i = 0; i < j.length; i++) {
if (typeof j[i] == 'object') {
options += '';
}
}
if (j.length) {
$("#selectModel2").html(options);
$("#selectModel2").removeAttr("disabled");
$("#selectModel2 option:first").attr("selected", "selected");
}
else {
$("#selectModel2").html('');
$("#selectModel2").attr("disabled", "disabled");
}
})
})
$("#selectModel2").change(function() {
window.location.replace("/search.html?parent=" + $("#selectManufacturer2").val() + "&cat=" + $(this).val());
})
$("#duration").change(function() {
term = $(this).val();
term = term.substring(0,2);
options = '';
if(term == 24)
{
options += '';
options += '';
options += '';
options += '';
}
else if(term == 36)
{
options += '';
options += '';
options += '';
options += '';
options += '';
}
else if(term == 48)
{
options += '';
options += '';
options += '';
options += '';
options += '';
}
else if(term == 60)
{
options += '';
options += '';
options += '';
options += '';
options += '';
}
else
{
options += '';
options += '';
options += '';
options += '';
options += '';
}
$("#spread").empty().append(options);
})
})