
(function (w) {
    /*tagconfig*/
    var a = 

{"pauseButton":true,"maxRun":3,"vastRetry":3,"height":300,"width":500,"closeButtonStyle":{"outside":true,"position":"Top-Left"},"autoContinue":true,"midrolltime":5,"maxImp":4,"channelId":"5f6c58c24ff50719c54dbb10","maxWidth":500,"customLogo":{"link":"https:\/\/streamlyn.com\/images\/favicon.png","height":20,"clickthrough":"https:\/\/streamlyn.com\/","width":20,"text":"Powered by Streamlyn"},"posDfp1x1":false,"startOnView":true,"soundButton":true,"showPlayer":true,"logo":true,"hideLogoOnAd":true,"position":"aniplayer_AV5f6c77287b21cd499118843d","closeButton":true,"templateType":"1","scriptId":"AV5f6c77287b21cd499118843d","preloader":{"random":true,"clickthrough":["","","","",""],"autoplay":true,"link":["https:\/\/nvqza80169tvong.belugacdn.link\/collectives\/health\/video\/en\/en-healthy-snacks-you-can-munch-on-while-working.mp4","https:\/\/nvqza80169tvong.belugacdn.link\/collectives\/health\/video\/en\/en-parts-of-food-you-never-thought-are-edible.mp4","https:\/\/nvqza80169tvong.belugacdn.link\/collectives\/career\/video\/en\/en-not-satisfied-at-work-what-to-do-next.mp4","https:\/\/nvqza80169tvong.belugacdn.link\/collectives\/lifestyle\/video\/en\/en-are-jeans-too-tight-or-too-loose-for-you.mp4","https:\/\/nvqza80169tvong.belugacdn.link\/collectives\/lifestyle\/video\/en\/en-saw-these-dreams-recently-do-you-know-what-it-means.mp4"],"nativeVideo":true,"type":"content"},"loop":false,"minHeight":300,"reqOnView":true,"timelineMode":"bottom","publisherId":"5eb7be27791eec2a0f7f2d49","autoPlay":true,"startmidroll":28,"errorLimit":3,"inViewRatio":0.5}

    /*tagconfig*/
    var st = {
        unique: function() {
            if (!this.win.aniplayerPos)
                this.win.aniplayerPos = {};
            this.win.aniplayerPos[a.position] = true;
            return true;
        },
        findWin: function() {
           try {
                if ((!a.posDfp1x1 && !a.posClass && !a.posSelector && !a.posId && !a.posTag) || (w === top) || !w.frameElement) {
                    this.doc = document;
                    this.win = w;
                } else if (a.posDfp1x1 && w.frameElement) {
                    this.win = parent;
                    this.doc = parent.document;
                } else {
                    this.win = top;
                    this.doc = top.document;
                }
            } catch (f) {
                this.doc = document;
                this.win = w;
            }
        },
        postCreate: function() {
            
        },
        retry: function() {
           if (this.retryCnt++ > a.timeout)
                return;
            var that = this;
            setTimeout(function() {
                that.position();
            }, 250);
        },
        create: function(p, n) {
            var d1 = document.createElement("div");
            d1.style.width = "100%";
            d1.style.margin = "0 auto";
            d1.style.maxWidth = "" + a.maxWidth + "px";
            var d2 = document.createElement("div");
            d2.id = "aniBox";
            d2.style.height = "1px";
            var d3 = document.createElement("div");
            d3.id = "" + a.position;
            if (p === this.doc || p === this.doc.head)
                p = this.doc.body;
            if (n) {
                p.insertBefore(d1, n);
            } else {
                p.appendChild(d1);
            }
            a.refDiv = p;
            d1.appendChild(d2);
            d2.appendChild(d3);
            this.postCreate(d1);
        },
        position: function() {
            var p = this.doc;
            var isScp = false;
            if (a.posSelector) {
                p = this.doc.querySelector(a.posSelector);
                if (!p) {
                    this.retry();
                    return;
                }
            }
            if (a.posId) {
                p = this.doc.getElementById(a.posId);
                if (!p) {
                    this.retry();
                    return;
                }
            }
            if (a.posTag) {
                var c = a.posTag.split("#");
                if (c && c.length == 2) {
                    var e = p.getElementsByTagName(c[0]);
                    if (e.length == 0) {
                        this.retry();
                        return;
                    }
                    p = e[Math.min(c[1] - 1, e.length - 1)];
                }
            }
            if (a.posClass) {
                var c = a.posClass.split("#");
                var e = 1;
                if (c.length == 2) {
                    e = c[1];
                }
                var f = p.getElementsByClassName(c[0]);
                if (f.length > 0) {
                    p = f[Math.min(e - 1, f.length - 1)];
                }
                if (!p) {
                    this.retry();
                    return;
                }
            }
            if (a.posDfp1x1 && window.frameElement) {
                n = window.frameElement.parentNode.parentNode;
                p = n.parentNode;
                if (document.body.clientHeight > 5 && !a.nohideIframe) {
                    frameElement.style.height = "0px";
                }
                if (a.posType == "after") {
                    n = n.nextElementSibling;
                }
            }
            var n;
            if (p === this.doc) {
                n = this.doc.getElementById(a.scriptId);
                if (n) {
                    n.id += "-used";
                    p = n.parentNode;
                }
            }
            if (p === this.doc.head) {
                n = null;
                p = this.doc;
            }
            if (a.posType && a.posType !== "in" && !n) {
                if (a.posType === "after" && p.nextElementSibling) {
                    p = p.nextElementSibling;
                }
                n = p;
                p = n.parentNode;
            }
            if (p) {
                if (!p.av_setpos) {
                    p.av_setpos = {};
                }
                if (!p.av_setpos[a.position]) {
                    p.av_setpos[a.position] = true;
                    a.position += "-" + Date.now();
                    this.create(p, n);
                    this.load();
                }
            }
        },
        load: function() {
            var that = this;
            var scp = this.doc.createElement("script");
            scp.src = (a.baseJsUrl || "https://player.aniview.com/script/6.1/") + "player.js";
            scp.onload = function() {
                that.start();
            };
            scp.async = true;
            this.doc.body.appendChild(scp)
        },
        postStart: function(p) {
            		var p = arguments[0];
		if (p) {
			p.on("ContentComplete", function () {
				p.close();
			});
		}

        },
        getAttr: function() {
            if (a.scriptId) {
                var s = document.getElementById(a.scriptId) || document.getElementById(a.scriptId + "-used");
                if (s) {
                    for (var i = 0, t = s.attributes; i < s.attributes.length; i++) {
                        if (t[i].nodeName && t[i].nodeName.indexOf("data-") == 0) {
                            var n = t[i].nodeName.replace("data-", "");
                            a[n] = t[i].nodeValue;
                        }
                    }
                    if (s.src) {
                        var p = s.src.indexOf("?");
                        if (p > 10) {
                            var r = (s.src.substring(p + 1, s.src.length));
                            a.ref1 = (a.ref1 || "") + "&" + (r || "");
                        }
                    }
                }
            }
        },
        start: function() {
            var b;
            this.getAttr();
            try {
                if (this.win.avPlayer) {
                    b = new this.win.avPlayer(a);
                } else if (window.avPlayer) {
                    b = new avPlayer(a);
                } else {
                    b = top.avPlayer(a);
                }
            } catch (exp) {
                b = new avPlayer(a);
            }
            this.p = b;
            if (this.pbjs)
                this.pbjs.preparePlayer(b, st);
            if (a.templateType != 0)
                b.startTemplate(this.doc.getElementById(a.position).parentNode);
            b.play(a);
            this.postStart(b);
        },
        preRun: function() {
            
        },
        run: function() {
            this.a = a;
            this.preRun();
            this.findWin();
            if (!this.doc.body) {
                this.doc.addEventListener("DOMContentLoaded", function() {
                    st.run();
                });
                if (this.bodyRetry > 0) {
                    setTimeout(function(){
                        st.run()
                    }, 250);
                    this.domRetry--;
                }
                return;
            }
            if (this.unique() && !this.loaded) {
                this.loaded = true;
                (new Image).src = "https://" + (a.trackDomain || "track1.aniview.com") + "/track?pid=" + a.publisherId + "&cid=" + a.channelId + "&e=playerLoaded&cb=" + Date.now();
                this.retryCnt = 0;
                this.timeout = a.posTimeout || 40;
                this.pbjs = window.aniviewRenderer && window.aniviewRenderer.units && window.aniviewRenderer.units[a.scriptId];
                if (this.pbjs)
                    this.pbjs.prepareConfig(a, st);
                this.position();
            }
        },
        domRetry: 20
    };
    st.run();
})(window);
