(function( $ ) {
    var win = $(window);

    // Each time the user scrolls

    //     win.scroll(function() {
    //     // End of the document reached?
    //     if ($(document).height() - win.height() == win.scrollTop() &&     waveJS.infiniteScroll  ) {
    //
    //     }
    //         console.log("scroll page" + waveJS.paged)
    //
    // });

     $("body").on("click",".more", function(e ){

        waveJS.paged= waveJS.paged+1;
       //console.log("page" + waveJS.paged)
        waveJS.refreshTable({s:$("#wave_search").val(), sf:$("#wave_search_options").val(), paged:  waveJS.paged+1});
        e.stopPropagation();
    });
    $("body").on("click",".view-switch a", function(e)
    {
        //console.log("test viewswitch" + $(this).attr("class"))
        var classmode=$(this).attr("class")

        $(".view-switch a").removeClass("current")
        if (classmode.indexOf("list")>0)
        {
            $(".view-switch a.view-list").addClass("current")
            viewmode="list";
        }
        if (classmode.indexOf("grid")>0)
        {

            $(".view-switch a.view-grid").addClass("current")
            viewmode="grid";
        }

        waveJS.refreshTable({ "viewmode":viewmode })
    })


})( jQuery );;