var uz_pc_til = {
    g_skiponready: false,
    ready: function (action) {
        if (uz_pc_til.g_skiponready) {
            switch (uz_pc_til.g_skiponready) {
                case 2:
                    window._loadSuper = window.onload;
                    window.onload = function (a, b, c, d, e) {
                        if (typeof window._loadSuper == 'function') {
                            try { window._loadSuper(a, b, c, d, e); }
                            catch (e) { }
                        }
                        if (action) { action(); }
                    }
                    break;
                default:
                    if (action) { action(); }
                    break;
            }
        }
        else {
            (function (i) {
                var u = navigator.userAgent;
                var e = /*@cc_on!@*/false;
                var st = setTimeout;
                if (/webkit/i.test(u)) {
                    st(function () {
                        var dr = document.readyState;
                        if (dr == "loaded" || dr == "complete") { i() } else { st(arguments.callee, 10); }
                    }, 10);
                }
                else if ((/mozilla/i.test(u) && !/(compati)/.test(u)) || (/opera/i.test(u))) {
                    if (document.readyState == "complete" || document.readyState == "interactive") { i(); } else { document.addEventListener("DOMContentLoaded", i, false); }
                } else if (e) {
                    (
		    function () {
		        var t = document.createElement('doc:rdy'); try {
		            t.doScroll('left');
		            i(); t = null;
		        } catch (e) { st(arguments.callee, 0); }
		    })();
                } else {
                    window._loadSuper = window.onload;
                    window.onload = function (a, b, c, d, e) {
                        if (typeof window._loadSuper == 'function') {
                            try { window._loadSuper(a, b, c, d, e); }
                            catch (e) { }
                        }
                        if (i) { i(); }
                    }

                }
            })(action);
        }
    },
    init: function () {        
        if (typeof (uz_til) == 'undefined') {
            if (navigator.userAgent.indexOf("UZLIB") > -1){
			    Android.timeOut("uz_pc_til.init();", 200);  //in android javascript setTimeout is not working as it should 
			}
			else
				setTimeout(function() { uz_pc_til.init(); }, 200);
        } else {
            if (typeof(g_m_androidForcePreview) != 'undefined') 
				uz_til.g_m_androidForcePreview= true;
            
             uz_til.g_skiponready = true;  uz_til.start({ ID: '2BED13501D0AE411BEDA0022196C4538', SID: '2AED13501D0AE411BEDA0022196C4538' });              
        }


    },
    start: function () {

        uz_pc_til.ready(function () {
            var parentElement = uz_pc_til.getParent();
            if (parentElement != null) {
                var script = document.createElement('script');
                script.type = 'text/javascript';
                script.charset = "utf-8";
                // si es preview forcem a carregar el .active.js
                //script.onload = function () { uz_pc_til.init(); };
                script.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn4.userzoom.com/trueintent/js/uz_til.js?cuid=2BA733EB49F6DF1188490022196C4538'; 
                parentElement.appendChild(script);
                uz_pc_til.init();
            }
            else
                setTimeout(function () { uz_pc_til.start(); }, 200);
        });
    },
    getHead: function () {
        var head = document.getElementsByTagName('head');
        if (head.length > 0)
            return head[0];
        else
            return null;
    },
    getParent: function () {
        if (document.body != null)
            return document.body;
        else if (uz_pc_til.getHead() != null) {
            return uz_pc_til.getHead();
        }
        else return null;
    }
}

uz_pc_til.start();
