$(document).delegate('.filter-nav a', 'click', function (e)
{
// get the src for the content we're trying to view
var dataSrc = $(this).attr('data-src');
// determine whether we're trying to sort the existing view
if($(this).attr('data-sort')) {
var dataSort = $(this).attr('data-sort');
} else {
var dataSort = $('.filter-nav > li > a').attr('data-sort');
}
// how many items do we have?
var itemOffset = $('.expandable .listing > li').size();
//find out if we clicked the menu, if so, clear out everything and add data attribute to the load more
if($(this).closest('div').hasClass("filter"))
{
var hiddenDiv = $('<div />', {
"class": "items hidden spacer",
"height": $('.expandable').outerHeight()
});
$('.expandable > .load').before(hiddenDiv);
$('.expandable > ul, .expandable > div:not(.spacer)').remove();
$('.load').attr('data-src',dataSrc);
// Change Class of Dropdown Toggle
var clickedClass = $(this).parent().attr('class');
$("#filter-drop strong").removeClass().addClass(clickedClass);
// Change Text of Dropdown Toggle
var thisLabel = $(this).text();
$("#filter-drop strong span").text(thisLabel);
// Grab datasrc from clicked-on menu item and populate the filters with it
$('.filter-nav a').attr('data-src' , dataSrc);
$('.filter-nav li').removeClass('active');
$('.filter-nav > li').eq(0).addClass('active');
}
//find out if we clicked the filter nav, if so let's switch the active class
if($(this).closest('ul').hasClass("filter-nav")) {
$('.filter-nav li').removeClass('active');
$(this).parent().addClass('active');
//Also let's remove all the items before replacing them with what we want
var hiddenDiv = $('<div />', {
"class": "items hidden spacer",
"height": $('.expandable').outerHeight()
});
$('.expandable > .load').before(hiddenDiv);
$('.expandable > ul, .expandable > div:not(.spacer)').remove();
}
$.get(dataSrc, { offset: itemOffset, sort: dataSort }, function(data) {
$('.expandable .spacer').remove();
var hiddenDiv = $('<div class="items hidden"></div>');
$('.expandable > .load').before(hiddenDiv);
$(hiddenDiv).append(data).hide().removeClass("hidden").fadeIn();
});
e.preventDefault();
});
}
function jsTabsetInit() {
var $tabset = $('.heading-tabset').eq(0);
var $tablist = $('<ul />', {"class": "heading-tab"});
$tabset.prepend($tablist);
$('div.heading-tab h3').each(function()
{
var $anchor = $('<a />', {
"class": $(this).attr('class'),










