var debug = false; var popup; window.onfocus = function() { if (popup != null && !popup.closed) popup.focus(); } window.onunload = function() { if (popup != null && !popup.closed) popup.close(); } /* --- Popups for the data entry --- */ function quickEditRequest(id) { if (document.forms.requestForm == null || document.forms.requestForm['request.id'] == null) return; id = document.forms.requestForm['request.id'].value; if (id == null || id == "") return; { openEditRequest(id); } } function openPromoSelling() { url = "/services-personalSellingOverview.jsp"; openPopup(url,800, 600, "popup", true); } function openViewAllFulfillment(documentNumber) { url = "/do/admin/warehouse/viewAllFulfillment?documentNumber=" + documentNumber; openPopup(url,800, 450, "popup", false); } function openViewAllGPFulfillment(invoiceNumber) { url = "/do/admin/warehouse/viewAllGPFulfillment?invoiceNumber=" + invoiceNumber; openPopup(url,600, 650, "popup", false); } function openOrderItems(orderNumber) { url = "/do/admin/warehouse/orderItems?orderNumber=" + orderNumber; openPopup(url,800, 450, "popup", false); } function openEditFulfillment(fulfillmentId) { url = "/do/admin/warehouse/editFulfillment?doAction=edit&fulfillmentId=" + fulfillmentId; openPopup(url,750, 700, "popup", false); } function openFulfillmentHistory(fulfillmentId) { url = "/do/admin/warehouse/fulfillmentLogHistory?fulfillmentId=" + fulfillmentId; openPopup(url,800, 560, "popup", true ); } function openFulfillmentInstructionsHistory(orderRequestId) { url = "/do/admin/fulfillmentInstructionsHistory?orderRequestId=" + orderRequestId; openPopup(url,800, 560, "popup", true ); } function openFulfillmentInstructionsHistoryForMove(moveRequestId) { url = "/do/admin/fulfillmentInstructionsHistory?moveRequestId=" + moveRequestId; openPopup(url,800, 560, "popup", true ); } function openQuoteRequestHistory(quoteRequestId) { url = "/do/admin/quoteRequestHistory?quoteRequestId=" + quoteRequestId; openPopup(url,800, 560, "popup", true ); } function openGiftCardDetailView(giftCardId) { url = "/do/admin/giftCardDetail?doAction=view&id=" + giftCardId; openPopup(url,800, 800, "popup", false ); } function openGiftCardDetailEdit(giftCardId) { url = "/do/admin/giftCardDetail?doAction=edit&id=" + giftCardId; openPopup(url,800, 800, "popup", false ); } function openCreateGiftCard(giftCardId) { url = "/do/admin/giftCard?doAction=create&id=" + giftCardId; openPopup(url,800, 800, "popup", false ); } function openGiftCardDetailApproved(giftCardId) { url = "/do/admin/giftCardDetail?doAction=approveGiftCard&id=" + giftCardId; openPopup(url,800, 800, "popup", false ); } function openMoveRequest(requestId) { url = "/do/user/request?doReset=true&salesForceId=" + requestId; openPopup(url, 588, 493, "popup", true); } function openVintage(wineId, year) { url = "/do/cellar/vintage?doReset=true&pageName=overview&vintage.wine.id=" + wineId + "&vintage.year=" + year + "&contextName=cellar"; openPopup(url, 770, 550, "popup", true); } function disableOpenVintage() { window.openVintage = function(wineId, year) { return; }; } function openRetailVintage(wineId, year, size) { url = "/do/cellar/vintage?doReset=true&pageName=overview&vintage.wine.id=" + wineId + "&vintage.year=" + year + "&contextName=retail&size=" + size; openPopup(url, 770, 550, "popup", true); } function openVintageNotes(bottleId) { url = "/do/cellar/vintage?doReset=true&pageName=notes&bottle.id=" + bottleId + "&contextName=cellar"; openPopup(url, 770, 550, "popup", true); } function openStatement(customerId, statementDate) { url = "/do/user/statement?customerId=" + customerId + "&statementDate="+statementDate; openPopup(url,700, 700, "popup", true); } function openVinfolioStorageActivity(customerId, statementDate) { url = "/do/user/vinfolioStorageActivity?customerId=" + customerId + "&statementDate="+statementDate; openPopup(url,700, 700, "popup", true); } function openWine(wineId, year) { url = "/do/cellar/wineSearch?doReset=true&query=" + wineName; openPopup(url, 400, 525, "popup", false); } function openWineSearch(wineName) { url = "/do/cellar/wineSearch?doReset=true&query=" + wineName; openPopup(url, 400, 525, "popup", false); } function openChangePassword() { url = "/do/user/password?doReset=true"; openPopup(url, 511, 349, "popup", false); } function openViewPriority() { url = "/do/user/priority?doReset=true"; openPopup(url, 511, 349, "popup", false); } function openEditPreferences() { url = "/do/user/preferences?doReset=true"; openPopup(url, 641, 500, "popup", false); } function openEditEmailPreferences() { url = "/do/user/emailPreferences"; openPopup(url, 641, 500, "popup", false); } function openRedeemGiftCard() { url = "/do/store/redeemGiftCard"; openPopup(url, 641, 500, "popup", false); } function openEditBurghound() { url = "/do/user/burghound?doReset=true"; openPopup(url, 511, 690, "popup", false); } function openSendRequest(context) { url = "/do/user/sendRequest?doReset=true&context=" + context; openPopup(url, 511, 350, "sendRequest", false); } function openBreakCase(bottleId) { url = "/do/cellar/break?doAction=start&doReset=true&bottle.id=" + bottleId; openPopup(url, 588, 505, "popup", false); } function openReceivePrearrival(bottleId) { url = "/do/cellar/receive?doReset=true&bottle.id=" + bottleId; openPopup(url, 511, 423, "popup", false); } function openUpdatePrearrival(bottleId) { url = "/do/cellar/updatePrearrival?doReset=true&bottle.id=" + bottleId; openPopup(url, 474, 343, "popup", false); } function openAssignToCase(wineId, year) { url = "/do/cellar/assign?doAction=start&doReset=true&vintage.year=" + year + "&vintage.wine.id=" + wineId; openPopup(url, 588, 505, "popup", false); } function openAssignCase(bottleId) { url = "/do/cellar/assign?doAction=start&doReset=true&bottle.id=" + bottleId; openPopup(url, 588, 505, "popup", false); } function openMoveCellar(bottleId) { url = "/do/cellar/moveCellar?doAction=start&doReset=true&bottle.id=" + bottleId; openPopup(url, 588, 493, "popup", false); } function openViewInvoiceImage(bottleId) { url = "/do/cellar/invoiceImage?doAction=start&doReset=true&bottle.id=" + bottleId; openPopup(url, 500, 450, "popup", false); } function openNotes(wineId, year) { url = "/do/cellar/vintage?doReset=true&page=overview&vintage.wine.id=" + wineId + "&vintage.year=" + year + "&contextName=cellar"; openPopup(url, 770, 542, "popup", true); } function openUndoRemoval(bottleId) { url = "/do/cellar/undoRemove?doReset=true&bottle.id=" + bottleId; openPopup(url, 500, 490, "popup", false); } function openEditRemoveComment(bottleId) { url = "/do/cellar/editRemoveComment?bottle.id=" + bottleId; openPopup(url, 400, 300, "popup", false); } function openEditTastingNote(noteId) { url = "/do/cellar/tastingNote?doReset=true&tastingNote.id=" + noteId + "&doAction=edit"; openPopup(url, 400, 525, "popup", false); } function openAddTastingNote(wineId, year) { url = "/do/cellar/tastingNote?doReset=true&doAction=add&tastingNote.wine.id=" + wineId + "&tastingNote.year=" + year; openPopup(url, 400, 525, "popup", false); } function openEditTransaction(bottleId) { url = "/do/cellar/transaction?doReset=true&bottle.id=" + bottleId; openPopup(url, 588, 645, "popup", false); } function openEditSellingServicePrice(bottleId) { url = "/do/cellar/forsale?doAction=editPrice&bottle.id=" + bottleId; openPopup(url, 400, 300, "popup", false); } function openEditSellingServicePayment(bottleId) { url = "/do/cellar/forsale?doAction=changePayment&bottle.id=" + bottleId; openPopup(url, 400, 300, "popup", false); } function openEditMarketValue(bottleId) { url = "/do/cellar/valuation?doAction=editMarketValue&bottle.id=" + bottleId; openPopup(url, 400, 310, "popup", false); } function openEditAverageCost(bottleId) { url = "/do/cellar/valuation?doAction=editAverageCost&bottle.id=" + bottleId; openPopup(url, 400, 310, "popup", false); } function openAddTransaction(wineId, year) { url = "/do/cellar/transaction?doReset=true&doAction=add&transaction.wine.id=" + wineId + "&transaction.year=" + year; openPopup(url, 400, 525, "popup", false); } function openProducerSearch(producerName) { url = "/do/admin/producerSearch?search=" + producerName; openPopup(url, 400, 525, "popup", false); } function openRetailSearch(year, query) { url = "/do/winesourcer/retailSearch?doReset=true&query=" + query + "&year=" + year; openPopup(url, 400, 525, "popup", false); } function openMoveLocation(bottleId) { url = "/do/cellar/moveLocation?doAction=start&doReset=true&bottle.id=" + bottleId; openPopup(url, 588, 600, "popup", false); } function openSite(id, source, action, customerId) { url = "/do/cellar/site?site.id=" + id + "&doReset=true&doAction=" + action + "&source=" + source; if (customerId) { url = url +"&customerId="+customerId; } openPopup(url, 588, 507, "popup", false); } function openManageWineClubRequestView(action, wineClubRequestId) { url = "/do/user/manageWineClubRequests?doAction=" + action + "&wineClubRequestId=" + wineClubRequestId; openPopup(url, 600, 630, "popup", false); } function openCreditCard(action, id) { url = "/do/user/creditCard?doReset=true&doAction=" + action +"&id="+id; openPopup(url, 588, 620, "popup", false); } function openShippingAddress(action, type, index) { url = "/do/user/shippingAddress?doReset=true&doAction=" + action +"&type="+type+"&index="+index; openPopup(url, 588, 580, "popup", false); } function openDeliverySite(id, source, action) { url = "/do/cellar/site?site.id=" + id + "&doReset=true&doAction=" + action + "&source=" + source + "&delivery=true"; openPopup(url, 474, 230, "popup", false); } function openCellar() { url = "/do/cellar/cellar?doReset=true"; openPopup(url, 588, 493, "popup", false); } function openEditRequest(type) { url = "/do/user/editRequest?&doReset=true&opportunity.serviceType=" + type; openPopup(url, 400, 525, "popup", false); } function openProvenance(bottleId) { url = "/do/cellar/provenance?bottle.id=" + bottleId; openPopup(url, 400, 525, "popup", false); } function viewSellRequest( sellRequestId ) { url = '/do/admin/sellRequestDetail?doAction=details&sellRequestId=' + sellRequestId; window.document.location=url; } function openSellRequestHistory(sellRequestId) { url = "/do/admin/sellRequestHistory?sellRequestId=" + sellRequestId; openPopup(url,800, 580, "popup", true ); } function openCreatePurchaseOrder(sellRequestId) { url = "/do/admin/createPurchaseOrder?doAction=init&sellRequestId=" + sellRequestId; openPopup(url,800, 640, "popup", true ); } function openCreateItemCards(sellRequestId) { url = "/do/admin/sellRequestDetail?doAction=viewBulk&sellRequestId=" + sellRequestId; openPopup(url,880, 760, "popup", true ); } function openSellRequestEmail(opportunityId) { url = "https://na6.salesforce.com/email/author/emailauthor.jsp?p3_lkid=" + opportunityId; openPopup(url,800, 580, "popup", true ); } function openMergeSellRequest(sellRequestId) { url = "/do/admin/mergeSellRequests?sellRequestId=" + sellRequestId; openPopup(url,650, 600, "popup", false ); } function openEditSellRequest(sellRequestId) { url = "/do/admin/editSellRequest?doAction=edit&sellRequestId=" + sellRequestId; openPopup(url,650, 500, "popup", false); } function openMergeOrderRequest(orderRequestId) { url = "/do/admin/mergeOrderRequests?orderRequestId=" + orderRequestId; openPopup(url,650, 600, "popup", false ); } function openEditOrderRequest(orderRequestId) { url = "/do/admin/orderRequestDetail?doAction=edit&orderRequestId=" + orderRequestId; openPopup(url,750, 700, "popup", false ); } function openEditMoveRequest(moveRequestId) { url = "/do/admin/moveRequestDetail?doAction=edit&moveRequestId=" + moveRequestId; openPopup(url,750, 700, "popup", false ); } function openOrderRequestDetail(orderRequestId) { url = "/do/admin/orderRequestDetail?doAction=view&orderRequestId=" + orderRequestId; openPopup(url,650, 700, "popup", false ); } function openMoveRequestDetail(moveRequestId) { url = "/do/admin/moveRequestDetail?doAction=view&moveRequestId=" + moveRequestId; openPopup(url,650, 700, "popup", false ); } function openQuoteRequestDetail(quoteRequestId) { url = "/do/admin/quoteRequestDetail?doAction=view"eRequestId=" + quoteRequestId; openPopup(url,650, 400, "popup", false ); } function openQuoteRequestEdit(quoteRequestId) { url = "/do/admin/quoteRequestDetail?doAction=edit"eRequestId=" + quoteRequestId; openPopup(url,650, 800, "popup", false ); } function openEditOrderRequestItemQuantity(orderRequestId, wineId, year) { url = "/do/admin/orderRequestItem?doAction=updateQuantity&orderRequestId=" + orderRequestId+"&wineId="+wineId+"&year="+year; openPopup(url,350, 300, "popup", false ); } function openEditOrderRequestItemQuantityKit(orderRequestId,kitId){ url = "/do/admin/orderRequestItem?doAction=updateQuantityKit&orderRequestId=" + orderRequestId+"&kitId="+kitId; openPopup(url,350, 300, "popup", false ); } function openCreateQuoteRequest(orderRequestId, wineId, year) { url = "/do/admin/orderRequestItem?doAction=createQuote&orderRequestId=" + orderRequestId+"&wineId="+wineId+"&year="+year; openPopup(url,400, 300, "popup", false ); } function openWineClubItemDetail(wineClubItemId) { url = "/do/admin/wineClubAdminDetail?doAction=view&wineClubRequestItemId=" + wineClubItemId; openPopup(url,650, 700, "popup", false ); } function openEditWineClubItemRequest(wineClubItemId) { url = "/do/admin/wineClubAdminDetail?doAction=edit&wineClubRequestItemId=" + wineClubItemId; openPopup(url,650, 400, "popup", false ); } function openBarcodes(bottleId) { url = "/do/cellar/barcodes?doReset=true&bottleId=" + bottleId; openPopup(url, 450, 550, "popup", true); } function openSellRequestReceiptsReject(numberOfBottles, bottleId, sellRequestId) { url = "/do/admin/warehouse/sellRequestReceiptsReject?doAction=init&numberOfBottles=" + numberOfBottles + "&bottleId="+ bottleId + "&sellRequestId=" + sellRequestId; openPopup(url,850, 450, "popup", false); } function openSellRequestReceiptsUnReject(numberOfBottles, bottleId, sellRequestId) { url = "/do/admin/warehouse/sellRequestReceiptsReject?doAction=initUnReject&numberOfBottles=" + numberOfBottles + "&bottleId="+ bottleId + "&sellRequestId=" + sellRequestId; openPopup(url,850, 450, "popup", false); } function openSellRequestReceiptsComplete(sellRequestId) { url = "/do/admin/warehouse/sellRequestReceiptsComplete?doAction=init&sellRequestId=" + sellRequestId; openPopup(url,800, 650, "popup", false); } function openAddCustomerToLoyaltyProgram(customerId) { url = "/do/admin/addCustomerToLoyaltyProgram?doAction=init&customerId=" + customerId; openPopup(url,450, 250, "popup", false); } function openEditKit(kitId) { url = "/do/admin/editKit?doAction=init&kitId=" + kitId; openPopup(url,650, 450, "popup", false); } function openSellRequestPrint(qty,barcode) { url = "/do/admin/sellRequestReceipts?doAction=partialBarcodes&numberOfItems=" + qty + "&barcode=" + barcode; openPopup(url,400, 400, "popup", false); } function openHelp(page) { url = "/jsp/help/" + page; openPopup(url, 400, 525, "helpPopup", false); } function openMediumHelp(page) { url = "/jsp/help/" + page; openPopup(url, 650, 500, "popup", false); } function openLargeHelp(page) { url = "/jsp/help/" + page; openPopup(url, 850, 710, "popup", false); } function showTerms(anchor) { url = "/jsp/company/terms.jsp"; if(anchor!=undefined) { url = url + "#" + anchor; } openPopup(url, 850, 710, "popup", true); } function openViewStockDetail(id, deleteAll) { if(deleteAll) { url = "/do/admin/warehouse/viewStockDetail?bottle.id=" + id + "&doAction=deleteAll"; } else { url = "/do/admin/warehouse/viewStockDetail?bottle.id=" + id + "&doAction=detail"; } openPopup(url, 730, 535, "popup", false); } function openPopup(url, width, height, name, scrollable) { var winWidth = width; var winHeight = height; // popup in screen center var winScreenX = (screen.availWidth - winWidth)/2; var winScreenY = (screen.availHeight - winHeight)/2; var canScroll = ( scrollable ? "yes" : "no" ); popup = window.open(url, name, 'scrollbars=' + canScroll + ',location=NO,resizable=YES,status=YES,width=' + winWidth + ',height=' + winHeight + ',screenX=' + winScreenX + ',screenY=' + winScreenY + ',left=' + winScreenX + ',top=' + winScreenY); popup.focus(); return popup; } function openTimeoutPopup(url, width, height, name, scrollable) { var winWidth = width; var winHeight = height; // popup in screen center var winScreenX = (screen.availWidth - winWidth)/2; var winScreenY = (screen.availHeight - winHeight)/2; var canScroll = ( scrollable ? "yes" : "no" ); popup = window.open(url, name, 'scrollbars=' + canScroll + ',location=NO,resizable=YES,status=YES,width=' + winWidth + ',height=' + winHeight + ',screenX=' + winScreenX + ',screenY=' + winScreenY + ',left=' + winScreenX + ',top=' + winScreenY); popup.focus(); } function closeAndLoadParent(popupWin, parentUrl) { loadParent(popupWin, parentUrl); closePopup(popupWin); } function closeAndReloadParent(popupWin) { reloadParent(popupWin); closePopup(popupWin); } function closeAndRefreshParent(popupWin) { refreshParent(popupWin); closePopup(popupWin); } function closePopup(popupWin) { popupWin.close(); if (popupWin.opener != null && !popupWin.opener.closed) { popupWin.opener.popup = null; popupWin.opener.focus(); } } function reloadParent(popupWin) { loadParent(popupWin, null); } function refreshParent(popupWin) { popupWin.top.window.opener.location.search = '?doAction=refresh'; } function loadParent(popupWin, parentUrl) { if (popupWin.top.window.opener != null) { var url = parentUrl; if (url == null) url = popupWin.top.window.opener.location.href; popupWin.top.window.opener.location.replace(url); } else { alert("There is no opener to reload"); } } function next(form) { form['doAction'].value = "next"; form.submit(); } function previous(form) { form['doAction'].value = "previous"; form.submit(); } function doAction(form, action) { form['doAction'].value = action; form.submit(); } function resizePopupContainers() { var windowHeight = getWindowHeight(); var popupTitle = document.getElementById("popupPageTitle"); var popupBody = document.getElementById("popupBody"); var popupButtons = document.getElementById("popupButtons"); var ieFix = (document.all) ? 3 : 0; popupBody.style.height = windowHeight - popupTitle.offsetHeight - popupButtons.offsetHeight -18 + ieFix + "px"; }