
// CAP Tabs 
function ShowCAPTab(intTabShow) {
    var objTab;
    var objTabData;
    for (intTab=0;intTab<CAPTab.TabIds.length;intTab++) {
        objTab = document.getElementById(CAPTab.TabIds[intTab]);
        objTabData = document.getElementById(CAPTab.TabDataIds[intTab]);
        objTab.style.backgroundImage = CAPTab.TabBG;
        objTab.style.color = CAPTab.TabColor;
        objTabData.style.display = CAPTab.TabDisplay
    }
    objTab = document.getElementById(CAPTab.TabIds[intTabShow]);
    objTabData = document.getElementById(CAPTab.TabDataIds[intTabShow]);
    objTab.style.backgroundImage = CAPTab.ActiveTabBG;
    objTab.style.color = CAPTab.ActiveTabColor;
    objTabData.style.display = CAPTab.ActiveTabDisplay
}

function Tab() {
    this.TabBG            = 'url(/images/prices/cap_tab.gif)';
    this.TabColor         = '#154c8c';
    this.TabDisplay       = 'none';
    this.ActiveTabBG      = 'url(/images/prices/cap_tab_over.gif)';
    this.ActiveTabColor   = '#ffffff';
    this.ActiveTabDisplay = 'block';
    this.TabIds           = ['CAPOptionsTab',
                             'CAPStandardTab'];
    this.TabDataIds       = ['CAPOptionsData',
                             'CAPStandardData'];
    this.ShowOptions      = function ShowOptions()  { ShowCAPTab(0) };
    this.ShowStandard     = function ShowStandard() { ShowCAPTab(1) }
}
var CAPTab = new Tab();


// Advanced Search
var makeSearchTotals = {
    getTotals:
    function () {
        var url = "/search_count.aspx";
        var make = $("span.MakeSearch").html();
        url += "?BodyType=&Make=" + make + "&Model=&Transmission=&Co2To=999&Co2From=0&P11dTo=500000&P11dFrom=0&RentalTo=5000&RentalFrom=0&FuelType=";
        $.get(url,
            function (data) {
                var count = $(data).find("All").text();
                $("span.MakeSearchTotals").html('<b>' + count + ' ' + make + ' found</b>. <br />Too Many? Why not try our <a href="/search.aspx">Advanced Search</a>.')
            }
        );
    }
}

// Document Ready
$(document).ready(
    function () {
        if ($("span.MakeSearchTotals").html() != null) {
            if ($("span.MakeSearchTotals").html().indexOf("Loading") != -1) {
                makeSearchTotals.getTotals();
            }
        }
    }
);

// End

