function setupViews() {

    var view_container = $('views');
    new Insertion.Top(view_container, '<div id="view-buttons"></div>');
    var buttons = $('view-buttons');

    $$('#views div.view').each( function (v) {
        var t = v.getElementsBySelector('h3.view-title')[0];
        t.id = 'button-'+v.id;
        t.addClassName('view-button');
        buttons.appendChild(t);

        Event.observe(t, 'click', function() {
            hideViews();
            showView(v.id);
        });
    });

    hideViews();
    showView($$('#views div.view')[1].id);

    var foundzero = $$('p.foundzero');
    if (foundzero.length == 1) $('button-view_map').style.display = 'none';
}

function hideViews() {
    $('view_grid').style.display = 'none';
    $$('#views div.view').each( function (v) {
        $('button-'+v.id).removeClassName('button-active');
    });
}

function showView(id) {
    $(id).style.display = 'block';
    $('button-'+id).addClassName('button-active');
    $('view-buttons').style.display = 'block';
}
