function ErrorHandlingSettings() { this.DisplayNotificationsOnError = false } function ErrorInfo() { this.ErrorNumber = -1; this.ErrorType = ""; this.Name = ""; this.Description = ""; this.Message = ""; this.Url = ""; this.LineNumber = -1; this.StackTrace = "" } var oErrorHandlingSettings = new ErrorHandlingSettings(); function HandleError(ex) { var oErrorInfo = new ErrorInfo(); if (ex instanceof SyntaxError) { oErrorInfo.ErrorType = "SyntaxError" } else if (ex instanceof URIError) { oErrorInfo.ErrorType = "URIError" } else if (ex instanceof ReferenceError) { oErrorInfo.ErrorType = "ReferenceError" } else if (ex instanceof EvalError) { oErrorInfo.ErrorType = "EvalError" } else if (ex instanceof TypeError) { oErrorInfo.ErrorType = "TypeError" } else if (ex instanceof RangeError) { oErrorInfo.ErrorType = "RangeError" } else { oErrorInfo.ErrorType = "Error" } if (ex.hasOwnProperty('message')) { oErrorInfo.Message = ex.message } if (ex.hasOwnProperty('name')) { oErrorInfo.Name = ex.name } if (ex.hasOwnProperty('description')) { oErrorInfo.Description = ex.description } else { oErrorInfo.Description = "" } $('.JSAdditionalErrorInfo').each(function () { var $hidValue = $(this); oErrorInfo.Description += " | " + $hidValue.attr('id') + "=" + $hidValue.val() }); if (ex.hasOwnProperty('number')) { if (!isNaN(ex.number)) { oErrorInfo.ErrorNumber = ex.number } } if (ex.hasOwnProperty('lineNumber')) { if (!isNaN(ex.lineNumber)) { oErrorInfo.LineNumber = ex.lineNumber } } oErrorInfo.Url = window.location.href; var lastError = ex; oErrorInfo.StackTrace = stacktrace(); LogError(oErrorInfo) }; function stacktrace() { re = /function\W+([\w-]+)/i; var f = arguments.callee; var s = ""; while (f) { s += (re.exec(f))[1] + '('; for (i = 0; i < f.arguments.length - 1; i++) { s += "'" + f.arguments[i] + "', " } if (arguments.length > 0) { s += "'" + f.arguments[i] + "'" } s += ")<br />"; f = f.arguments.callee.caller } return s }; function LogError(pErrorInfo) { var DTO = new Object(); DTO.pErrorInfo = pErrorInfo; $.ajax({ type: "POST", data: JSON.stringify(DTO), url: "/Services/ErrorReporting.asmx/LogJavascriptError", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { try { var oResponse = null; if (response == null) { DisplayErrorGrowlNotification("It was unsuccessfully logged - the result from the webservice was null.") } else { if (response.hasOwnProperty("d")) { oResponse = response.d } else { oResponse = response } if (oResponse) { DisplayErrorGrowlNotification("It was successfully logged.") } else { DisplayErrorGrowlNotification("It was unsuccessfully logged - an error occurred in the webservice.") } } } catch (ex) { } }, error: function (xhr, status, error) { try { DisplayErrorGrowlNotification("It was unsuccessfully logged - the webservice was unable to be reached.") } catch (ex) { } } }) }; function DisplayErrorGrowlNotification(strMessage) { if (oErrorHandlingSettings.DisplayNotificationsOnError) { $.gritter.add({ title: 'Javascript Error Occurred', text: strMessage, sticky: true }) } } window.onerror = function myErrorHandler(errorMsg, url, lineNumber) { if ((url == null) || (url.indexOf("maps.gstatic.com") == -1)) { var ex = new Error(errorMsg, url, lineNumber); HandleError(ex) } return true }; OverrideJqueryEventHandlers(); function OverrideJqueryEventHandlers() { var jQueryBind = jQuery.fn.bind; jQuery.fn.bind = function (type, data, fn) { if (!fn && data && typeof data == 'function') { fn = data; data = null } if (fn) { var origFn = fn; var wrappedFn = function () { try { origFn.apply(this, arguments) } catch (ex) { HandleError(ex) } }; fn = wrappedFn } return jQueryBind.call(this, type, data, fn) }; var jqueryOne = jQuery.fn.one; jQuery.fn.one = function (type, data, fn) { if (!fn && data && typeof data == 'function') { fn = data; data = null } if (fn) { var origFn = fn; var wrappedFn = function () { try { origFn.apply(this, arguments) } catch (ex) { HandleError(ex) } }; fn = wrappedFn } return jqueryOne.call(this, type, data, fn) }; var jQueryReady = jQuery.fn.ready; jQuery.fn.ready = function (fn) { var origFn = fn; var wrappedFn = function () { try { origFn.apply(this, arguments) } catch (ex) { HandleError(ex) } }; fn = wrappedFn; return jQueryReady.call(this, fn) } } var eesjs = eesjs || {}; if (eesjs) { eesjs = {}; function raiseError(pErrorDescription) { var ex = new Error(pErrorDescription, '', 0); HandleError(ex) } if (typeof jQuery == 'undefined') { raiseError('jQuery is not loaded in the page. Add the appropriate script reference') }; if (!(jQuery.tools)) { raiseError('jQuery Tools is not loaded in the page. Add the appropriate script reference') }; var PopUpProfiles = { windowUserControls: { height: 400, width: 300, scrollbars: 1, center: 1} }; $(document).ready(function () { BetaMessageOnLoad(); CustomSelectorsOnLoad(); messageControlOnLoad(); SearchFilterOnLoad(); NavigationOnLoad(); EmailFaxOnLoad(); ModalClickOnLoad(); UserHeaderControlsOnLoad() }); function BetaMessageOnLoad() { $(" .divBetaMessage > .close-notify").click(function () { $.cookie("HideBetaMessage", "true", { expires: 8 }); $(".divBetaMessage").slideUp("slow"); return false }); if ($.cookie("HideBetaMessage") != null || $.cookie("HideBetaMessage") == "true") { } else { $(".divBetaMessage").slideDown("slow") } } function messageControlOnLoad() { $(".msgClose").click(function () { $(this).parent().fadeOut("slow") }); if (jQuery.scrollTo) { var boxes = $('.msgError, .msgWarning, .msgInfo, .msgSuccess, .msgHelp'); if (boxes.length > 0) { $.scrollTo(boxes.first()) } } } function SearchFilterOnLoad() { $(".navSearch").delegate(".searchBox, .searchIndicator", "click", function (e) { $("#searchOptions").show() }).delegate(".pnlSearch", "mouseleave", function () { $("#searchOptions").hide() }) } function NavigationOnLoad() { $(".navUserLink[title]").tooltip({ position: "center left", opacity: 0.9, offset: [4, -2], tipClass: "navTip" }); $("ul.wizardSteps li:first-child a span").css("background-position", "0 0"); $("ul.wizardSteps li:last-child a span").css("background-position", "-200px 0"); $("ul.wizardSteps li.active:first-child a span").css("background-position", "0 -37px"); $("ul.wizardSteps li.active:last-child a span").css("background-position", "-200px -37px"); $("ul.wizardSteps li:first-child a.active span").css("background-position", "0 -37px"); $("ul.wizardSteps li:last-child a.active span").css("background-position", "-200px -37px") } function EmailFaxOnLoad() { $("div.jEmailFaxOption").delegate("a.close", "click", function () { $(this).parent().parent().parent().parent().slideUp("slow"); $("a.jEmailFaxButtons").removeClass("active") }) } function ShowEmailFax(btn) { $("a.jEmailFaxButtons").removeClass("active"); $(btn).addClass("active"); $("div.jEmailFaxOption").hide(); $("#" + $(btn).attr("rel")).slideDown("slow"); $("div.jEmailFaxOption").delegate("a.close", "click", function () { $(this).parent().parent().parent().parent().slideUp("slow"); $("a.jEmailFaxButtons").removeClass("active") }); return false } function ModalClickOnLoad() { $(".jsModal").click(function () { var $OverlayBox = $("#" + $(this).attr("data-modal")); if ($OverlayBox.length > 0) { $OverlayBox.overlay({ top: 250, expose: { color: "#aaa", loadSpeed: 200, opacity: 0.5 }, onBeforeLoad: function () { if ($.browser.msie && $.browser.version < "8.0") { var currentObj = this; var currentOverlay = this.getOverlay(); $(currentOverlay).appendTo("#form1"); $(".close", currentOverlay).click(function (e) { currentObj.close() }) } }, closeOnClick: false, api: true }).load() } }) } function UserHeaderControlsOnLoad() { if ($(".jsPopup").length > 0) { $(".jsPopup").popupWindow({ height: 400, width: 300, centerScreen: 1, scrollbars: 1 }) } } function ChangePoJobName(rObject) { if ((rObject != null) && (rObject.NewName != null) && (rObject.NewName.length > 0)) { var DTO = new Object(); DTO.pInvoice = rObject.InvoiceNumber; DTO.pInvDate = rObject.InvoiceDate; DTO.pOldPoJobName = rObject.OldName; DTO.pNewPoJobName = rObject.NewName; $.ajax({ type: "POST", data: JSON.stringify(DTO), url: "/AccountInquiry/WebServices/Invoices.asmx/UpdatePoJobName", contentType: "application/json; charset=utf-8", cache: false, dataType: "json", success: function (response) { var returnedInfo = null; var strOutput = ""; if (response == null) { alert("Response was Null") } else { if (response.hasOwnProperty("d")) { returnedInfo = response.d } else { returnedInfo = response } if (returnedInfo.Errors) { alert(returnedInfo.Errors) } else { rObject.NewName = rObject.NewName.toUpperCase(); rObject.LblID.text(rObject.NewName); if (rObject.AnchorID.attr("data-jobname") !== undefined) { rObject.AnchorID.attr("data-jobname", rObject.NewName) } } } }, error: function (xhr, status, error) { alert("We apologize, but an error has occurred. Please try again later."); try { LogError("Error occurred while calling AddItemsToCart webservice: " & xhr.responseText) } catch (ex) { } } }) } } function CustomSelectorsOnLoad() { LoadSelectorHasStore(); LoadSelectorIsHost(); LoadSelectorHasState() } function LoadSelectorHasStore() { $.expr[':'].hasStore = function (objNode, intStackIndex, arrProperties, arrNodeStack) { var arrArguments = eval("([" + arrProperties[3] + "])"); var $jThis = $(objNode); for (var i = 0; i < arrArguments.length; i++) { if (parseInt($jThis.attr("data-store")) == parseInt(arrArguments[i])) { return (true) } } return (false) } } function LoadSelectorIsHost() { $.expr[':'].isHost = function (objNode, intStackIndex, arrProperties, arrNodeStack) { var $jThis = $(objNode); if (parseInt($jThis.attr("data-host")) == "0") { return (true) } return (false) } } function LoadSelectorHasState() { $.expr[':'].hasState = function (objNode, intStackIndex, arrProperties, arrNodeStack) { var arrArguments = eval("([ " + arrProperties[3] + " ])"), $jThis = $(objNode); for (var i = 0; i < arrArguments.length; i++) { if ($jThis.attr("data-state") == arrArguments[i].toString().toUpperCase()) { return (true) } } return (false) } } function addToQuote(pThis) { $("#Quote_catalog").val(($(pThis).attr("data-catalog"))); $("#Quote_vendor").val(($(pThis).attr("data-vendor"))); $("#Quote_description").val(($(pThis).attr("data-description"))); $("#Quote_upc").val(($(pThis).attr("data-upc"))); var txtBox = $("#txtQuantityToAddQuotes"); txtBox.val($("#" + ($(pThis).attr("data-textbox"))).val()); if (txtBox.val() == 0) txtBox.val("1") } function addToCustonList(pThis) { $("#CustomList_catalog").val(($(pThis).attr("data-catalog"))); $("#CustomList_vendor").val(($(pThis).attr("data-vendor"))); $("#CustomList_description").val(($(pThis).attr("data-description"))); $("#CustomList_upc").val(($(pThis).attr("data-upc"))); $("#txtQuantityToAddLists").val($("#" + ($(pThis).attr("data-textbox"))).val()) } } else { alert("eesnet.js file loaded more than once. Remove the second reference for the page to function correctly") }; var conCTBErrorClass = "CartItemTextBoxError"; var conCTBAttributeDefaultDisplayAmount = "data-defaultdisplayamount"; var conCTBAttributeVendor = "data-vendor"; var conCTBAttributeCatalog = "data-catalog"; var conCTBAttributeStore = "data-store"; var conCTBAttributeIsPrimaryCartTextBox = "data-isprimarycarttextbox"; var conCTBAttributeIsSurplus = "data-issurplus"; var conCTBAttributeMultiplyBy = "data-multiplyby"; var conCTBAttributeMultiplesOf = "data-multiplesof"; var conCTBAttributeUniqueTextBoxId = "data-uniqueTextBoxID"; var conCTBAttributeClicked = "data-clicked"; var conCTBAttributeErrorMesssagePosition = "data-errormessageposition"; function cCartItem() { this.Catalog = ""; this.Vendor = ""; this.Store = -1; this.IsSurplus = false; this.Quantity = 0 } function cNoItemsMessage() { this.BeingDisplayed = false } function cGetItemsErrors() { this.InvalidMuliplesOfValues = false } var oNoItemsMessage = new cNoItemsMessage(); $(document).ready(function () { $('.CartTextBox').each(function (event) { InitializeCartTextBox($(this)) }); $('body').delegate('a.btnAddToCart', 'click', function (event) { event.preventDefault(); var $btnAddToCart = $(this); if (!AddToCartButtonIsClicked($btnAddToCart)) { DisableAddToCartLink($btnAddToCart); $('.CartTextBox').each(function (event) { ValidateCurrentInput($(this)) }); var oGetItemsErrors = new cNoItemsMessage(); var aryCartItems = GetValidCartItems($btnAddToCart, oGetItemsErrors); if (aryCartItems.length > 0) { SendItemsToCartWebSerice(aryCartItems, true, $btnAddToCart) } else { EnableAddToCartLink($btnAddToCart); DisplayNoItemsAddedMessage(oNoItemsMessage, oGetItemsErrors) } } return false }) }); function AddItemToCart($txtItemToAdd) { var blnAllValuesValid = true; var aryCartItems = new Array(); blnAllValuesValid = BuildArrayCartItems($txtItemToAdd, blnAllValuesValid, aryCartItems); if (blnAllValuesValid) { SendItemsToCartWebSerice(aryCartItems, false, null) } } var $btnCurAddToCart = null; var blnCompletedAjaxCall = false; function ChangeButtonText() { if (!blnCompletedAjaxCall) { $btnCurAddToCart.html('&nbsp; &nbsp; &nbsp; &nbsp;Loading...') } } function SendItemsToCartWebSerice(aryCartItems, blnDisplayMessages, $btnAddToCart) { if (aryCartItems.length > 0) { var DTO = new Object(); DTO.pNewCartItems = aryCartItems; var strOriginalAddToCartHtml = $btnAddToCart.html(); blnCompletedAjaxCall = false; $btnCurAddToCart = $btnAddToCart; var oTimer = setTimeout("ChangeButtonText();", 750); $.ajax({ type: "POST", data: JSON.stringify(DTO), url: "/Checkout/WebServices/ShoppingCart.asmx/AddItemsToCart", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { var oCartInfo = null; var strOutput = ""; blnCompletedAjaxCall = true; $btnAddToCart.html(strOriginalAddToCartHtml); if (response == null) { if (blnDisplayMessages) { DisplayDefaultErrorMessage() } } else { if (blnDisplayMessages) { if (response.hasOwnProperty("d")) { oCartInfo = response.d } else { oCartInfo = response } if (oCartInfo.HasError) { strOutput = GetMessagesUnorderedListHtml(oCartInfo.ErrorMessages); $.gritter.add({ title: 'The following error(s) occurred:', text: strOutput, sticky: false, time: '7000' }) } if (oCartInfo.HasCartItemsAdded) { DisplayCartItems(oCartInfo, true) } if (oCartInfo.HasCartItemsNotAdded) { DisplayCartItems(oCartInfo, false) } if (oCartInfo.HasWarning) { strOutput = GetMessagesUnorderedListHtml(oCartInfo.WarningMessages); $.gritter.add({ title: 'The following warning occurred:', text: strOutput, sticky: false, time: '7000' }) } ResetAddedItemsToDefaultValue(oCartInfo) } if (oCartInfo.HasCartTotals) { $('.DisplayCartTotal').html(oCartInfo.TotalPrice); $('.DisplayCartNumberOfItems').html(oCartInfo.NumberOfCartItemsText) } else { $('.DisplayCartTotal').html('<img style="float:right;padding:0px;margin:0px !important" alt="Unavailable" src="/Images/Icons/24x24/unavailable.png" />'); $('.DisplayCartNumberOfItems').html('? items') } } if ($btnAddToCart != null) { EnableAddToCartLink($btnAddToCart) } }, error: function (xhr, status, error) { blnCompletedAjaxCall = true; $btnAddToCart.html(strOriginalAddToCartHtml); if (blnDisplayMessages) { DisplayDefaultErrorMessage() } if ($btnAddToCart != null) { EnableAddToCartLink($btnAddToCart) } try { var oErrorInfo = new ErrorInfo(); oErrorInfo.ErrorType = "Error"; oErrorInfo.Message = "Error occured while calling AddItemsToCart webservice: " + xhr.responseText; oErrorInfo.Name = status; oErrorInfo.Description = "Error occured while calling AddItemsToCart webservice: " + xhr.responseText; oErrorInfo.Url = window.location.href; LogError(oErrorInfo) } catch (ex) { } } }) } } function AddToCartButtonIsClicked($lnkAddToCart) { var blnClicked = true; if ($lnkAddToCart.attr(conCTBAttributeClicked) == undefined) { blnClicked = false } else { if ($lnkAddToCart.attr(conCTBAttributeClicked) == "false") { blnClicked = false } } return blnClicked } function DisableAddToCartLink($lnkAddToCart) { $lnkAddToCart.attr(conCTBAttributeClicked, "true"); $lnkAddToCart.removeAttr("disabled") } function DisplayNoItemsAddedMessage(pNoItemsMessage, pGetItemsErrors) { if (pNoItemsMessage.BeingDisplayed == false) { var strNoItemsMessage = "No items were selected"; var strTime = '4000'; pNoItemsMessage.BeingDisplayed = true; if (pGetItemsErrors.InvalidMuliplesOfValues) { strNoItemsMessage = "Some of the items had invalid quantities.  Please review your requested quantities and ensure they are correct."; strTime = '6500' } else { if (typeof (gIsCustomList_ListDetailPage) != 'undefined') { if (gIsCustomList_ListDetailPage) { strNoItemsMessage = "Please check the &#39;Select Item&#39; checkbox for each item you would like to add to your cart."; strTime = '6000' } } } $.gritter.add({ title: 'No items added:', text: strNoItemsMessage, sticky: false, time: strTime, after_close: function () { pNoItemsMessage.BeingDisplayed = false } }) } } function GetValidCartItems($btnAddToCart, pGetItemsErrors) { var aryCartItems = new Array(); var blnAllValuesValid = true; if ($btnAddToCart.attr('data-uniqueCartTextBoxID') != '') { var uniqueCartTextBoxID = $btnAddToCart.attr('data-uniqueCartTextBoxID'); var $uniqueTextBox = $('.CartTextBox[id=' + uniqueCartTextBoxID + ']'); blnAllValuesValid = BuildArrayCartItems($uniqueTextBox, blnAllValuesValid, aryCartItems) } else { $('.CartTextBox').each(function () { if (blnAllValuesValid) { $txtMe = $(this); blnAllValuesValid = BuildArrayCartItems($txtMe, blnAllValuesValid, aryCartItems); if (!blnAllValuesValid) { pGetItemsErrors.InvalidMuliplesOfValues = true } } }) } if (blnAllValuesValid) { if (typeof (gIsCustomList_ListDetailPage) != 'undefined') { if (gIsCustomList_ListDetailPage) { var $txtListQuantity = $('#txtListQuantity'); if ($txtListQuantity.length > 0 && $txtListQuantity.val() > 0) { var arrayLength = aryCartItems.length; var intListQuantity = $txtListQuantity.val(); for (var intI = 0; intI < arrayLength; intI++) { aryCartItems[intI].Quantity = (aryCartItems[intI].Quantity * intListQuantity) } } } } } else { aryCartItems = new Array() } return aryCartItems } function BuildArrayCartItems($txtCurrentBox, blnAllValuesValid, aryCartItems) { if (!$txtCurrentBox.attr('disabled') && !$txtCurrentBox.attr('readonly') && !$txtCurrentBox.hasClass('disabled')) { var oCurCartItem = null; var intCurMulitplyBy = 0; var intQuantity = 0; if (isNaN(parseInt($txtCurrentBox.val()))) { $txtCurrentBox.val("0") } intCurMulitplyBy = ($txtCurrentBox.attr(conCTBAttributeMultiplyBy)) - 0; intQuantity = ($txtCurrentBox.val()) * intCurMulitplyBy; if (intQuantity > 0) { if ($txtCurrentBox.hasClass(conCTBErrorClass)) { var api = $txtCurrentBox.data("tooltip"); api.show(); blnAllValuesValid = false } if (blnAllValuesValid) { oCurCartItem = new cCartItem(); oCurCartItem.Catalog = $txtCurrentBox.attr(conCTBAttributeCatalog); oCurCartItem.Vendor = $txtCurrentBox.attr(conCTBAttributeVendor); oCurCartItem.Store = ($txtCurrentBox.attr(conCTBAttributeStore)) - 0; oCurCartItem.IsSurplus = ($txtCurrentBox.attr(conCTBAttributeIsSurplus) == 'true'); oCurCartItem.Quantity = intQuantity; aryCartItems.push(oCurCartItem) } } } return blnAllValuesValid } function DisplayDefaultErrorMessage() { $.gritter.add({ title: 'The following error(s) occurred:', text: 'Unfortunately, there was an unexpected error while attempting to add the items to your cart.' + ' If the error persists, please <a href="Support-ContactUs.aspx">Contact Us</a>.', time: '7000', sticky: false }) } function DisplayCartItems(oCartInfo, blnCartItemsAdded) { var strOutput = ""; var strTitle = ""; var aryCartItems = null; var blnReachMaxItemsDisplayed = false; var strTime = "5000"; if (blnCartItemsAdded) { strTitle = "The following items have been added:"; aryCartItems = oCartInfo.CartItemsAdded } else { strTitle = "The following items <i>were not</i> added:"; aryCartItems = oCartInfo.CartItemsNotAdded } strOutput = "<ul>"; for (var i = 0; i < aryCartItems.length && !blnReachMaxItemsDisplayed; i++) { if (i == 10) { strTime = "5750" } else if (i == 15) { strTime = "6500" } if (i < 20) { strOutput += "<li>" + aryCartItems[i].Quantity + ": " + aryCartItems[i].Name; if (blnCartItemsAdded) { if (typeof (gIsSpecialOrderItem) != 'undefined' && gIsSpecialOrderItem == true) { if (parseFloat(aryCartItems[i].TotalPrice.substr(1)) > 0) { strOutput += " - " + aryCartItems[i].TotalPrice + "</li>" } else { strOutput += " - N/A </li>" } } else { strOutput += " - " + aryCartItems[i].TotalPrice + "</li>" } } } else { blnReachMaxItemsDisplayed = true; if (blnCartItemsAdded) { strOutput += "<li>Please <a href='" + oCartInfo.ViewCartLink + "'>View Cart</a> to see all items...</li>" } else { strOutput += "<li>. . .</li>" } } } strOutput += "</ul>"; $.gritter.add({ title: strTitle, text: strOutput, sticky: false, time: strTime }) } function EnableAddToCartLink($lnkAddToCart) { $lnkAddToCart.attr(conCTBAttributeClicked, "false"); $lnkAddToCart.removeAttr("disabled") } function GetMessagesUnorderedListHtml(aryMessages) { var ulHtml = ""; ulHtml = "<ul>"; for (var i = 0; i < aryMessages.length; i++) { ulHtml += "<li>" + aryMessages[i] + "</li>" } ulHtml += "</ul>"; return ulHtml } function ResetAddedItemsToDefaultValue(oCartInfo) { var aryCartItems = oCartInfo.CartItemsAdded; $('.CartTextBox').each(function (event) { $txtMe = $(this); var i = 0; var blnFoundCurItem = false; while (i < aryCartItems.length && !blnFoundCurItem) { if (aryCartItems[i].Catalog == $txtMe.attr(conCTBAttributeCatalog) && aryCartItems[i].Vendor == $txtMe.attr(conCTBAttributeVendor)) { $txtMe.val($txtMe.attr(conCTBAttributeDefaultDisplayAmount)); blnFoundCurItem = true } i++ } }); if (typeof (gIsDetailPage) == 'undefined') { } else { if (gIsDetailPage) { if (typeof (gIsSpecialOrderItem) != 'undefined' && gIsSpecialOrderItem == false) { UpdateDetailPageTotalPrice(1) } } } } function InitializeCartTextBox($txtCurrent) { InitializeCartTextBoxToolTip($txtCurrent); $txtCurrent.bind('blur focus', function (event) { ValidateCurrentInput($(this)); return false }) } function InitializeCartTextBoxToolTip($txtCurItemInput) { var intMultiplesOf = $txtCurItemInput.attr(conCTBAttributeMultiplesOf) - 0; var strOriginalTitle = ""; var strPosition = ""; if (intMultiplesOf > 1) { var strTitle = $txtCurItemInput.attr(conCTBAttributeCatalog) + " needs to be ordered<br />in mulitiples of " + String(intMultiplesOf) + " (ie. " + String(intMultiplesOf) + ", " + String(intMultiplesOf * 2) + ", " + String(intMultiplesOf * 3) + " etc.)"; strOriginalTitle = $txtCurItemInput.attr("title"); $txtCurItemInput.attr("title", strTitle); strPosition = $txtCurItemInput.attr(conCTBAttributeErrorMesssagePosition); var strId = "#" + $txtCurItemInput.attr("id") + "[title]"; $(strId).tooltip({ tipClass: 'ToolTipCartItemTextboxError', position: strPosition, events: { def: "mouseenter,mouseleave", input: "null,null", widget: "focus mouseenter,blur mouseleave", tooltip: "mouseenter,mouseleave"} }); if (strOriginalTitle !== undefined) { $txtCurItemInput.attr("title", strOriginalTitle) } } } function ValidateCurrentInput($txtCurItemInput) { var intDefaultAmount = $txtCurItemInput.attr(conCTBAttributeDefaultDisplayAmount) - 0; var intMultiplesOf = $txtCurItemInput.attr(conCTBAttributeMultiplesOf) - 0; var strDefaultValue = String(intDefaultAmount); var strCurValue = $txtCurItemInput.val(); if ($txtCurItemInput.hasClass(conCTBErrorClass)) { $txtCurItemInput.removeClass(conCTBErrorClass) } var apiToolTip = $txtCurItemInput.data("tooltip"); if (apiToolTip != null) { apiToolTip.hide() } if (isNaN(parseInt(strCurValue))) { $txtCurItemInput.val(strDefaultValue) } else { var intAmount = parseInt(strCurValue); if (intAmount < 0) { $txtCurItemInput.val(strDefaultValue) } else { if (intMultiplesOf != 1 && apiToolTip != null) { if ((intAmount > 0) && (intAmount % intMultiplesOf) != 0) { $txtCurItemInput.addClass(conCTBErrorClass); apiToolTip.show(); window.setTimeout(function () { apiToolTip.hide() }, 12000) } } } } if (typeof (gIsDetailPage) == 'undefined') { } else { if (gIsDetailPage && $txtCurItemInput.attr(conCTBAttributeIsPrimaryCartTextBox) == "true") { if (typeof (gIsSpecialOrderItem) != 'undefined' && gIsSpecialOrderItem == false) { UpdateDetailPageTotalPrice(parseInt(strCurValue)) } } } } function UpdateDetailPageTotalPrice(qty) { var $lblPrice = $("#spnCurrentPrice"); var $lblUnit = $("#spnCurrentUnit"); var $displayUnit = $("input.prodUnit"); var unit = $displayUnit.val(); var dblPrice = parseFloat($("input.prodPriceEach").val()); var dblTotal = qty * dblPrice; $lblPrice.text("$" + dblTotal.toFixed(2)); $lblUnit.text("(for " + qty + " " + unit + ")") }
