﻿function MakeModelChanged()
{
    var Brand = document.getElementById("ctl00_ContentPlaceHolder_MainContent_Hidden_Make").value;
    var Make = Brand;
    
    if (document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Make") != null)
    {
        Make = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Make").value;
    }
    
    var Range = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Range").value;
    var PhotosOnly = document.getElementById("ctl00_ContentPlaceHolder_MainContent_Checkbox_PhotosOnly").checked;    
    
    VehicleSearch.GetVehicleCount(Brand, Make, Range, '', '', '', '', '', '', '', '', PhotosOnly, ShowVehicleCount);
}

function SearchCritiriaChanged()
{
    var Brand = document.getElementById("ctl00_ContentPlaceHolder_MainContent_Hidden_Make").value;
    var Make = Brand;
    
    if (document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Make") != null)
    {
        Make = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Make").value;
    }
    
    var Range = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Range").value;
    var BodyStyle = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Style").value;
    var TransmissionType = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Transmission").value;
    var FuelType = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Fuel").value;
    var MinPrice = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_MinPrice").value;
    var MaxPrice = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_MaxPrice").value;
    var Age = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Age").value;
    var Mileage = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Mileage").value;
    var Keyword = document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Keyword").value;
    var PhotosOnly = document.getElementById("ctl00_ContentPlaceHolder_MainContent_Checkbox_PhotosOnly").checked;    
    
    VehicleSearch.GetVehicleCount(Brand, Make, Range, BodyStyle, TransmissionType, FuelType, MinPrice, MaxPrice, Age, Mileage, Keyword, PhotosOnly, ShowVehicleCount);
}

function ShowVehicleCount(_Result)
{
    document.getElementById("ctl00_ContentPlaceHolder_MainContent_Label_VehicleCount").innerHTML = _Result;
}

function ValidateUsedSearch()
{
    if (document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Range").value == "")
    {
        alert("Please select a Model");
        return false;
    }
}

function ValidateNewSearch()
{
    if (document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_New_Range").value == "")
    {
        alert("Please select a Model");
        return false;
    }
}

function ResetRange()
{
    document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Range").value = "";
}

