$(function(){ var yourSearch = $("#yourSearch"); var yourFilter = $("#filter"); var contentArea = $("#pageContent"); var getSpecialties = function(){ var arrSpecial = []; yourSearch.find(".specialty").each(function(){ arrSpecial.push($.trim($(this).find("a").attr("rel"))); }); return arrSpecial; }; var getCountries = function(){ var arrCountries = []; yourSearch.find(".country").each(function(){ arrCountries.push($.trim($(this).find("a").attr("rel"))); }) return arrCountries; }; var getSearchTags = function(){ var arrSearchTags = []; yourFilter.find("a").each(function(){ if (!$(this).hasClass("active")){ arrSearchTags.push($.trim($(this).attr("rel"))); } }) return arrSearchTags; } var refreshPostData = function(){ var specialtiesBool = false, countriesBool = false, omitted_tagsBool = false; if (getSpecialties().length <= 0){ specialtiesBool = true; } if (getCountries().length <= 0){ countriesBool = true; } if (getSearchTags().length <= 0){ omitted_tagsBool = true; } return searchPostData = { specialties: getSpecialties(), countries: getCountries(), omitted_tags: getSearchTags(), reset: { specialties: specialtiesBool, countries: countriesBool, omitted_tags: omitted_tagsBool }, format:"html" }; }; refreshPostData(); yourSearch.delegate("a","click",function(e){ $(this).parents("dd").animate({opacity:0},function(){ $(this).remove(); refreshPostData(); loadNewPage("/elective-results/",searchPostData); }); e.preventDefault(); }); yourFilter.delegate("a","click",function(e){ if ( $(this).hasClass("active")){ $(this).removeClass("active"); } else { $(this).addClass("active"); } refreshPostData(); loadNewPage("/elective-results/",searchPostData); e.preventDefault(); }); var pagingEvent = function(){ $(".paging").delegate("a","click",function(e){ var linkHref = $(this).attr("href"); linkHref = linkHref.split("="); loadNewPage("/elective-results/",{page_number:linkHref[1]}); e.preventDefault(); }); }; pagingEvent(); var loadNewPage = function(url,postData){ $.post(url,postData,function(data){ $("body, html").animate({scrollTop:230}); contentArea.addClass("loading").children().wrapAll('