/*! iFrame Resizer (iframeSizer.min.js ) - v4.0.4 - 2019-03-04
 *  Desc: Force cross domain iframes to size to content.
 *  Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame.
 *  Copyright: (c) 2019 David J. Bradshaw - dave@bradshaw.net
 *  License: MIT
 */

!function(u){if("undefined"!=typeof window){var e,l=0,m=!1,n=!1,p="message".length,b="[iFrameSizer]",y=b.length,v=null,r=window.requestAnimationFrame,g={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},F={},i=null,h={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClosed:function(){},onInit:function(){},onMessage:function(){O("onMessage function not defined")},onResized:function(){},onScroll:function(){return!0}},I={};window.jQuery&&((e=window.jQuery).fn?e.fn.iFrameResize||(e.fn.iFrameResize=function(i){return this.filter("iframe").each(function(e,n){d(n,i)}).end()}):z("","Unable to bind to jQuery, it is not fully loaded.")),"function"==typeof define&&define.amd?define([],B):"object"==typeof module&&"object"==typeof module.exports&&(module.exports=B()),window.iFrameResize=window.iFrameResize||B()}function w(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function M(e,n,i){e.addEventListener(n,i,!1)}function x(e,n,i){e.removeEventListener(n,i,!1)}function o(e){return b+"["+(i="Host page: "+(n=e),window.top!==window.self&&(i=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+n:"Nested host page: "+n),i)+"]";var n,i}function t(e){return F[e]?F[e].log:m}function k(e,n){a("log",e,n,t(e))}function z(e,n){a("info",e,n,t(e))}function O(e,n){a("warn",e,n,!0)}function a(e,n,i,t){!0===t&&"object"==typeof window.console&&console[e](o(n),i)}function s(n){function a(){e("Height"),e("Width"),P(function(){j(h),C(w),l("onResized",h)},h,"init")}function e(e){var n=Number(F[w]["max"+e]),i=Number(F[w]["min"+e]),t=e.toLowerCase(),o=Number(h[t]);k(w,"Checking "+t+" is in range "+i+"-"+n),o<i&&(o=i,k(w,"Set "+t+" to min value")),n<o&&(o=n,k(w,"Set "+t+" to max value")),h[t]=""+o}function s(e){return g.substr(g.indexOf(":")+p+e)}function d(i,t){var e,n,o;e=function(){var e,n;H("Send Page Info","pageInfo:"+(e=document.body.getBoundingClientRect(),n=h.iframe.getBoundingClientRect(),JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(n.top-e.top,10),offsetLeft:parseInt(n.left-e.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset})),i,t)},n=32,I[o=t]||(I[o]=setTimeout(function(){I[o]=null,e()},n))}function c(e){var n=e.getBoundingClientRect();return N(w),{x:Math.floor(Number(n.left)+Number(v.x)),y:Math.floor(Number(n.top)+Number(v.y))}}function f(e){var n=e?c(h.iframe):{x:0,y:0},i={x:Number(h.width)+n.x,y:Number(h.height)+n.y};k(w,"Reposition requested from iFrame (offset x:"+n.x+" y:"+n.y+")"),window.top!==window.self?window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):O(w,"Unable to scroll to requested position, window.parentIFrame not found"):(v=i,u(),k(w,"--"))}function u(){!1!==l("onScroll",v)?C(w):S()}function l(e,n){return R(w,e,n)}var i,t,o,r,m,g=n.data,h={},w=null;"[iFrameResizerChild]Ready"===g?function(){for(var e in F)H("iFrame requested init",A(e),document.getElementById(e),e)}():b===(""+g).substr(0,y)&&g.substr(y).split(":")[0]in F?(m=g.substr(y).split(":"),h={iframe:F[m[0]]&&F[m[0]].iframe,id:m[0],height:m[1],width:m[2],type:m[3]},w=h.id,F[w]&&(F[w].loaded=!0),(r=h.type in{true:1,false:1,undefined:1})&&k(w,"Ignoring init message from meta parent page"),!r&&(o=!0,F[t=w]||(o=!1,O(h.type+" No settings for "+t+". Message was: "+g)),o)&&(k(w,"Received: "+g),i=!0,null===h.iframe&&(O(w,"IFrame ("+h.id+") not found"),i=!1),i&&function(){var e,i=n.origin,t=F[w]&&F[w].checkOrigin;if(t&&""+i!="null"&&!(t.constructor===Array?function(){var e=0,n=!1;for(k(w,"Checking connection is from allowed list of origins: "+t);e<t.length;e++)if(t[e]===i){n=!0;break}return n}():(e=F[w]&&F[w].remoteHost,k(w,"Checking connection is from: "+e),i===e)))throw new Error("Unexpected message received from: "+i+" for "+h.iframe.id+". Message was: "+n.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}()&&function(){switch(F[w]&&F[w].firstRun&&F[w]&&(F[w].firstRun=!1),h.type){case"close":F[w].closeRequeston?R(w,"onCloseRequest",F[w].iframe):E(h.iframe);break;case"message":r=s(6),k(w,"onMessage passed: {iframe: "+h.iframe.id+", message: "+r+"}"),l("onMessage",{iframe:h.iframe,message:JSON.parse(r)}),k(w,"--");break;case"scrollTo":f(!1);break;case"scrollToOffset":f(!0);break;case"pageInfo":d(F[w]&&F[w].iframe,w),function(){function e(n,i){function t(){F[r]?d(F[r].iframe,r):o()}["scroll","resize"].forEach(function(e){k(r,n+e+" listener for sendPageInfo"),i(window,e,t)})}function o(){e("Remove ",x)}var r=w;e("Add ",M),F[r]&&(F[r].stopPageInfo=o)}();break;case"pageInfoStop":F[w]&&F[w].stopPageInfo&&(F[w].stopPageInfo(),delete F[w].stopPageInfo);break;case"inPageLink":e=s(9),i=e.split("#")[1]||"",t=decodeURIComponent(i),(o=document.getElementById(t)||document.getElementsByName(t)[0])?(n=c(o),k(w,"Moving to in page link (#"+i+") at x: "+n.x+" y: "+n.y),v={x:n.x,y:n.y},u(),k(w,"--")):window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(i):k(w,"In page link #"+i+" not found and window.parentIFrame not found"):k(w,"In page link #"+i+" not found");break;case"reset":W(h);break;case"init":a(),l("onInit",h.iframe);break;default:a()}var e,n,i,t,o,r}())):z(w,"Ignored: "+g)}function R(e,n,i){var t=null,o=null;if(F[e]){if("function"!=typeof(t=F[e][n]))throw new TypeError(n+" on iFrame["+e+"] is not a function");o=t(i)}return o}function T(e){var n=e.id;delete F[n]}function E(e){var n=e.id;k(n,"Removing iFrame: "+n);try{e.parentNode&&e.parentNode.removeChild(e)}catch(e){O(e)}R(n,"onClosed",n),k(n,"--"),T(e)}function N(e){null===v&&k(e,"Get page position: "+(v={x:window.pageXOffset!==u?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==u?window.pageYOffset:document.documentElement.scrollTop}).x+","+v.y)}function C(e){null!==v&&(window.scrollTo(v.x,v.y),k(e,"Set page position: "+v.x+","+v.y),S())}function S(){v=null}function W(e){k(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),N(e.id),P(function(){j(e),H("reset","reset",e.iframe,e.id)},e,"reset")}function j(i){function t(e){n||"0"!==i[e]||(n=!0,k(o,"Hidden iFrame detected, creating visibility listener"),function(){function n(){Object.values(F).forEach(function(n){function e(e){return"0px"===(F[n]&&F[n].iframe.style[e])}F[n]&&(i=F[n].iframe,null!==i.offsetParent)&&(e("height")||e("width"))&&H("Visibility change","resize",F[n].iframe,n);var i})}function e(e){k("window","Mutation observed: "+e[0].target+" "+e[0].type),c(n,16)}var i=w();i&&(t=document.querySelector("body"),o={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},new i(e).observe(t,o));var t,o}())}function e(e){var n;n=e,i.id?(i.iframe.style[n]=i[n]+"px",k(i.id,"IFrame ("+o+") "+n+" set to "+i[n]+"px")):k("undefined","messageData id not set"),t(e)}var o=i.iframe.id;F[o]&&(F[o].sizeHeight&&e("height"),F[o].sizeWidth&&e("width"))}function P(e,n,i){i!==n.type&&r?(k(n.id,"Requesting animation frame"),r(e)):e()}function trycatch(i,x,y){try{i.contentWindow.postMessage(x,y)}catch(error){}}function H(e,n,i,t,o){var r,a=!1;t=t||i.id,F[t]&&(i&&"contentWindow"in i&&null!==i.contentWindow?(r=F[t]&&F[t].targetOrigin,k(t,"["+e+"] Sending msg to iframe["+t+"] ("+n+") targetOrigin: "+r),trycatch(i,b+n,r)):O(t,"["+e+"] IFrame("+t+") not found"),o&&F[t]&&F[t].warningTimeout&&(F[t].msgTimeout=setTimeout(function(){!F[t]||F[t].loaded||a||(a=!0,O(t,"IFrame has not responded within "+F[t].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))},F[t].warningTimeout)))}function A(e){return e+":"+F[e].bodyMarginV1+":"+F[e].sizeWidth+":"+F[e].log+":"+F[e].interval+":"+F[e].enablePublicMethods+":"+F[e].autoResize+":"+F[e].bodyMargin+":"+F[e].heightCalculationMethod+":"+F[e].bodyBackground+":"+F[e].bodyPadding+":"+F[e].tolerance+":"+F[e].inPageLinks+":"+F[e].resizeFrom+":"+F[e].widthCalculationMethod}function d(i,e){function n(e){var n=e.split("Callback");if(2===n.length){var i="on"+n[0].charAt(0).toUpperCase()+n[0].slice(1);this[i]=this[e],delete this[e],O(f,"Deprecated: '"+e+"' has been renamed '"+i+"'. The old method will be removed in the next major version.")}}var t,o,r,a,s,d,c,f=(""===(t=i.id)&&(i.id=(o=e&&e.id||h.id+l++,null!==document.getElementById(o)&&(o+=l++),t=o),m=(e||{}).log,k(t,"Added missing iframe ID: "+t+" ("+i.src+")")),t);f in F&&"iFrameResizer"in i?O(f,"Ignored iFrame, already setup."):(d=(d=e)||{},F[f]={firstRun:!0,iframe:i,remoteHost:i.src.split("/").slice(0,3).join("/")},function(e){if("object"!=typeof e)throw new TypeError("Options is not an object")}(d),Object.keys(d).forEach(n,d),function(e){for(var n in h)Object.prototype.hasOwnProperty.call(h,n)&&(F[f][n]=Object.prototype.hasOwnProperty.call(e,n)?e[n]:h[n])}(d),F[f]&&(F[f].targetOrigin=!0===F[f].checkOrigin?""===(c=F[f].remoteHost)||"file://"===c?"*":c:"*"),function(){switch(k(f,"IFrame scrolling "+(F[f]&&F[f].scrolling?"enabled":"disabled")+" for "+f),i.style.overflow=!1===(F[f]&&F[f].scrolling)?"hidden":"auto",F[f]&&F[f].scrolling){case"omit":break;case!0:i.scrolling="yes";break;case!1:i.scrolling="no";break;default:i.scrolling=F[f]?F[f].scrolling:"no"}}(),function(){function e(e){1/0!==F[f][e]&&0!==F[f][e]&&(i.style[e]=F[f][e]+"px",k(f,"Set "+e+" = "+F[f][e]+"px"))}function n(e){if(F[f]["min"+e]>F[f]["max"+e])throw new Error("Value for min"+e+" can not be greater than max"+e)}n("Height"),n("Width"),e("maxHeight"),e("minHeight"),e("maxWidth"),e("minWidth")}(),"number"!=typeof(F[f]&&F[f].bodyMargin)&&"0"!==(F[f]&&F[f].bodyMargin)||(F[f].bodyMarginV1=F[f].bodyMargin,F[f].bodyMargin=F[f].bodyMargin+"px"),r=A(f),(s=w())&&(a=s,i.parentNode&&new a(function(e){e.forEach(function(e){Array.prototype.slice.call(e.removedNodes).forEach(function(e){e===i&&E(i)})})}).observe(i.parentNode,{childList:!0})),M(i,"load",function(){var e,n;H("iFrame.onload",r,i,u,!0),e=F[f]&&F[f].firstRun,n=F[f]&&F[f].heightCalculationMethod in g,!e&&n&&W({iframe:i,height:0,width:0,type:"init"})}),H("init",r,i,u,!0),F[f]&&(F[f].iframe.iFrameResizer={close:E.bind(null,F[f].iframe),removeListeners:T.bind(null,F[f].iframe),resize:H.bind(null,"Window resize","resize",F[f].iframe),moveToAnchor:function(e){H("Move to anchor","moveToAnchor:"+e,F[f].iframe,f)},sendMessage:function(e){H("Send Message","message:"+(e=JSON.stringify(e)),F[f].iframe,f)}}))}function c(e,n){null===i&&(i=setTimeout(function(){i=null,e()},n))}function f(){"hidden"!==document.visibilityState&&(k("document","Trigger event: Visiblity change"),c(function(){q("Tab Visable","resize")},16))}function q(i,t){Object.keys(F).forEach(function(e){var n;F[n=e]&&"parent"===F[n].resizeFrom&&F[n].autoResize&&!F[n].firstRun&&H(i,t,document.getElementById(e),e)})}function L(){M(window,"message",s),M(window,"resize",function(){var e;k("window","Trigger event: "+(e="resize")),c(function(){q("Window "+e,"resize")},16)}),M(document,"visibilitychange",f),M(document,"-webkit-visibilitychange",f)}function B(){function t(e,n){n&&(!function(){if(!n.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==n.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+n.tagName+">")}(),d(n,e),o.push(n))}var o;return function(){var e,n=["moz","webkit","o","ms"];for(e=0;e<n.length&&!r;e+=1)r=window[n[e]+"RequestAnimationFrame"];r||k("setup","RequestAnimationFrame not supported")}(),L(),function(e,n){var i;switch(o=[],(i=e)&&i.enablePublicMethods&&O("enablePublicMethods option has been removed, public methods are now always available in the iFrame"),typeof n){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(n||"iframe"),t.bind(u,e));break;case"object":t(e,n);break;default:throw new TypeError("Unexpected data type ("+typeof n+")")}return o}}}();
//# sourceMappingURL=iframeResizer.map
;
(function(){this.PagesFrame=function(){function t(e,i){this.frameId=e||"et4pages_iframe",this.url=i||t.FRAME_URL,this.width="100%",this.height="900",this.url.indexOf("/peoplecountwidget/")>-1&&(this.height=360),this.rm_cache_bust=1,this.rm_callback=null,this.timer=-1,this.scroll_element=null,this.iframe=null}return t.FRAME_URL="",t.prototype.setScrollElement=function(t){if(t&&""!==t)return this.scroll_element=document.getElementById(t)},t.prototype.setOnChange=function(t){if(window.onresize=window.onscroll=t,this.scroll_element)return this.scroll_element.onscroll=this.scroll_element.onresize=t},t.prototype.renderAt=function(e,i){return"string"==typeof e&&(e=document.getElementById(e)),"script"===e.tagName.toLowerCase()&&0===this.url.lastIndexOf("//",0)&&0===e.src.lastIndexOf("https://",0)&&(this.url="https:"+this.url),this.iframe=document.createElement("iframe"),this.iframe.id="et4pages_iframe",this.iframe.src=this.url,this.iframe.setAttribute("width",this.width),this.iframe.setAttribute("height",this.height),this.iframe.setAttribute("frameborder","0"),this.iframe.setAttribute("scrolling","no"),this.iframe.setAttribute("style","min-height: "+this.height+"px;"),this.iframe.setAttribute("allowfullscreen","allowfullscreen"),this.iframe.setAttribute("allow","geolocation; autoplay"),i&&this.iframe.setAttribute("name",i),this.iframe.onload=function(){return iFrameResize({log:!1,autoResize:!0,contentWindowBodyMargin:0,doHeight:!0,doWidth:!1,enablePublicMethods:!1,interval:33,scrolling:!1,callback:function(){var e;e=function(){var e;if(e=this.windowScrollTop()-this.offset().top+t.getEffectiveHeaderOffset()+"|"+(this.windowScrollTop()-this.offset().top+window.innerHeight),this.postMessage("scroll="+e,"*",this.iframe.contentWindow),Math.max(this.windowScrollTop(),this.bodyScrollTop())+window.innerHeight+t.getEffectiveFooterOffset()>=this.getDocumentHeight())return this.postMessage("addContent","*",this.iframe.contentWindow)},this.delayOnce(e,200)}},"#et4pages_iframe")},"script"===e.tagName.toLowerCase()?e.parentNode.insertBefore(this.iframe,e):e.appendChild(this.iframe)},t.prototype.isFunction=function(t){return t&&"[object Function]"==={}.toString.call(t)},t.prototype.postMessage=function(t,e,i){if(e)return i=i||parent,window.postMessage?i.postMessage(t,e.replace(/([^:]+:\/\/[^\/]+).*/,"$1")):i.location=e.replace(/#.*$/,"")+"#"+ +new Date+this.rm_cache_bust+++"&"+t},t.prototype.receiveMessage=function(t,e,i){var o,n;return window.postMessage?(t&&(this.rm_callback&&this.receiveMessage(),n=this.isFunction,this.rm_callback=function(i){return!("string"==typeof e&&i.origin!==e||n(e)&&!1===e(i.origin))&&t(i)}),window.addEventListener?window[t?"addEventListener":"removeEventListener"]("message",this.rm_callback,!1):window[t?"attachEvent":"detachEvent"]("onmessage",this.rm_callback)):(o&&clearInterval(o),o=null,t?(i="number"==typeof e?e:"number"==typeof i?i:100,setInterval(function(){var e,i,o;if(o=/^#?\d+&/,(e=document.location.hash)!==i&&o.test(e))return i=e,t({data:e.replace(o,"")})},i)):void 0)},t.prototype.offset=function(){var t,e,i,o;if(t={top:0,left:0},e=(o=document.getElementById(this.frameId))&&o.ownerDocument)return i=e.documentElement,"undefined"!=typeof o.getBoundingClientRect&&(t=o.getBoundingClientRect()),{top:t.top+(window.pageYOffset||i.scrollTop)-(i.clientTop||0),left:t.left+(window.pageXOffset||i.scrollLeft)-(i.clientLeft||0)}},t.prototype.windowScrollTop=function(t){return void 0!==t?(t<0&&(t=this.offset().top+t),window.scrollTo(window.pageXOffset||document.documentElement.scrollLeft,t)):window.pageYOffset||document.documentElement.scrollTop},t.prototype.bodyScrollTop=function(t){return void 0!==t?this.scroll_element?this.scroll_element.scrollTop=t:this.windowScrollTop(t):this.scroll_element?this.scroll_element.scrollTop:0},t.prototype.getDocumentHeight=function(){var t;return t=0,this.scroll_element&&(t=this.scroll_element.scrollHeight),Math.max(t,document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},t.prototype.setHeight=function(t){return this.height=t,this.iframe.setAttribute("height",t),this.iframe.style.height=t+"px"},t.prototype.delayOnce=function(t,e){return-1!==this.timer&&clearTimeout(this.timer),this.timer=setTimeout(t,e)},t}()}).call(this);
PagesFrame.FRAME_URL = 'https://pages.et4.de/de/open-data-niedersachsen-tourismus/default/search/Event/keyword:%22NLPH%20Baltrum%22/mode:next_months,12/sort:chronological';
PagesFrame.getEffectiveHeaderOffset = function() { return (window.innerWidth < 768 && 0 != 0) ? 0 : 80; };
PagesFrame.getEffectiveFooterOffset = function() { return (window.innerWidth < 768 && 0 != 0) ? 0 : 460; };

(function(){
  if (PagesFrame.FRAME_URL.indexOf('/streaming/') != -1) {
    if (window.console) console.error("eT4 PAGES: iframe src=*/streaming/* detected: don't do that, the src must refer to /default/ or another non-streaming template");
  }

  if (location.hash.indexOf("/default/") != -1)
  {
    var urlParts = PagesFrame.FRAME_URL.split("/");
    PagesFrame.FRAME_URL = urlParts[0] + "//" + urlParts[2] + location.hash.replace('#', '');
  }
  if (location.hash.indexOf('/streaming/') != -1) {
    if (window.console) console.error("eT4 PAGES: #*/streaming/* detected: don't do that, the relative url in the fragment must use /default/");
  }
})();
(function() {
  var sf = function() {
    if (pagesIframe == null)
      return;
    try {
      var scrollTop = pagesIframe.windowScrollTop() - pagesIframe.offset().top + PagesFrame.getEffectiveHeaderOffset();
      var scrollBottom = pagesIframe.windowScrollTop() - pagesIframe.offset().top + window.innerHeight;
      var scroll = scrollTop + "|" + scrollBottom;
      pagesIframe.postMessage("scroll=" + scroll, "*", document.getElementById("et4pages_iframe").contentWindow);
      if(Math.max(pagesIframe.windowScrollTop(), pagesIframe.bodyScrollTop()) + window.innerHeight + PagesFrame.getEffectiveFooterOffset() >= pagesIframe.getDocumentHeight())
        pagesIframe.postMessage('addContent', "*", document.getElementById("et4pages_iframe").contentWindow)
     } catch(e) {
     }
  }; 
  try {
    var pagesIframe = new PagesFrame("et4pages_iframe");
    pagesIframe.setScrollElement("");
    if (0 > 0) pagesIframe.height = 0;
    if(window.name && window.name.indexOf('|') != -1)
      pagesIframe.renderAt("et4pages", window.name);
    else
      pagesIframe.renderAt("et4pages");
    var hist_timer = -1;
    pagesIframe.setOnChange(function() { pagesIframe.delayOnce(sf, 200); });
    /* now @ et4-pages-iframe.js.coffee
    iFrameResize({
        log: false,
        autoResize: true,
        contentWindowBodyMargin:0,
        doHeight:true,
        doWidth:false,
        enablePublicMethods:false,
        interval:33,
        scrolling:false,
        callback:function(messageData){ pagesIframe.delayOnce(sf, 200); }
      },
      "#et4pages_iframe"
    );
    */
    // tfs#6460 real bad safari hack for history back
    // HMDEV-I7185 iOS 14.x changed something so this hack causes crashes. but they didnt fix the history back bug
    if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1 && navigator.userAgent.indexOf('Android') == -1) {
      window.addEventListener('popstate', function(e) {
        // HMDEV-I7185 alternative workaround
        if (location.hash.indexOf("/default/") != -1) {
          var urlParts = PagesFrame.FRAME_URL.split("/");
          var newUrl = urlParts[0] + "//" + urlParts[2] + location.hash.replace('#', '');
          pagesIframe.iframe.src = newUrl;
        }
        //window.location.href = location.href;
      });
    }
    setInterval(function() {
      pagesIframe.delayOnce(sf, 200);
    }, 3000);
    pagesIframe.receiveMessage(function(e) {
      var matchUpdateScrollInfo = e.data.match("^updateScrollInfo=(.*)");
      var matchScroll = e.data.match("^scroll=(.*)");
      var matchHistory = e.data.match("^history=(.*)");
      // trigger custom event even if i_update_url=false
      if (matchHistory) {
        pagesIframe.iframe.dispatchEvent(new CustomEvent('pages:load', {detail: {url: matchHistory[1]}}));
      }
      if (true && matchHistory && matchHistory.length == 2) {
        var url = matchHistory[1];
        var urlParts = url.split("/");
        var urlOrigin = urlParts[0] + "//" + urlParts[2];
        var origin = window.location.origin
        if (!origin)
          origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
        var mLocationStreaming = window.location.href.match(/\/streaming(_[A-Za-z-0-9]*)?(|_?([A-Za-z-0-9]*))?\//)
        var templateInner = (mLocationStreaming ? mLocationStreaming[3] : null) || 'default'
        if (History.enabled && url.indexOf(origin) == 0 && url.indexOf("/"+templateInner+"/") != -1 && mLocationStreaming) {
          var newUrl = url.replace("/"+templateInner+"/", mLocationStreaming[0])
          if (newUrl != History.getState().url) {
            if (hist_timer != -1)
              clearTimeout(hist_timer);
            hist_timer = setTimeout(function() {
              History.replaceState(null, document.title, newUrl);
            }, 50);
          }
        } else {
          var newHash = url.replace(urlOrigin, "#");
          var trueBaseLocation = location.protocol+'//'+location.hostname+(location.port?":"+location.port:"")+location.pathname+(location.search?location.search:""); //stop using base href -_-
          if(window.location.hash != newHash) {
            if (window.history && window.history.replaceState)
              history.replaceState(null, document.title, trueBaseLocation + newHash);
            else
              window.location.hash = newHash;
          }
        }
      }
      else if (matchUpdateScrollInfo && matchUpdateScrollInfo.length == 2) {
        var params = matchUpdateScrollInfo[1].split("|");
        var scroll = pagesIframe.windowScrollTop();
        var height = parseInt(params[1]);
        var offset = parseInt(params[2]);
        var limit = parseInt(params[3]);
        var baseLimit = parseInt(params[4]);
        var urlHash = parseInt(params[5]);
        window.name = scroll + "|" + height + "|" + offset + "|" + limit + "|" + baseLimit + "|" + urlHash;
      } else if (matchScroll && matchScroll.length == 2) {
        var params = matchScroll[1].split('|')
        if (params[1] === 'original') params[1] = pagesIframe.height;
        pagesIframe.setHeight(params[1]);
        pagesIframe.windowScrollTop(params[0]);
      } else {
        switch(e.data) {
          case "scrollToTop":
            var scrollOffsetToUse = 0;
            if (window.innerWidth < 768 && 0 != 0) scrollOffsetToUse = 0;
            pagesIframe.bodyScrollTop(scrollOffsetToUse);
            break;
          case "refresh":
            pagesIframe.delayOnce(sf, 200);
            break;
          case "register":
            pagesIframe.postMessage("init=" + window.name, "*", document.getElementById("et4pages_iframe").contentWindow);
            break;
        }
      }
    });
  } catch(e) {
  }
})();

