﻿function SearchOverviewControl() {}

SearchOverviewControl.prototype.enquireUrl = null;

SearchOverviewControl.getClassInstance = function(controlId)
{
    var control = document.getElementById(controlId);
    
    if (control != null && control.classInstance == null)
    {
        var inst = new SearchOverviewControl();

        inst.enquireUrl = control.getAttribute("enquireUrl");

        control.classInstance = inst;
    }
    
    return control == null ? null : control.classInstance;
}

SearchOverviewControl.vehicleModelSelect = function(eventSource)
{
    var controlId = eventSource.getAttribute("controlId");
    var controlName = eventSource.getAttribute("controlName");
    var vehicleMakeId = eventSource.getAttribute("vehicleMakeId");
    var vehicleModelId = eventSource.getAttribute("vehicleModelId");
    var stockCount = eventSource.getAttribute("stockCount");
    var excludeOverview = eventSource.getAttribute("excludeOverview");
    var excludeMake = eventSource.getAttribute("excludeMake");
    
    var inst = SearchOverviewControl.getClassInstance(controlId);

    if (inst != null)
    {
        Utils.createSubmitHidden(
            Utils.getForm(),
            controlName,
            vehicleMakeId + "," + vehicleModelId + "," + excludeOverview + "," + excludeMake);
            
        Utils.getForm().submit();
    }
}
