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

{"posDfp1x1":false,"publisherId":"5f969ed529b9c109507d2ad1","position":"aniplayer_AV5fad5f31d19ce73e47155e71","channelId":"5fad5c61e4bce34abb1d37ab","pauseButton":true,"maxWidth":640,"closeButtonStyle":{"position":"Default"},"maxRun":9999,"autoPlay":true,"customLogo":{},"height":0,"vastRetry":4,"logo":true,"templateType":"1","floating":{"size":0.5,"resize":true,"position":"Bottom-Right","floatOnBottom":true},"openAnim":true,"scriptId":"AV5fad5f31d19ce73e47155e71","errorLimit":10,"midrolltime":2,"passbackUrl":{"passbackUrlEnabled":true,"nofloat":true,"color":"White","height":250,"url":"https:\/\/play.aniview.com\/59c9148628a0612da3689288\/5fc8a2e7b37ade32e632ed84\/olympicpassback.html","type":"html","width":300},"loop":true,"maxImp":9999,"width":100,"soundButton":true}

    /*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) {
            
        },
        getAttr: function() {
            if (a.scriptId) { 
                var s = document.getElementById(a.scriptId); 
                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);
