/* Browse Functions */

var datapage = "view-list.php";
var currentsort = "id";

function sortby_newest() {
    new Ajax.Updater("flyer_browser","http://www.fly-post.com/modules/user-pages/ajax/" + datapage + "?sort=id", { evalScripts: true });
    currentsort = "id";
    window.scrollTo(0,1);
}

function sortby_best() {
    new Ajax.Updater("flyer_browser","http://www.fly-post.com/modules/user-pages/ajax/" + datapage + "?sort=rating", { evalScripts: true });
    currentsort = "rating";
    window.scrollTo(0,1);
}

function sortby_popular() {
    new Ajax.Updater("flyer_browser","http://www.fly-post.com/modules/user-pages/ajax/" + datapage + "?sort=rsvps", { evalScripts: true });
    currentsort = "rsvps";
    window.scrollTo(0,1);
}

function sortby_now() {
    new Ajax.Updater("flyer_browser","http://www.fly-post.com/modules/user-pages/ajax/" + datapage + "?sort=start_date", { evalScripts: true });
    currentsort = "start_date";
    window.scrollTo(0,1);
}

function changePage(page) {
    new Ajax.Updater("flyer_browser","http://www.fly-post.com/modules/user-pages/ajax/" + datapage + "?sort=" + currentsort + "&page=" + page + "", { evalScripts: true });
    window.scrollTo(0,1);
}

function switch_normal() {
    $('small_thumb').src = "http://www.fly-post.com/images/small_thumb_off.png";
    $('med_thumb').src = "http://www.fly-post.com/images/med_thumb_on.png";
    datapage = "view-thumbs.php";
    if (currentsort == "id")
    	sortby_newest();
    if (currentsort == "rating")
    	sortby_best();
    if (currentsort == "rsvps")
    	sortby_popular();
    if (currentsort == "start_date")
    	sortby_now();
}

function switch_list() {
    $('small_thumb').src = "http://www.fly-post.com/images/small_thumb_on.png";
    $('med_thumb').src = "http://www.fly-post.com/images/med_thumb_off.png";
    datapage = "view-list.php";
    if (currentsort == "id")
    	sortby_newest();
    if (currentsort == "rating")
    	sortby_best();
    if (currentsort == "rsvps")
    	sortby_popular();
    if (currentsort == "start_date")
    	sortby_now();
}