var Applications = window.Applications || function($, window) { var groupingRegex = /(\d+)(\d{3})/, splittingRegex = /(\d*)(?:\.(\d*))?/, decimals = ["", "0", "00", "000", "0000"] ; function splitNumber(value) { var splitValue; value = value.replace(/,/g, "").replace(/^0+/, ""); splitValue = splittingRegex.exec(value); if (splitValue != null) { splitValue.shift(); } return splitValue; } function addCommas(value) { var valueParts = splitNumber(value); if (valueParts == null || !valueParts[0]) { // integer is undefined or "" or "0" return value; } while (groupingRegex.test(valueParts[0])) { valueParts[0] = valueParts[0].replace(groupingRegex, "$1,$2"); } if ((valueParts[1] !== undefined) && (valueParts[1] !== "")) { return valueParts.join("."); } else { return valueParts[0]; } } function padDecimal(value, places) { var decimal = decimals[places]; if (decimal === undefined) { decimal = ""; while (places--) { decimal += "0"; } places = decimal.length; decimals[places] = decimal; } if (value.length !== undefined) { // string value = value + decimal; return value.substring(0, places); } else { // number value = decimal + value; return value.substring(value.length - places); } } function formatValue(value, places) { var valueParts = splitNumber("" + value); valueParts[0] = valueParts[0] || "0"; valueParts[1] = padDecimal(valueParts[1] || 0, places); return addCommas(valueParts.join(".")); } return window.Applications = { addCommas: addCommas, formatValue: formatValue } }(jQuery, window); var Tabs = window.Tabs || function($, window) { var tabGroups = {}, tabs = {} ; function tabHandler(event) { var $clickedTabLink = $(this), clickedTabId = $clickedTabLink.attr('href').split('#a-')[1], clickedTabGroupId = $clickedTabLink.closest('div').attr('id') ; changeSections(clickedTabId, clickedTabGroupId); event.preventDefault(); return false; } function init() { var tabGroupIndex = 0; while (tabGroupIndex !== false) { tabGroupIndex = getTabs(tabGroupIndex); } } function setTabDefault(pageId, tabGroupIndex, defaultTabId) { if ($('#' + pageId).length) { tabGroupIndex = tabGroupIndex || ""; changeSections(defaultTabId, 'create-tabs' + tabGroupIndex, pageId); } } function getTabs(tabGroupIndex) { var tabsRequired = true, $tabContainer = null, $tabSections = null, $tabs = null, tabGroupHeight = 0 ; if (!tabGroupIndex || typeof tabGroupIndex === "object") { tabGroupIndex = ""; } $tabContainer = $('#create-tabs' + tabGroupIndex); if ($tabContainer.length === 0) { return false; } replaceWithTabs(tabGroupIndex); $tabContainer.children().each(function() { var $this = $(this); switch (this.tagName.toLowerCase()) { case "div": $this.addClass('tab-content-wrapper'); $tabSections = $this; break; case "ul": $this.addClass('tabs'); $tabs = $this; tabsRequired = false; break; } }); if (tabsRequired) { $tabs = createTabs($tabSections).insertBefore($tabSections); } $tabs.find('li a[href*="#a-"]').each(function(i) { var $tabLink = $(this), $tab = $tabLink.closest('li'), tabId = $tabLink.attr('href').split('#a-')[1], $tabSection = $('#' + tabId), tabGroupId = $tabLink.closest('div').attr('id'), tabGroupData = tabGroups[tabGroupId], tabSectionHeight = 0 ; if (!tabGroupData) { tabGroupData = tabGroups[tabGroupId] = {}; } tabGroupData[tabId] = $tabSection; tabs[tabId] = $tab; $tabSection.removeClass('javascript-hide'); $tab.removeClass('selected'); $tabSection.css('display', 'block'); tabSectionHeight = $tabSection.outerHeight() || 0; // handle if section doesn't exist if (tabSectionHeight > tabGroupHeight) { tabGroupHeight = tabSectionHeight; } if (i === 0) { $tab.addClass('selected'); } else { $tabSection.css('display', 'none'); } $tabLink.on('click', tabHandler); }); if ($tabContainer.hasClass('equalheight')) { $tabSections.height(tabGroupHeight); } return ++tabGroupIndex; } function replaceWithTabs(sourceIndex) { var $sourceElement = null, $tabs = $('