var ExPass = ExPass || {}; ExPass.expassServerProduction = "https://www.excursionpass.net"; ExPass.expassServerSandbox = "https://www.excursionpass.net"; ExPass.environemtProduction = ExPass.expassServerProduction; ExPass.environemtSandbox = ExPass.expassServerSandbox; var spinner; var ExPass = ExPass || {}; ExPass.expassSandbox = ExPass.environemtSandbox; ExPass.expassProduction = ExPass.environemtProduction; function centerPosition(elem, elemWidth, elemHeight,largeViewport) { var e = window , a = 'inner'; if ( !( 'innerWidth' in window ) ) { a = 'client'; e = document.documentElement || document.body; } var width = e[ a+'Width' ]; var height = e[ a+'Height' ]; if(typeof elemWidth == 'string') { elemWidth = elemWidth.replace('%',''); var num1 = parseFloat(width); var elemWidth = (num1 * parseFloat('0.'+elemWidth)); } if(typeof elemHeight == 'string' && largeViewport == false) { elemHeight = elemHeight.replace('%',''); var num2 = parseFloat(height); var elemHeight = (num2 * parseFloat('0.'+elemHeight)); }else{ elem.style.top = 100 + "px"; } if (width > elemWidth) { elem.style.left = 0.5*(width - elemWidth) + "px"; } if (height > elemHeight && largeViewport == false) { elem.style.top = (0.5*(height - elemHeight))-100 + "px"; } } function showSpinner() { centerPosition(spinner, 30, 30); document.body.appendChild(spinner); } function hideSpinner() { try { document.body.removeChild(spinner); } catch (e) { } } function expassCheckout(token, returnUrl, cancelUrl, uniqueId, isSandbox, closeCallbackFunc){ expassStartCheckout({ token: token, returnUrl : returnUrl, cancelUrl : cancelUrl, uniqueId: uniqueId, isSandbox : isSandbox, closeCallbackFunc : closeCallbackFunc }); } function thanksPaypal(lang){ expassStartCheckout(lang) } function expassGetQueryParam(name){ name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); var results = regex.exec(window.location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } function expassMaybeShowPaypalConfirmation(){ var paypalStatus = expassGetQueryParam('paypal'); var statusCode = expassGetQueryParam('statusCode'); var pp = expassGetQueryParam('pp'); if(paypalStatus != 'completed' && !(pp != '' && statusCode == '0'))return; var confirmationKey = 'expass_paypal_confirmation_' + (pp != '' ? pp : expassGetQueryParam('transactionID')); try { if(sessionStorage.getItem(confirmationKey))return; sessionStorage.setItem(confirmationKey,'1'); } catch(e) {} var lang = expassGetQueryParam('lang'); if(lang == '')lang = 'EN'; lang = lang.toUpperCase(); setTimeout(function(){ thanksPaypal(lang); },250); } function expassStartCheckout(expassParams) { if (document.getElementById('expassOverlay')) { return; } if (!expassParams.token && expassParams.length > 3) { return; } if (!expassParams.uniqueId && expassParams.length > 3) { return; } var expassServer; if (expassParams.isSandbox) { expassServer = ExPass.expassSandbox; } else { expassServer = ExPass.expassProduction; } var iframeWidth = 90 + "%"; var iframeHeight = 400 + "px"; var iframeWidthXL = 520 + "px"; var iframeHeightXL = 540 + "px"; var largeViewport = false; var pixelRatio = 1; try { pixelRatio = window.devicePixelRatio; } catch (e) { pixelRatio = 1; } if (pixelRatio === undefined || pixelRatio == 1) { try { if (!expassParams.useMobileSize && window.matchMedia("(min-device-width: 540px)").matches && window.matchMedia("(min-device-height: 560px)").matches) { largeViewport = true; } } catch (e) { try { if (window.matchMedia("(min-width: 540px)").matches && window.matchMedia("(min-height: 560px)").matches) { largeViewport = true; } } catch (e) { var isIE7 = navigator.userAgent.match(/MSIE 7.0/i); var isIE8 = navigator.userAgent.match(/MSIE 8.0/i); var isIE9 = navigator.userAgent.match(/MSIE 9.0/i); var isIEMobile = navigator.userAgent.match(/IEMobile/i); if (isIE7 || isIE8 || (isIE9 && !isIEMobile)) { largeViewport = true; } } } try { if (!expassParams.useMobileSize && window.matchMedia("(min-device-width: 375px)").matches && window.matchMedia("(min-device-height: 667px)").matches) { ipnoneSixViewport = true; } } catch (e) { try { if (window.matchMedia("(min-width: 375px)").matches && window.matchMedia("(min-height: 667px)").matches) { ipnoneSixViewport = true; } } catch (e) { var isIE7 = navigator.userAgent.match(/MSIE 7.0/i); var isIE8 = navigator.userAgent.match(/MSIE 8.0/i); var isIE9 = navigator.userAgent.match(/MSIE 9.0/i); var isIEMobile = navigator.userAgent.match(/IEMobile/i); if (isIE7 || isIE8 || (isIE9 && !isIEMobile)) { ipnoneSixViewport = false; } } } try { if (!expassParams.useMobileSize && window.matchMedia("(min-device-width: 414px)").matches && window.matchMedia("(min-device-height: 736px)").matches) { ipnoneSixPlusViewport = true; } } catch (e) { try { if (window.matchMedia("(min-width: 414px)").matches && window.matchMedia("(min-height: 736px)").matches) { ipnoneSixPlusViewport = true; } } catch (e) { var isIE7 = navigator.userAgent.match(/MSIE 7.0/i); var isIE8 = navigator.userAgent.match(/MSIE 8.0/i); var isIE9 = navigator.userAgent.match(/MSIE 9.0/i); var isIEMobile = navigator.userAgent.match(/IEMobile/i); if (isIE7 || isIE8 || (isIE9 && !isIEMobile)) { ipnoneSixPlusViewport = false; } } } } if(navigator.userAgent.match(/iPad/i) != null)largeViewport = true; var isIE = navigator.userAgent.match(/MSIE/i); var iframeSrc = expassServer + "/mobile/mobileweb/expass-hub?token=" + expassParams.token + "&uniqueID=" + expassParams.uniqueId; if(expassParams.length == 2)iframeSrc = expassServer + "/mobile/mobileweb/confirmation?lang="+expassParams; if(expassParams.length == 3)iframeSrc = expassServer + "/mobile/mobileweb/confirmation?photopass=1&lang="+expassParams.replace('1',''); if(!checkIfMobile())largeViewport = true; if (expassParams.overrideScreenSize){ if (expassParams.overrideScreenSize.toLowerCase() === 'large'){ largeViewport = true; } else if (expassParams.overrideScreenSize.toLowerCase() === 'small') { largeViewport = false; } } if (largeViewport == true) { iframeWidth = iframeWidthXL; iframeHeight = iframeHeightXL; } iframeSrc += "&largeViewport=" + largeViewport; spinner = document.createElement('img'); spinner.src = expassServer + "/mobile/mobileweb/img/loader_spinner.gif"; spinner.style.position = 'absolute'; spinner.style.zIndex = "99999"; spinner.style.opacity = 0.4; spinner.style.filter = 'alpha(opacity=40)'; showSpinner(); expassOverlay = document.createElement('div'); expassOverlay.id = 'expassOverlay'; if(!isIE) { expassOverlay.style.background = 'none repeat scroll 0 0 rgba(150, 150, 150, 0.6)'; } expassOverlay.style.top = '0'; expassOverlay.style.left = '0'; expassOverlay.style.height = "100%"; expassOverlay.style.width = "100%"; expassOverlay.style.overflowX = 'hidden'; expassOverlay.style.overflowY = 'auto'; expassOverlay.style.WebkitOverflowScrolling = 'touch'; expassOverlay.style.position = 'fixed'; expassOverlay.style.zIndex = "99901"; document.body.appendChild(expassOverlay); expassIframeContainer = document.createElement('div'); expassIframeContainer.setAttribute('id', 'expassIframeContainer'); expassIframeContainer.style.border = "1px outset white"; expassIframeContainer.style.borderRadius = "6px"; expassIframeContainer.style.MozBorderRadius = "6px"; expassIframeContainer.style.WebkitBorderRadius = "6px"; expassIframeContainer.style.background = "none repeat scroll 0% 0% #F9F9F9"; expassIframeContainer.style.height = iframeHeight; expassIframeContainer.style.margin = "auto"; expassIframeContainer.style.position = "absolute"; expassIframeContainer.style.paddingTop = "1px"; expassIframeContainer.style.width = iframeWidth; expassIframeContainer.style.zIndex = "99902"; expassIframeContainer.style.webkitTransform = "translate3D(0,0,0)"; centerPosition(expassIframeContainer, iframeWidth, iframeHeight); expassOverlay.appendChild(expassIframeContainer); var expassIframe = document.createElement('iframe'); expassIframe.style.background = 'none'; expassIframe.style.border = "medium none"; expassIframe.style.height = "99%"; expassIframe.style.margin = "0"; expassIframe.style.overflowY = 'auto'; expassIframe.style.overflowx = 'hidden'; expassIframe.style.padding = "0"; expassIframe.style.width = "100%"; if (expassParams.returnUrl) { iframeSrc += "&returnUrl=" + expassParams.returnUrl; } if (expassParams.cancelUrl) { } if (expassParams.rememberMeDefault == false) { } if (expassParams.preferredLanguage) { iframeSrc += "&preferredLanguage=" + expassParams.preferredLanguage; } if (expassParams.customStylesheet) { } if (expassParams.completeCallBackFunc) { iframeSrc += "&callbackDomain=" + window.location.protocol + "//" + window.location.host; var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; var eventer = window[eventMethod]; var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; eventer(messageEvent,function(e) { if (e.origin === expassServer) { if (expassOverlay && expassOverlay.parentNode) { expassOverlay.parentNode.removeChild(expassOverlay); expassParams.completeCallBackFunc(e.data); } } },false); } expassIframe.setAttribute('src', iframeSrc); function onIframeLoad() { var expassCloseButton = new Image(); expassCloseButton.src = expassServer + "/mobile/mobileweb/img/close_button.png"; expassCloseButton.style.cursor = "pointer"; expassCloseButton.style.position = "absolute"; var leftBtn = iframeWidth - 15; expassCloseButton.style.right = -5+"%"; var bottomBtn = iframeHeight - 15; expassCloseButton.style.top = -3+"%"; expassCloseButton.style.zIndex = "99903"; expassCloseButton.onclick = function() { document.body.removeChild(document.getElementById('expassOverlay')); hideSpinner(); if (expassParams.closeCallbackFunc) { expassParams.closeCallbackFunc(); } }; expassIframeContainer.appendChild(expassCloseButton); hideSpinner(); } if (isIE) { expassIframe.attachEvent("onload", onIframeLoad); } else { expassIframe.onload = onIframeLoad(); } expassIframe.setAttribute('id', 'expassIframe'); expassIframe.setAttribute('name', 'expassIframe'); expassIframeContainer.appendChild(expassIframe); var reposition = function(){ previousOrientation = window.orientation; expassOverlay.style.height = "100%"; expassOverlay.style.width = "100%"; centerPosition(expassIframeContainer, iframeWidth, iframeHeight); centerPosition(spinner, 30, 30); return false; }; window.onresize = reposition; if (!navigator.userAgent.match(/android/i)) { window.onorientationchange = reposition; } }; function checkIfMobile(){ var ua = navigator.userAgent.toLowerCase(); var platform = navigator.platform.toLowerCase(); var platformName = ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0]; var isMobile = /ios|android|webos/.test(platformName); return isMobile; } function popExcursionPass(it){ it.disabled = "true"; var path = window.location.protocol + "//" + window.location.host + "/"; if(checkIfMobile()) { document.body.style.position = "fixed"; } var varname = 'ExPass_min'; var PhotoPass = ''; var TourID = ''; var ExPass_amount = 0; var value = (it.getAttribute("tot")!=undefined?it.getAttribute("tot"):0); var pics = it.getAttribute("pics"); var BookingParams = ''; if(window[varname].TransactionType == 'photopass') { PhotoPass = pics; ExPass_amount = value; window[varname].PurchaseDescription = ('PhotoPass: '+it.getAttribute("tourname")).replace(/(\r\n|\n|\r)/gm," ");; }else{ ExPass_amount = window[varname].Amount; } if(window[varname].TourID != undefined) { TourID = window[varname].TourID; }else{ TourID = it.getAttribute("tourid"); } if(window[varname].BookingParams != undefined) { BookingParams = JSON.stringify(window[varname].BookingParams); }else{ BookingParams = it.getAttribute("bookparams"); } if(window[varname].Token != undefined && window[varname].Token != 'undefined' ) { Token = window[varname].Token; }else{ Token = (new Date).getTime(); } if(window[varname].Code != undefined) { CodeID = window[varname].Code; }else{ CodeID = it.getAttribute("code"); } if(window[varname].terminal != undefined) { Terminal = window[varname].terminal; }else{ Terminal = it.getAttribute("terminal"); } var ExPass_sandboxActive = window[varname].SandboxActive; var ExPass_language = window[varname].Language; var ExPass_currency = window[varname].Currency; var ExPass_transactionType = window[varname].TransactionType; var ExPass_purchaseDescription = window[varname].PurchaseDescription; var ExPass_isShippingRequired = window[varname].isShippingRequired; var Expass_productCode = CodeID; var ExPass_CustomerParams = JSON.stringify(window[varname].CustomerParams); var Ds_MerchantParameters = { "DS_MERCHANT_TERMINAL": Terminal, "DS_MERCHANT_ORDER" : (new Date).getTime(), "DS_MERCHANT_ISSANDBOX" : ExPass_sandboxActive, "DS_MERCHANT_LANGUAGE" : ExPass_language, "DS_MERCHANT_CURRENCY" : ExPass_currency, "DS_MERCHANT_AMOUNT" : ExPass_amount, "DS_MERCHANT_TRANSACTIONTYPE" : ExPass_transactionType, "DS_MERCHANT_PURCHASE_DESCRIPTION" : ExPass_purchaseDescription, "DS_MERCHANT_CUSTOMER_PARAMS" : ExPass_CustomerParams, "DS_MERCHANT_BOOKING_PARAMS" : BookingParams, "DS_MERCHANT_PRODUCT_CODE" : Expass_productCode, "DS_MERCHANT_INTEGRITY" : 1, "DS_MERCHANT_PHOTOPASS" : PhotoPass, "DS_MERCHANT_TOURID" : TourID }; expassStartCheckout({ token : Token, uniqueId : btoa(JSON.stringify(Ds_MerchantParameters)), isSandbox : ExPass_sandboxActive, returnUrl : window.location.href , cancelUrl : window.location.href , preferredLanguage: ExPass_language, isShippingRequired : ExPass_isShippingRequired, closeCallbackFunc : function() { document.body.style.position = ""; }, }); } function startExcursionPass(){ var button = document.querySelectorAll(".ExcursionPasscheckoutButton"); for (var J = button.length - 1; J >= 0; --J) { button[J].addEventListener("click",function(e){ e = e || window.event; var target = e.target || e.srcElement; popExcursionPass(this); },false); } } document.addEventListener('DOMContentLoaded', function(){ startExcursionPass(); expassMaybeShowPaypalConfirmation(); });