function GetRadWindow(){var n=null;return window.radWindow?n=window.radWindow:window.frameElement.radWindow&&(n=window.frameElement.radWindow),n}function CloseSelf(){window!=null&&window.close()}function CloseWindowTest(n){try{n.close()}catch(t){return alert("Caught Exception: "+t.description),0}}function CloseWindowOnTimeout(){var n=GetRadWindow();n!=null&&(n.close(),self.location.reload(!0))}function CloseActiveToolTip(){var n=Telerik.Web.UI.RadToolTip.getCurrent();n&&n.hide()}function MailTo(n,t){jQuery(n).attr("href",t);jQuery(n).click()}function ProcessLogin(n,t){var i=t;document.forms[0].action=n=="Y"?i.replace(/http:/i,"https:"):i;document.forms[0].submit()}function toggleCheckAll(n){var t=n.checked}function runPrint(){hideControls();print();showHiddenControls()}function disableOnClick(n,t){return t?document.forms[0].submit():n.click(),n.disabled=!0,!0}function addControlToHide(n){control=$("#"+n);control&&(controlsToHide[controlsToHide.length]=control)}function showHiddenControls(){for(var n=0;n<controlsToHide.length;n++)controlsToHide[n].style.display="block"}function hideControls(){for(var n=0;n<controlsToHide.length;n++)controlsToHide[n].style.display="none"}function addControlToDisableArray(n){control=$("#"+n);control&&(controlsToDisable[controlsToDisable.length]=control)}function disableControlsOnClick(n,t){alert("here");t?document.forms[0].submit():n.click();for(var i=0;i<controlsToDisable.length;i++)controlsToDisable[i].disabled=!0;return!0}function popupCentreWindow(n,t){var i=800,r=800,u=Number(screen.width/2-i/2),f=Number(screen.height/2-r/2),e=window.open("about:blank","","width="+i+",height="+r+",top="+f+",left="+u+",toolbar=0,menubar=0,scrollbars=1,resizable=1,status=0");return e.location.href=t,!1}function generatePrintablePopupWithMargin(n){printableQuoteMargin!=""&&(n=n+"&margin="+printableQuoteMargin);n+="&ssdet="+showSupplierDetailsOnPrintableQuote;var t=popupCentreWindow("Singleton",n,775,575);return!1}function handleEnterKey(n){var t=document.getElementById(n);if(t&&t.click)return t.click(),!1}function AutoWireUpEnterKeyButtonClickEvent(n,t){$("#"+n).bind("keydown",{buttonIdToClick:"#"+t},handleEnterKeyButtonClick)}function handleEnterKeyButtonClick(n){if(n.which==13){var t=n.data.buttonIdToClick;return $(t).length&&$(t).click(),!0}return!0}function submitOnEnter(){this.window.event.keyCode==13&&this.document.submit();this.document.submit()}function removeTextFromTextBox(n){n.length&&n.value&&(n.value="")}function setPrintableQuoteMargin(n){printableQuoteMargin=n}function setShowSupplierDetailsOnPrint(n){showSupplierDetailsOnPrintableQuote=n}function OnTimePickerOpening(){}function OnDatePickerOpening(){}function dataWasEntered(){return dataHasChanged=!0,!1}function confirmPushCompanyNameChange(){return!0}function canProceed(){return canProceedToAct?(canProceedToAct=!1,!0):canProceedToAct}function resetCanProceed(){canProceedToAct=!0}function SelectRow(n,t,i,r){if(!contextmenuIsShowing){var u=document.getElementById(n),f=document.getElementById(r);u.className=="pt-table-row__selected"&&i=="true"?(u.className=t=="true"?"even":"",f.checked=!1,numRowsSelected--):u.className!="pt-table-row__selected"&&i=="true"&&(u.className="pt-table-row__selected",f.checked=!0,numRowsSelected++);DisplayCorrectBottomLinks()}}function DisplayCorrectBottomLinks(){var n=document.getElementById("enabledLinks"),t=document.getElementById("disabledLinks");numRowsSelected>0?(n.style.display="inline",t.style.display="none"):(n.style.display="none",t.style.display="inline")}function ShowContextMenu(n,t,i,r,u){contextmenuIsShowing=!0;var s=window.event?window.event:t,h=s.clientX,e=s.clientY,o=document.compatMode&&document.compatMode!="BackCompat"?document.documentElement:document.body,c=document.all?o.scrollLeft:pageXOffset,l=document.all?o.scrollTop:pageYOffset,f=document.getElementById(n);f.style.display="block";e<o.clientHeight/2?(f.style.top=e+l-20+"px",f.style.left=h+c-20+"px"):(f.style.top=e+l-f.offsetHeight+20+"px",f.style.left=h+c-20+"px");SelectDeselectAllRows_helperMethod(i,r,!1);document.getElementById(u).className="darkGray"}function HideMenu(n,t,i,r){try{if(!window)return;if(window.event){if(window.event.toElement.parentNode.id==t.id||window.event.toElement.id==t.id)return}else if(n.relatedTarget.id==t.id||n.relatedTarget.parentNode.id==t.id)return;contextmenuIsShowing=!1;var u=document.getElementById(t.id);u.style.display="none";document.getElementById(r).className=i?"even":"";DisplayCorrectBottomLinks()}catch(f){}}function SelectOrDeselectAllRows(n,t,i,r){var f=document.getElementById(i),u=document.getElementById(r),e=u.style.display=="none";SelectDeselectAllRows_helperMethod(n,t,e);e?(f.style.display="none",u.style.display="inline"):(f.style.display="inline",u.style.display="none");DisplayCorrectBottomLinks()}function SelectDeselectAllRows_helperMethod(n,t,r){var u=document.getElementsByTagName("body")[0].getElementsByTagName("*"),f=r.toString().toLowerCase()=="true"||r;for(i=0;i<u.length;i++)elem=u[i],elem.id.indexOf(n)>=0&&(elem.type=="checkbox"&&(f==!0?elem.checked==!1&&(elem.checked=!0,numRowsSelected++):elem.checked==!0&&(elem.checked=!1,numRowsSelected--)),elem.id.indexOf(t)>=0&&(f==!0?elem.className="darkGray":(rowCounter++,elem.className=rowCounter%2==0?"":"even")));rowCounter=0}function getY(n){for(var t=0;n!=null;)t+=n.offsetTop,n=n.offsetParent;return t}function getX(n){for(var t=0;n!=null;)t+=n.offsetLeft,n=n.offsetParent;return t}function findPos(n){var t=getX(n),i=getY(n);return[t,i]}function setElementFocus(n){var t=$("#"+n);t.focus()}function disableTimer(){return timer!=null&&timer._stopTimer(),!0}function SetElementFocus(n){var t=$("#"+n);if(t.length&&t.focus)return t.focus(),!1}function GetElement(n){return $("#"+n)}function HighlightRow(){jQuery(this).css("backgroundColor","#B5B5B5")}function LowlightRow(){jQuery(this).css("backgroundColor","#D8D5CF")}function CallButtonServersideEvent(n){$("#"+n).click()}function selectChkBoxWhenTextIsClicked(n){var t=$("#"+n);t.length&&t.attr("checked",!t.is(":checked"))}function HandleRoleCheckboxLoadup(){for(var t=$(roleCheckboxSelector+":checked"),i,n=0;n<t.length;n++)i=t[n],jQuery.data(i,"CheckedAtLoadup",!0)}function EnsureUserWantsToRemoveRole(){var n=!0,t=[],u,i,f,r,e;if(isSysAdmin)for(u=$(roleCheckboxSelector+":not(:checked)"),i=0;i<u.length;i++)f=u[i],jQuery.data(f,"CheckedAtLoadup")==!0&&(t[t.length]=f.id);if(t.length>0)if(n=confirm("You have removed one or more roles for this company.  Removing a role from a company will also remove this role for all company users who are already assigned to the role.  Are you sure you want to do this?"),n)n=!0;else{for(r=0;r<t.length;r++)e=$("#"+t[r]).attr("checked",!0);this.beenClicked=n=!1}else n=!0;return n}function ConfirmChangeQuoteType(){var n=$("#"+this.id),i=$("#QuoteTypeSelector input:radio:checked"),t=$("#QuoteTypeSelector").data("QuoteTypeSelectedAtLoad");if(dataHasChanged)if(confirm("Are you sure you want to change the quote type? Proceeding will result in all the entered data being lost."))dataHasChanged=!1,t.removeAttr("checked"),n.attr("checked","checked"),$("#aspnetForm").submit();else return n.removeAttr("checked"),t.attr("checked","checked"),!1;else return $("#aspnetForm").submit(),!0}function GetFormRepostState(){return $("#aspnetForm").data("AllowRepost")}function hidePrintButtons(){document.getElementById("divPrintButtons1").style.display="none";document.getElementById("divPrintButtons2").style.display="none"}function ShowPrintButtons(){document.getElementById("divPrintButtons1").style.display="block";document.getElementById("divPrintButtons2").style.display="block"}function PTApplicationInit(){$("input[type=image]").preventDoubleClick();$(".menuItem.highlightable").mouseover(HighlightRow);$(".menuItem.highlightable").mouseleave(LowlightRow);$("#PrintLinkButton_lnkPrint").click(function(){return generatePrintablePopupWithMargin($(this).attr("data-href"),760,550),!1});$("#PrintLinkButton_lnkPrintAsPDF").click(function(){return generatePrintablePopupWithMargin($(this).attr("data-href"),760,550),!1});$.extend(!0,$.fn.dataTable.defaults,{dom:'<"dataTables_header cf"f>rt<"dataTables_footer cf"il<"paging pt-table-controls-pagination"p>>',oLanguage:{sSearch:"Filter:",sInfo:"<label>Showing<\/label> _START_-_END_ of _TOTAL_ records",sInfoEmpty:"No results",sInfoFiltered:" filtered from <strong>_MAX_ total<\/strong>",oPaginate:{sPrevious:"<< PREV",sNext:"NEXT >>"}},orderMulti:!1,processing:!0,serverSide:!0,autoWidth:!1,bSortClasses:!1})}function hideToolTip(n){var t=$find(n);t.isVisible()&&t.hide()}function HideRadToolTip(n){var t=$find(n),i=$("#RadToolTipWrapper_"+n);t!=null&&($(i).find("input, select").each(function(){switch(this.type){case"password":case"text":case"textarea":case"file":case"select-one":case"select-multiple":jQuery(this).val("");break;case"checkbox":case"radio":this.checked=!1}}),t.isVisible()&&t.hide())}function pdf(){$.fancybox({type:"ajax",href:"/common/snippets/pdf.html",maxWidth:560,maxHeight:480,fitToView:!1,autoSize:!1,closeClick:!1,openEffect:"none",closeEffect:"none"})}function addCommas(n){n+="";for(var i=n.split("."),t=i[0],u=i.length>1?"."+i[1]:"",r=/(\d+)(\d{3})/;r.test(t);)t=t.replace(r,"$1,$2");return t+u}function removeCommas(n){return n.replace(",","")}function getTime(){return new Date((new Date).getTime()).toLocaleTimeString()}var initialFieldToFocus="",controlsToDisable=[],controlsToHide=[],checkedBoxes=[],isSysAdmin=!1,printableQuoteMargin="",showSupplierDetailsOnPrintableQuote=!0,dataHasChanged=!1,timer,canProceedToAct=!0,numRowsSelected=0,contextmenuIsShowing=!1,rowCounter=0,roleCheckboxSelector="#roleContainer input:checkbox",repeatableOps,DashboardModel;jQuery.fn.allowRepostForThisPage=function(){jQuery(this).data("AllowRepost",!0)};jQuery.fn.preventDoubleSubmit=function(){jQuery(this).submit(function(){if(GetFormRepostState()==!0)return!0;if(this.beenSubmitted)return!1;this.beenSubmitted=!0})};jQuery.fn.preventDoubleClick=function(){jQuery(this).click(function(){if(GetFormRepostState()!=!0){if(this.beenClicked)return!1;this.beenClicked=!0}})};$(document).ready(PTApplicationInit),function(n){"use strict";var t="error,info,log,trace,warn",r=function(){for(var n,i={},r=t.split(","),u=function(){};n=r.pop();)i[n]=u;return i},u=function(n){for(var i,r=t.split(",");i=r.pop();)if(typeof n[i]!="function")return!1;return!0},i=typeof n.console=="object"&&u(n.console)?n.console:r(),f={enabled:!1,log:function(){return this.enabled&&i.log.apply(i,arguments),this.enabled}};n.logger=n.logger||f}(typeof window=="undefined"?this:window);repeatableOps=repeatableOps||function(n){"use strict";function t(){this.version="1.0"}var r=function(t,i,r,u,f){function o(n){var s=setTimeout(function(){t().done(function(n){e.resolve(n)}).fail(function(){i-->0?(n=n*2||r,logger.log("[%s] retrying after %d ms...",f,n+u),o(n)):e.reject()}).always(function(){clearTimeout(s)})},u+n)}var e=n.Deferred();return u=u||0,o(0),e.promise()},i=function(t,u,f,e,o){var s=n.isFunction(u)?u():u||0,h;logger.log("[%s] starting refresh timer every %d ms",o,s);h=setInterval(function(){logger.log("[%s] refreshing...",o);t().done(function(){n.isFunction(u)&&u()!=s&&(logger.log("[%s] new refresh period detected, re-starting timer",o),clearInterval(h),i(t,u,f,e,o))}).fail(function(){logger.log("[%s] stopping refresh timer, enter retry mode",o);clearInterval(h);r(t,f,e,s,o).done(function(){i(t,u,f,e,o)}).fail(function(){logger.log("[%s] refresh aborted",o)})})},s)};return t.prototype.retryOnFailure=r,t.prototype.setUpPeriodicRefresh=i,t.prototype.fromAngularPromise=function(t){var i=n.Deferred();return t.then(function(n){i.resolve(n)},function(n){i.reject(n)}),i.promise()},new t}(jQuery),function(n){jQuery.ui.autocomplete.prototype._resizeMenu=function(){var n=this.menu.element;n.outerWidth(this.element.outerWidth())};n.widget("custom.combobox",{_create:function(){this.wrapper=n("<span>").addClass("custom-combobox").insertAfter(this.element);this.element.hide();this._createAutocomplete()},_createAutocomplete:function(){var t=this.element.children(":selected"),i=t.val()?t.text():"";this.input=n('<input type="text" title="">').appendTo(this.wrapper).val(i).autocomplete({delay:0,minLength:0,source:n.proxy(this,"_source")}).tooltip({});this.input.bind("focus",function(){n(this).autocomplete("search","")});this._on(this.input,{autocompleteselect:function(n,t){t.item.option.selected=!0;this._trigger("select",n,{item:t.item.option})},autocompletechange:"_removeIfInvalid"})},_source:function(t,i){for(var o=new RegExp(n.ui.autocomplete.escapeRegex(t.term),"i"),u=this.element.get(0),e=[],f,r=0;r<u.length;r++)if(f=u.options[r].text,u.options[r].value&&(!t.term||o.test(f))&&e.push({label:f,value:f,option:u.options[r]}),e.length>10)break;i(e)},_removeIfInvalid:function(t,i){if(!i.item){var r=this.input.val(),f=r.toLowerCase(),u=!1;(this.element.children("option").each(function(){if(n(this).text().toLowerCase()===f)return this.selected=u=!0,!1}),u)||(this.input.val("").attr("title",r+" didn't match any item").tooltip("open"),this.element.val(""),this._delay(function(){this.input.tooltip("close").attr("title","")},2500))}},_destroy:function(){this.wrapper.remove();this.element.show()}})}(jQuery);$(document).ready(function(){function i(){var n=0;return $("input.managePaymentsMoney:text, input.managePaymentsMoneyShort:text").each(function(){var i=$(this).val(),t;i=i.replace(",","");t=parseFloat(i);isNaN(t)&&(t=0);n=n+t}),n.toFixed(2)}var f=$("td.tdComboBoxContainer").find("select.ddlCompanyNames"),u;f.combobox();$("input#btnCancelPopup").click(function(){$('[id$="ttConfirmSave"]').hide();$("div.TelerikModalOverlay").hide()});var n=$("span#spanTotalVariance"),r=parseFloat($("span.lblTotalLoaded").html()),t=i()-r;t<0?(u=-t.toFixed(2),n.html("-$"+u)):isNaN(t)?n.html("$0"):n.html("$"+t.toFixed(2));$("input.managePaymentsMoney:text, input.managePaymentsMoneyShort:text").keyup(function(){var t=i()-r,u;t<0?(u=-t.toFixed(2),n.html("-$"+u)):n.html("$"+t.toFixed(2))})});$(document).ready(function(){$("div.divCreateRequestSponsorListDisabledSponsorContainer").mouseenter(function(){var n=$(this).find("div.divCreateRequestSponsorDescriptionPopup");n.is(":visible")||($("div.divCreateRequestSponsorDescriptionPopup").hide(),n.fadeIn("fast"))}).mouseleave(function(){var n=$(this).find("div.divCreateRequestSponsorDescriptionPopup");n.is(":visible")&&n.fadeOut("fast")})}),function(n,t,i){function s(n){return n=p(n),n!==n?0:0===n||t===n||-t===n?n:(0<n||-1)*f.floor(f.abs(n))}function l(n,t){var c,h,e,o,l;for(h=u(this),e=h.length>>>0,i!==n?(n=s(n),o=0>n?f.max(e+n,0):f.min(n,e)):o=0,i!==t&&(t=s(t),e=0>t?f.max(e+t,0):f.min(t,e)),c=new r(e-o),l=0;o<e;++o,++l)o in h&&(c[l]=h[o]);return c}function a(n){return"[object Array]"===u.prototype.toString.call(n)}function e(n){if("[object Function]"!==u.prototype.toString.call(n))throw Error(n+" is not a function");}function h(n){if(!n)throw Error("reduce of empty array with no initial value");}function v(n){var t=!0;if(r.prototype[n])try{r.prototype[n].call(i,/test/,null);t=!1}catch(u){}else t=!1;return t}function c(n){var t=!0;if(r[n])try{r[n](i,/test/,null);t=!1}catch(u){}else t=!1;t||(r[n]=y(n))}function y(n){return function(t){var u;if(i===t||null===t)throw Error("Array.prototype."+n+" called on "+t);return u=r.prototype.slice.call(arguments,1),r.prototype[n].apply(t,u)}}var r=n.Array,u=n.Object,f=n.Math,p=n.Number,o;n={indexOf:function(n,t){var e,o,r;for(e=u(this),o=e.length>>>0,i!==t?(t=s(t),r=0>t?f.max(o+t,0):f.min(t,o)):r=0;r<o;++r)if(r in e&&n===e[r])return r;return-1},lastIndexOf:function(n,t){var e,r;for(e=u(this),r=e.length>>>0,i!==t?(t=s(t),r=0>t?r-f.abs(t):f.min(t,r-1)):r-=1;-1<r;--r)if(r in e&&n===e[r])return r;return-1},forEach:function(n,t){var r,f,i;for(r=u(this),e(n),f=r.length>>>0,i=0;i<f;++i)i in r&&n.call(t,r[i],i,r)},every:function(n,t){var r,f,i;for(r=u(this),e(n),f=r.length>>>0,i=0;i<f;++i)if(i in r&&!n.call(t,r[i],i,r))return!1;return!0},some:function(n,t){var r,f,i;for(r=u(this),e(n),f=r.length>>>0,i=0;i<f;++i)if(i in r&&n.call(t,r[i],i,r))return!0;return!1},filter:function(n,t){var f=[],r,o,i,s;for(r=u(this),e(n),o=r.length>>>0,i=s=0;i<o;++i)i in r&&n.call(t,r[i],i,r)&&(f[s++]=r[i]);return f},map:function(n,t){var f=[],r,o,i;for(r=u(this),e(n),o=r.length>>>0,i=0;i<o;++i)i in r&&(f[i]=n.call(t,r[i],i,r));return f},reduce:function(n,t){var f,o,s,r;for(f=u(this),e(n),o=i!==t,s=f.length>>>0,r=0;r<s;++r)r in f&&(o?t=n(t,f[r],r,f):(t=f[r],o=!0));return h(o),t},reduceRight:function(n,t){var f,o,r;for(f=u(this),e(n),o=i!==t,r=(f.length>>>0)-1;-1<r;--r)r in f&&(o?t=n(t,f[r],r,f):(t=f[r],o=!0));return h(o),t}};for(o in n)n.hasOwnProperty(o)&&(v(o)||(r.prototype[o]=n[o]),c(o));if(r.isArray=r.isArray||a,"concat join slice pop push reverse shift sort splice unshift".split(" ").forEach(c),document)try{r.slice(document.childNodes)}catch(w){r.prototype.slice=l}}(this,1/0);DashboardModel=function(n){"use strict";var t=this,r=3e4,u=function(){return r},i;t.dashboardMenus=ko.observableArray();t.matchLinkHref=function(n){var t=window.location.href.toLowerCase();return t.indexOf(n)>0?!0:!1};i=function(){return $("#dashboardMenuContainer").addClass("pt-side-nav-panel-gears"),$.ajax(n,{type:"GET",dataType:"json"}).done(function(n){return t.dashboardMenus(n.DashboardMenus),$("#dashboardMenuContainer").removeClass("pt-side-nav-panel-gears"),$("#dashboardMenu").show(),$("#dashboardError").hide(),r=n.RefreshPeriod,n}).fail(function(){logger.log("Unable to get dashboard");$("#dashboardMenuContainer").removeClass("pt-side-nav-panel-gears");$("#dashboardError").show()})};repeatableOps.retryOnFailure(i,3,5e3,0,"dashboard").then(function(){repeatableOps.setUpPeriodicRefresh(i,u,5,5e3,"dashboard")})}