').insertAfter($(".ui-articles", this).addClass("cs-tab-list displayFlexRow").attr("role", "tablist")); var appPmi = $(this).closest("div[id*='pmi-']").attr("id").replace("pmi-", ""); var shortMonths = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; var longMonths = ["January","February","March","April","May","June","July","August","September","October","November","December"]; var panels = ""; var monthIndex = "", eventMonth = "", eventDate = ""; // LOOP THROUGH EACH LI AND BUILD THE TABS AND PANELS $(".ui-articles > li", this).each(function(i) { monthIndex = shortMonths.indexOf($(".joel-month", this).text()); var ariaDate = $(".joel-date", this).text(); switch($(".joel-date", this).text()){ case "01": ariaDate = "First"; break; case "02": ariaDate = "Second"; break; case "03": ariaDate = "Third"; break; case "04": ariaDate = "Fourth"; break; case "05": ariaDate = "Fifth"; break; case "06": ariaDate = "Sixth"; break; case "07": ariaDate = "Seventh"; break; case "08": ariaDate = "Eighth"; break; case "09": ariaDate = "Ninth"; break; case "10": ariaDate = "Tenth"; break; case "11": ariaDate = "Eleventh"; break; case "12": ariaDate = "Twelveth"; break; case "13": ariaDate = "Thirteenth"; break; case "14": ariaDate = "Fourteenth"; break; case "15": ariaDate = "Fifteenth"; break; case "16": ariaDate = "Sixteenth"; break; case "17": ariaDate = "Seventeenth"; break; case "18": ariaDate = "Eighteenth"; break; case "19": ariaDate = "Nineteenth"; break; case "20": ariaDate = "Twentieth"; break; case "21": ariaDate = "Twenty-first"; break; case "22": ariaDate = "Twenty-second"; break; case "23": ariaDate = "Twenty-third"; break; case "24": ariaDate = "Twenty-fourth"; break; case "25": ariaDate = "Twenty-fifth"; break; case "26": ariaDate = "Twenty-sixth"; break; case "27": ariaDate = "Twenty-seventh"; break; case "28": ariaDate = "Twenty-eighth"; break; case "29": ariaDate = "Twenty-ninth"; break; case "30": ariaDate = "Thirtieth"; break; case "31": ariaDate = "Thirty-first"; break; } $(this).attr({ "role": "tab", "tabindex": (i == 0) ? "0" : "-1", "data-index": $(this).index(), "aria-controls": "cs-panel-" + appPmi + "-" + $(this).index(), "aria-selected": (i == 0) ? "true" : "false", "id": "cs-tab-" + appPmi + "-" + $(this).index(), "class": (i == 0) ? "active" : "", "aria-label": longMonths[monthIndex] + " " + ariaDate }); panels += '