﻿$(document).ready(function(){
    $("#ButtonRecent").click(function(event){GetPolls("recent");event.preventDefault();});
    $("#ButtonPopular").click(function(event){GetPolls("popular");event.preventDefault();});
    //GetPolls("recent");
    $("#ForumPager").pager({ pagenumber: 1, pagecount: PageCount, buttonClickCallback: PageClick });
    if(parseUri(document.location).anchor == "popular"){
        GetPolls("popular");       
        $("#ContentSections a").removeClass();
        $("#ButtonPopular").addClass("Selected");
    }
});
function GetPolls(m){
    $.get("/ajax/GetPolls.ashx?q="+m+"&s="+s+"&page="+PageIndex+"&pageSize="+PageSize, function(data){
        $("#PollContainer").html(data);
        switch(m){
            case "recent":$("#HeadingPolls").html("Latest "+showName+"  Polls");$("#ForumPager").show();break;
            case "popular":$("#HeadingPolls").html("Popular "+showName+"  Polls");$("#ForumPager").hide();break;
            default:break;
        }         
		statsTracker();
    });
}
PageClick = function(Pageclickednumber) {
    $("#ForumPager").pager({ pagenumber: Pageclickednumber, pagecount: PageCount, buttonClickCallback: PageClick });
    PageIndex = Pageclickednumber;
     $.get("/ajax/GetPolls.ashx?q=recent&s="+s+"&page="+PageIndex+"&pageSize="+PageSize, function(data){
        $("#PollContainer").html(data);
		statsTracker();
    });
    $.scrollTo( 600, 500, {queue:true} );
}

