function checkAndClear() {
    if (document.getElementById("q").value.match('Всего')) {
        insertWord('');
    }
}

function insertWord(word) {
    document.getElementById("q").value = word;
    document.getElementById("q").style.color = "black";
}

function setBlockBg(mouseover, element, color) {
    if ($(element).css("background-color") != "rgb(235, 237, 232)") {
        if (mouseover) {
            $(element).css("background", "#ECEBD4 none repeat scroll 0 0");
        } else {
            $(element).css("background", color + " none repeat scroll 0 0");
        }
    }
}

function setOfferButtonImg(mouseover, element, color) {
    if ($(element).css("background-color") != "rgb(235, 237, 232)") {
        if (mouseover) {
            $(element).css("background", "#ECEBD4 none repeat scroll 0 0");
        } else {
            $(element).css("background", color + " none repeat scroll 0 0");
        }
    }
}

jQuery(document).ready(function() {
    //track submit
    $('#search').submit(function() {
        var query = jQuery('#q').val().trim();
        return query != '' && query.indexOf('Всего') == -1 && query.indexOf('предлож') == -1;
    });
});

$(function() {
    $("#offerButtonImg")
        .mouseover(function() {
            $(this).attr("src", "/media/img/public/offer_button_over.png");
        })
        .mouseout(function() {
            var src = $(this).attr("src").replace("_over", "");
            $(this).attr("src", src);
        });
});

$(function() {
    // Accordion
    if (parentIndex == undefined) {
        $("#accordion").accordion({
            header: "h3",
            active: false,
            autoHeight: false,
            collapsible: true
        });
    } else {
        $("#accordion").accordion({
            header: "h3",
            active: parseInt(parentIndex),
            autoHeight: false,
            collapsible: true
        });
    }
});