var start = 0; $j(document).ready(function() { if (typeof pr !== "undefined") { var start = new Date(); start = start.getTime(); $j(window).on('beforeunload', function() { var end = new Date(); end = end.getTime(); r.timeonpageStart = start; r.timeonpageEnd = end; if ((end - start) > 0) { performAjaxCall('https://www.werkenvoorzeeland.nl/resources/ajax/conversionFunnelingSaveVisitData.php', r) } }); } }); var funnelFadeElement = $j('.site'); funnelPopupContainer = $j('.funnel-popup-container'); funnelPopupForm = $j('.funnel-popup-form'); funnelPopupMask = $j('.funnel-popup-mask'); function performAjaxCall(url, data, callbackOnSuccess) { if (callbackOnSuccess === "undefined") { callbackOnSuccess = ""; } var params = ''; if (data !== "undefined") { for (var key in data) { if (params != "") { params += "&"; } params += key + "=" + encodeURIComponent(data[key]); } } if (typeof url !== "undefined") { try { x = new(this.XMLHttpRequest || ActiveXObject)('MSXML2.XMLHTTP.3.0'); x.open("POST", url+'?'+params, 1); x.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); x.onreadystatechange = function () { x.readyState > 3 && typeof callbackOnSuccess === "function" && callbackOnSuccess(x.responseText); }; x.send(data); } catch (e) { window.console && console.log(e); } } } function showConversionFunnelingPopup() { funnelFadeElement.removeClass('noblur'); funnelFadeElement.addClass('blur'); funnelPopupContainer.fadeIn(250); setPopupDimensions(); } // Close button is clicked $j('.funnel-popup-close').click(function (e) { var data = new Object(); data.actie = "showpopup"; data.formulierid = "0"; data.lt = "0"; // User clicked 'close' so make it so the form is not shown again next time performAjaxCall('https://www.werkenvoorzeeland.nl/resources/ajax/conversionFunnelingPopup.php', data); funnelPopupContainer.fadeOut(250); funnelFadeElement.removeClass('blur'); funnelFadeElement.addClass('noblur'); }); function setPopupDimensions() { // Reset height for height calculations funnelPopupForm.css('height', 'auto'); // Popup is higher then window itself if (funnelPopupForm.height() > $j(window).height()) { funnelPopupForm.css('top', 20); funnelPopupForm.css('left', $j(window).width()/2 - funnelPopupForm.width()/2); funnelPopupForm.css('height', '100%'); // Disable double scrollbar $j('body').css('overflow', 'none'); } else { //Set the popup window to center vertically funnelPopupForm.css('top', $j(window).height()/2 - funnelPopupForm.height()/2); funnelPopupForm.css('left', $j(window).width()/2 - funnelPopupForm.width()/2); funnelPopupForm.css('height', 'auto'); // Disable double scrollbar $j('body').css('overflow', 'auto'); } } $j(window).resize(function () { setTimeout(function() { setPopupDimensions(); }, 50); });