(function() { //Search the querystring parameters looking for a specific parameter based on the name provided //https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144 function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, '\\$&'); var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, ' ')); } //Determine which context value to use for the new case function getContextUrl() { //If a context value was provided as a querystring parameter, use that var context = getParameterByName('context'); if (context) { return context; } //If document.referrer is around that should tell us who opened us, and it's more accesible than window.opener.location if (document.referrer) { return document.referrer; } //Try/catch is needed here to deal with cross-origin security limitations regarding window.opener.location try { //Else fallback to the opener url, if available if (window.opener && window.opener.location.href) { return window.opener.location.href; } } catch(error) { } //Else final fallback use current form url return window.location.href; } function getReturnUrl() { var parameters = ''; //If query parameters exist, add them to the thank you url so the thank you page can leverage them as well if (window.location.search) { parameters = window.location.search; } //If a return url was provided as a querystring parameter, use that var returnUrl = getParameterByName('return'); if (returnUrl) { return returnUrl + parameters; } //Else use the default return url from the config return window._config.returnUrl + parameters; } //Determine which product name case should be associated with - this cannot be automatically // infered and rather depends on web to case intiator passing in product querystring parameter value function getProductName() { var product = getParameterByName('product'); return product; } function getType() { var type = getParameterByName('type'); return type; } //Determine which queue case should be associated with function getQueue(queueType) { var type = getType(); if (queueType) { type = queueType; } if (type) { if (window._config.queueTypeMapping[type]) { return window._config.queueTypeMapping[type]; } } return window._config.queueTypeMapping.default; } function addSelectOption(select, dataItem) { var selectValues = { value: dataItem, text: dataItem }; if(typeof dataItem === 'object') { selectValues = dataItem; } select.append($('