/*global define */
/*jshint indent:4 */

define(['AppParams', 'jquery'], function (AppParams, $) {
    "use strict";

    var $postsViewStyleThumbnail = $('#posts-view-style-thumbnail');
    var $postsViewStyleTable = $('#posts-view-style-table');

    var $postsTableView = $("#posts-table-view");
    var $postsThumbnailView = $("#posts-thumbnail-view");

    var changeViewStyle = function (style) {
        if (style === "table") {
            $postsTableView.removeClass("hidden");
            $postsThumbnailView.addClass("hidden");
        } else {
            $postsTableView.addClass("hidden");
            $postsThumbnailView.removeClass("hidden");
        }

        $.ajax({
            url: "?posts_view_style=" + style,
            type: "HEAD"
        });
    };

    $postsViewStyleTable.on("click", function () {
        changeViewStyle("table");
    });

    $postsViewStyleThumbnail.on("click", function () {
        changeViewStyle("thumbnail");
    });

    var $statusTypeMenuDropdown = $("#status-type-menu-dropdown");

    $statusTypeMenuDropdown.on("click", function (e) {
        if (AppParams.accountEditable === true && e.target.className.match(/type/) !== null) {
            e.preventDefault();
        }
    });
});

@@ -1235,13 +1235,832 @@
 %0A    %7D);
+%0A%0A    var $stockSelect = $(%22#stock-select%22);%0A%0A    $stockSelect.on(%22change%22, function (e) %7B%0A        var value = e.target.value.split(%22;%22);%0A        var status;%0A        var make = value%5B0%5D;%0A        var model = %22%22;%0A        var url;%0A%0A        if (! AppParams.status %7C%7C AppParams.status === %22active%22) %7B%0A            status = %22%22;%0A        %7D else %7B%0A            status = AppParams.status;%0A        %7D%0A%0A        var requestParams = %7B%7D;%0A%0A        if (status) %7B%0A            requestParams.status = status;%0A        %7D%0A%0A        if (make) %7B%0A            requestParams.make = make;%0A        %7D%0A%0A        if (value.length === 2) %7B%0A            model = value%5B1%5D;%0A            requestParams.model = model;%0A        %7D%0A%0A        url = $.param(requestParams);%0A%0A        if (url) %7B%0A            url = %22?%22 + url;%0A        %7D%0A%0A        window.location = url;%0A    %7D);
 %0A%7D);%0A

add script to filter the results when the stock-select is used