We're open! Call us on
01442 835 769

var specials = false; var standards = false; var standardsWithPictures = false; var pageSize = 50; var buttonClicked = false; var disableInitialLoad = false; var groupByModelLowestPrice = false; $(document).ready(function () { reloadDropDowns(''); $('.cv-filter-actions select').selectize({ create: false, sortField: 'sortOrder', allowEmptyOption: true }); $('#personal-button').click(function () { $('input#current-page').val(1); $('#personal').val('true'); $('#personal-button').hide(); $('#business-button').show(); $('.small-print .car-business').hide(); $('.filter-header h2').text('Personal Deal Prices'); $('.special-header h2').text('Personal Special Offer Prices'); if (!buttonClicked) { buttonClicked = true; $('#personal-specials-button').click(); buttonClicked = false; } loadVehicles(); }); $('#business-button').click(function () { $('input#current-page').val(1); $('#personal').val('false'); $('#business-button').hide(); $('#personal-button').show(); $('.small-print .car-business').show(); $('.filter-header h2').text('Business Deal Prices'); $('.special-header h2').text('Business Special Offer Prices'); if (!buttonClicked) { buttonClicked = true; $('#business-specials-button').click(); buttonClicked = false; } loadVehicles(); }); if (!disableInitialLoad) { //loadVehicles(); } var personal = $('input#personal').val(); if(personal == 'true'){ $('#business-button').show(); $('#personal-button').hide(); $('.small-print .car-business').hide(); $('.filter-header h2').text('Personal Deal Prices'); $('.special-header h2').text('Personal Special Offer Prices'); }else{ $('#business-button').hide(); $('#personal-button').show(); $('.small-print .car-business').show(); $('.filter-header h2').text('Business Deal Prices'); $('.special-header h2').text('Business Special Offer Prices'); } }); function loadVehicles() { //console.log('loading vehicles - ' + standardsWithPictures); if (specials) loadSpecials(); if (standards) loadStandardList(); if (standardsWithPictures) loadStandardsWithPictures(); } function loadStandardList() { renderLoadingMessage(); var vehicleType = 'Car'; var bodyType = $('select#body-type').val(); var pricePerMonth = $('select#price-per-month').val(); var fuelType = $('select#fuel-type').val(); var transmission = $('select#transmission').val(); var personal = $('input#personal').val(); var manufacturerId = $('input#manufacturer-id').val(); var modelId = $('input#model-id').val(); var currentPage = $('input#current-page').val(); //console.log('loading standard list - page ' + currentPage); jQuery.getJSON('/avvehicle/fetchvehicles.axd', { vehicleType: vehicleType, bodyType: bodyType, fuelType: fuelType, transmission: transmission, pricePerMonth: pricePerMonth, personal: personal, pageSize: pageSize, currentPage: currentPage, specialOnly: false, manufacturerId: manufacturerId, modelId: modelId, groupByModelLowestPrice: groupByModelLowestPrice }, function (data) { var html = ''; var vatText = 'ex'; if (personal !== 'false') { vatText = 'inc'; } var vehicles = data.Vehicles; if (vehicles.length > 0) { jQuery.each(vehicles, function (index, vehicle) { var vehiclePrice = "£" + vehicle.LowestPriceInt; if (vehicle.LowestPriceInt === 0) vehiclePrice = "POA"; html += '
  • '; html += ' ' + vehicle.Name + ''; html += ' '; if (vehicle.PromoText && vehicle.PromoText.length !== 0) html += ' ' + vehicle.PromoText + ''; if (vehicle.BestOffer) html += ' Best Offer'; else if (vehicle.SpecialOffer) html += ' Special Offer'; html += ' ' + vehiclePrice + ' ' + vatText + ' VAT pm'; html += ' View Deal'; html += ' '; html += '
  • '; }); //console.log(data.TotalPages); if (data.TotalPages > 1) { var paging = renderPaging(data.LeftPage, data.MiddlePage, data.RightPage, data.CurrentPage, data.TotalPages); $('#paging').html(paging); $('#paging a').click(function () { $('input#current-page').val($(this).data('page')); loadStandardList(); $(window).scrollTop($('#content').offset().top); }); } else { $('#paging').html(''); } } else { html += '
  • Sorry, there are no vehicles matching your search.
  • '; } $('.cv-offer-list-results').html(html); }); } function loadStandardsWithPictures() { renderStandardsWithPicturesLoadingMessage(); var vehicleType = 'Car'; var bodyType = $('select#body-type').val(); //console.log('loadStandardsWithPictures - ' + bodyType); var pricePerMonth = $('select#price-per-month').val(); var fuelType = $('select#fuel-type').val(); var transmission = $('select#transmission').val(); var personal = $('input#personal').val(); var manufacturerId = $('input#manufacturer-id').val(); var modelId = $('input#model-id').val(); var currentPage = $('input#current-page').val(); jQuery.getJSON('/avvehicle/fetchvehicles.axd', { vehicleType: vehicleType, bodyType: bodyType, fuelType: fuelType, transmission: transmission, pricePerMonth: pricePerMonth, personal: personal, pageSize: 12, currentPage: currentPage, specialOnly: false, manufacturerId: manufacturerId, modelId: modelId, groupByModelLowestPrice: groupByModelLowestPrice }, function (data) { var vatText = 'ex'; if (personal !== 'false') { vatText = 'inc'; } var html = '
    '; var vehicles = data.Vehicles; if (vehicles.length > 0) { jQuery.each(vehicles, function (index, vehicle) { var vehiclePrice = "£" + vehicle.LowestPriceInt; if (vehicle.LowestPriceInt === 0) vehiclePrice = "POA"; html += ''; var indexToCheck = index + 1; //if (indexToCheck % 6 == 0 && indexToCheck != 36) { //html += '
    '; //} }); //console.log('pages - ' + data.TotalPages); if (data.TotalPages > 1) { var paging = renderPaging(data.LeftPage, data.MiddlePage, data.RightPage, data.CurrentPage, data.TotalPages); $('#paging').html(paging); $('#paging a').click(function () { $('input#current-page').val($(this).data('page')); loadStandardsWithPictures(); $(window).scrollTop($('#content').offset().top); }); } else { $('#paging').html(''); } } else { html += '

    Sorry, there are no vehicles matching your search.

    '; } html += '
    '; $('#standard-list-with-pics').html(html); }); } function renderLoadingMessage() { var html = '
  • loading

    Finding your vehicles

  • '; $('.cv-offer-list-results').html(html); } function renderspecialOffersLoadingMessage() { var html = '
    loading

    Finding your vehicles

    '; $('#specials').html(html); } function renderStandardsWithPicturesLoadingMessage() { var html = '
    loading

    Finding your vehicles

    '; $('#standard-list-with-pics').html(html); } function renderPaging(leftPage, middlePage, rightPage, currentPage, totalPages) { var html = ''; html += '
    '; html += ' '; html += '
    '; return html; } function loadSpecials() { renderspecialOffersLoadingMessage(); var vehicleType = 'Car'; var bodyType = $('select#body-type').val(); var pricePerMonth = $('select#price-per-month').val(); var fuelType = $('select#fuel-type').val(); var transmission = $('select#transmission').val(); var personal = $('input#personal').val(); jQuery.getJSON('/avvehicle/fetchvehicles.axd', { vehicleType: vehicleType, bodyType: bodyType, fuelType: fuelType, transmission: transmission, pricePerMonth: pricePerMonth, personal: personal, pageSize: 24, currentPage: 1, specialOnly: true }, function (data) { var vatText = 'ex'; if (personal !== 'false') { vatText = 'inc'; } var html = '
    '; var vehicles = data.Vehicles; if (vehicles.length > 0) { jQuery.each(vehicles, function (index, vehicle) { var vehiclePrice = "£" + vehicle.LowestPriceInt; if (vehicle.LowestPriceInt === 0) vehiclePrice = "POA"; html += ''; var indexToCheck = index + 1; //if (indexToCheck % 6 == 0 && indexToCheck != 36) { // html += '
    ').html(option.DisplayName).text(); //console.log(decode + ' - ' + currentSortId); select.addOption({ value: option.Name, text: decode, sortOrder: currentSortId }); }); select.refreshOptions(); select.enable(); select.setValue(valToSet, false); select.on('change', function () { $('input#current-page').val('1'); //loadVehicles(); reloadDropDowns(dropdown); }); } function setDropDownValue(dropdown, valToSet) { //console.log('setting ddl value - ' + valToSet); var select = $('select#' + dropdown)[0].selectize; select.off('change'); select.disable(); select.clear(); select.refreshOptions(); select.enable(); select.setValue(valToSet, false); select.on('change', function () { $('input#current-page').val('1'); //loadVehicles(); reloadDropDowns(dropdown); }); }
    Need Help? Just ask iVan
    Call us for prices, advice or simply to order now.