
var tmlSealBuilder = tmlSealBuilder || {

    jQueryUrl: '//code.jquery.com/jquery-1.11.1.min.js',
    jQueryExists: null,

    run: function(buttonsHtml, popupsHtml, sealStyleUrl, place) {
        this.checkJQuery();

        if (!this.jQueryExists) {
            // Hook with addedJQuery is needed not to load script one more time
            // if loading was already started
            var addedJQuery = this.addedJQuery();

            if (!addedJQuery) {
                // If jQuery script was not added, add initial callbacks to move jQuery from global
                // and build first content
                this.includeJQuery(function() {
                    tmlSealBuilder.moveJQuery();
                    tmlSealBuilder.buildContent(buttonsHtml, popupsHtml, sealStyleUrl, place);
                });
            } else {
                // If jQuery script is added and loading, add other build content callback above previous
                this.addJQueryOnLoad(addedJQuery, buttonsHtml, popupsHtml, sealStyleUrl, place);
            }
        } else {
            tmlSealBuilder.moveJQuery();
            this.buildContent(buttonsHtml, popupsHtml, sealStyleUrl, place);
        }
    },

    getCurrentScript: function() {
        return document.currentScript || (function() {
            var scripts = document.getElementsByTagName('script');
            return scripts[scripts.length - 1];
        })();
    },

    checkJQuery: function() {
        this.jQueryExists = typeof jQuery != 'undefined' || typeof tmlQ != 'undefined';
    },

    includeJQuery: function(callback) {
        var jq = document.createElement('script');
        jq.type = 'text/javascript';
        jq.src = this.jQueryUrl;

        document.getElementsByTagName('head')[0].appendChild(jq);

        jq.onload = callback;
    },

    addedJQuery: function() {
        var scripts = document.getElementsByTagName('script');

        for (var i = 0, n = scripts.length; i < n; i++)  {
            if (scripts[i].getAttribute('src') == this.jQueryUrl)  {
                return scripts[i];
            }
        }

        return false;
    },

    addJQueryOnLoad: function(script, buttonsHtml, popupsHtml, sealStyleUrl, place) {
        var oldCb = script.onload;
        var newCb = function() {
            if (typeof oldCb == 'function') {
                oldCb();
            }
            tmlSealBuilder.buildContent(buttonsHtml, popupsHtml, sealStyleUrl, place);
        };
        script.onload = newCb;
    },

    moveJQuery: function() {
        if (!tmlSealBuilder.jQueryExists) {
            // Moving jQuery to widget property to avoid conflicts
            // if jQuery will be loaded after this script.
            tmlQ = jQuery.noConflict(true);
        } else if (typeof tmlQ == 'undefined') {
            tmlQ = jQuery;
        }
    },

    buildContent: function(buttonsHtml, popupsHtml, sealStyleUrl, place) {
        if (!tmlSealBuilder.styleExists(sealStyleUrl)) {
            tmlSealBuilder.appendStyle(sealStyleUrl);
        }
        tmlSealBuilder.appendButtons(buttonsHtml, place);
        tmlSealBuilder.appendPopups(popupsHtml);
    },

    styleExists: function(sealStyleUrl) {
        return tmlQ('[href*="' + sealStyleUrl + '"]').length > 0;
    },

    appendStyle: function(sealStyleUrl) {
        var link = document.createElement('link');
        link.type = 'text/css';
        link.rel = 'stylesheet';
        link.media = 'all';
        link.href = sealStyleUrl;

        document.getElementsByTagName('head')[0].appendChild(link);
    },

    appendButtons: function(buttonsHtml, place) {
        tmlQ(place).before(buttonsHtml);
    },

    appendPopups: function(popupsHtml) {
        var popups = tmlQ(popupsHtml);

        // Unset popups that already exists in DOM
        popups.each(function(key,popup) {
            var popupId = tmlQ(popup).attr('id');
            if (popupId) {
                if (tmlQ('#' + popupId).length > 0) {
                    popups.splice(key, 1);
                }
            }
        });

        tmlQ('body').append(popups);
    }

};

tmlSealBuilder.run(
    '\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22trust\x2Dmogul\x2Dseal\x20site\x2Dverified\x2Dseal\x22\x3E\x0A\x20\x20\x20\x20\x3Ca\x20href\x3D\x22\x23modal\x2Dtm\x2Dsite\x2Dverified\x2Dseal\x22\x20id\x3D\x22open\x2Dmodal\x2Dsite\x2Dverified\x2Dseal\x22\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x3Cimg\x20src\x3D\x22http\x3A\x2F\x2Fsportsfactory.com.au\x2Fwp\x2Dcontent\x2Fplugins\x2Ftrust\x2Dmogul\x2Fassets\x2Fimg\x2Ftrust\x2Dmogul\x2Dbadge\x2Dsite\x2Dverified\x2Dbig.png\x22\x20alt\x3D\x22Site\x20Verified\x20Seal\x22\x20width\x3D\x22120\x22\x2F\x3E\x0A\x20\x20\x20\x20\x3C\x2Fa\x3E\x0A\x3C\x2Fdiv\x3E\x0A',
    '\x20\x20\x20\x20\x3Csection\x20class\x3D\x22site\x2Dverified\x2Dseal\x20trust\x2Dmogul\x2Dseal\x20tm\x2D\x2Dmodal\x20modal\x2D\x2Dshow\x22\x0A\x20\x20\x20\x20\x20id\x3D\x22modal\x2Dtm\x2Dsite\x2Dverified\x2Dseal\x22\x20tabindex\x3D\x22\x2D1\x22\x20role\x3D\x22dialog\x22\x20aria\x2Dlabelledby\x3D\x22modal\x2Dlabel\x22\x20aria\x2Dhidden\x3D\x22true\x22\x3E\x0A\x0A\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22modal\x2Dinner\x20seal\x2Dmodal\x2Dinner\x22\x20style\x3D\x22background\x2Dimage\x3A\x20url\x28http\x3A\x2F\x2Fsportsfactory.com.au\x2Fwp\x2Dcontent\x2Fplugins\x2Ftrust\x2Dmogul\x2Fassets\x2Fimg\x2Ftrust\x2Dmogul\x2Dpopup\x2Dsite\x2Dverified.png\x29\x3B\x22\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22modal\x2Dcontent\x20seal\x2Dmodal\x2Dcontent\x22\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22modal\x2Dscrollable\x22\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22seal\x2Dcontainer\x2Dfluid\x22\x3E\x0A\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cp\x3E\x3Cstrong\x3ETrust\x20Mogul\x20Site\x20Verified\x20requirements\x3C\x2Fstrong\x3E\x3C\x2Fp\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cp\x3Eon\x3A\x2002\x2F26\x2F2018\x3C\x2Fp\x3E\x0A\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22domain\x22\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22seal\x2Dcol\x2Dsm\x2D6\x22\x3EDomain\x3A\x3C\x2Fdiv\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22seal\x2Dcol\x2Dsm\x2D6\x22\x3E\x3Cp\x20class\x3D\x22value\x22\x3Esportsfactory.com.au\x3C\x2Fp\x3E\x3C\x2Fdiv\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3C\x2Fdiv\x3E\x0A\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22domain_status\x22\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22seal\x2Dcol\x2Dsm\x2D6\x22\x3EDomain\x20Status\x3A\x3C\x2Fdiv\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22seal\x2Dcol\x2Dsm\x2D6\x22\x3E\x3Cp\x20class\x3D\x22value\x22\x3ERegistered\x20and\x20Active\x20website\x3C\x2Fp\x3E\x3C\x2Fdiv\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3C\x2Fdiv\x3E\x0A\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22name_servers\x22\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22seal\x2Dcol\x2Dsm\x2D6\x22\x3ENameServer\x28s\x29\x3A\x3C\x2Fdiv\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22seal\x2Dcol\x2Dsm\x2D6\x22\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cp\x20class\x3D\x22value\x22\x3E192.185.224.42\x3C\x2Fp\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cp\x20class\x3D\x22value\x22\x3E192.185.224.43\x3C\x2Fp\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3C\x2Fdiv\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3C\x2Fdiv\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3C\x2Fdiv\x3E\x0A\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cdiv\x20class\x3D\x22seal\x2Dcontainer\x2Dfluid\x22\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3Cp\x20class\x3D\x22seal\x2Ddisclaimer\x22\x3EDisclaimer\x3A\x20Trust\x20Mogul\x20carefully\x20verifies\x20all\x20the\x20information\x20displayed\x20on\x20this\x20certificate.\x20However,\x20we\x20cannot\x20be\x20held\x20responsible\x20if\x20a\x20verified\x20company\x20changes\x20its\x20information\x20without\x20informing\x20us.\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3C\x2Fp\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3C\x2Fdiv\x3E\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3C\x2Fdiv\x3E\x0A\x0A\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3C\x2Fdiv\x3E\x0A\x20\x20\x20\x20\x3C\x2Fdiv\x3E\x0A\x0A\x20\x20\x20\x20\x3Ca\x20href\x3D\x22\x23\x21\x22\x20class\x3D\x22modal\x2Dclose\x22\x20title\x3D\x22Close\x20this\x20modal\x22\x20data\x2Dclose\x3D\x22Close\x22\x20data\x2Ddismiss\x3D\x22modal\x22\x3E\x3F\x3C\x2Fa\x3E\x0A\x3C\x2Fsection\x3E\x0A',
    'http://sportsfactory.com.au/wp-content/plugins/trust-mogul/assets/css/seals.css',
    tmlSealBuilder.getCurrentScript()
);
