﻿$(document).ready(
    function () {
        $('#ddlCategory').change(function () {
            $('.header .type').hide();
            $('#ddlType' + $(this).val()).show();
            $('.header .price').hide();
            $('#ddlPrice' + $(this).val()).show();
        });

        $('.home .promo .car').click(function () {
            location.href = $(this).find('a').attr('href');
        });

        $('.home .list .car').hover(function () { $(this).addClass('hover'); }, function () { $(this).removeClass('hover'); });
        $('.home .list .car').click(function () {
            location.href = $(this).find('a').attr('href');
        });

        $('#ddlCategory').change();
    }
);

function quickSearch() {
    var sCategory = $('#ddlCategory').val();
    var sType = $('#ddlType' + sCategory).val();
    var sPrice = $('#ddlPrice' + sCategory).val();

    $.ajax(
        {
            url: "/ajax/SimpleSearch.ashx",
            type: "POST",
            data: {
                category: sCategory,
                type: sType,
                price: sPrice
            },
            cache: false,
            dataType: 'text',
            timeout: 10000,
            success: function (resp) {
                    location.href = '/keszletkereso';
            }
        }
    );

    return false;
}

function highlightcar(carId) {
    $(".list tr td span:contains('" + carId + "')").parent().parent().find('td').css('background-color', '#eeeeee');
}

function trackGAEvent(ec, ev, el) {
    try {
        _gaq.push(['_trackEvent', ec, ev, el]);
    } catch (e) { }
}
