$(function() { //#Attach behaviours to navigation tabs. $(".tabs.navigation:first").each(function() { //Attach behaviour to enabled tabs. $(this).find('a:not(.disabled)').click(function(event) { //Highlight selected tab. $(this).parent().siblings().children(this.tagName).highlight(this); //Show results table matching tab index. $("#results > div").hide().eq($(".tabs.navigation:first a").index(this)).show(); event.preventDefault(); }).mousedown(function(event) { event.preventDefault(); }) //Trigger click event of first enabled tab. .filter(":first").click(); //Attach behaviour to disabled tabs. $(this).find("a.disabled").click(function(event) { event.preventDefault(); }).mousedown(function(event) { event.preventDefault(); }); //Trigger click event of last selected tab var showTab = new QueryString(window.location.toString()).get("SD"); if (showTab) { $(this).find('a').eq(showTab).click(); } }); //#Attach asset type checkbox logic. var alltypes = $("#search_col_left :checkbox[value='all']"); var types = $("#search_col_left :checkbox:not([value='all'])"); alltypes.click(function() { types.attr("checked", this.checked); }); types.click(function() { alltypes.attr("checked", types.filter(":checked").length == types.length); }); //#Attach exchanges checkbox and select field logic. var exchanges = $("#search_col_right select:first"); //Stores array of selected exchanges. var selectedExchanges; $("#search_col_right :checkbox:first").click(function() { if (this.checked) { selectedExchanges = exchanges.val(); exchanges.children().attr("selected", true); } else if (selectedExchanges) exchanges.val(selectedExchanges); }); exchanges.change(function() { $("#search_col_right :checkbox:first").attr("checked", $(this).children(":selected").length == $(this).children().length); }); }); $.fn.highlight = function(e, c) { //Default class. if (!c) c = "selected"; //Remove class from each element. $(this).removeClass(c); //Add class to the passed element. $(e).addClass(c); return this; };