﻿function GetVehicleCount()
{
    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;        
}

function GetVehicleCountComplete(_Result)
{
    document.getElementById("ctl00_ContentPlaceHolder_MainContent_Label_VehicleCount").innerHTML = _Result;
}

function ValidateUsedSearch()
{
    if (document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_Make").value == "")
    {
        alert("Please select a Make");
        return false;
    }
    
    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_Make").value == "")
    {
        alert("Please select a Make");
        return false;
    }
    
    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 = "";
}

function ResetRangeNew()
{
    document.getElementById("ctl00_ContentPlaceHolder_MainContent_DropDownList_New_Range").value = "";
}

function DoDealerSearch()
{
    if (document.getElementById('ctl00_ContentPlaceHolder_MainContent_txtPostcode').value == 'Enter your postcode'
        || document.getElementById('ctl00_ContentPlaceHolder_MainContent_txtPostcode').value == 'Postcode'
        || document.getElementById('ctl00_ContentPlaceHolder_MainContent_txtPostcode').value == '' )
    {
        alert('Please enter your postcode.');
        return false;
    }
}


function txtPostcode_OnFocus()
{
    if(document.getElementById('ctl00_ContentPlaceHolder_MainContent_txtPostcode').value == 'Enter your postcode')
    {
        document.getElementById('ctl00_ContentPlaceHolder_MainContent_txtPostcode').value = '';
    }
}

