function ToggleFocusBoolean(focus) {
    if (EF.Teachers.LiveBall.Private._init == undefined) return;
	EF.Teachers.LiveBall.Private._temp(focus);
	if(EF.Teachers.LiveBall.Private._temp.Loaded){
	  $.fn.colorbox.close();
	}
}
var EF = {
    /* Short hand to return object in global */
    $_script: function() {
        return this.Global.ScriptHandler
    },
    $_util: function() {
        return this.Global.Utilities
    },
    /* -- Global */
    Global: {
        Utilities: {
            CookieManager: {
                /* Create cookie */
                Bake: function(name, value, days) {
                    var date = new Date();
                    days = days || 1
                    document.cookie = name + "=" + value + "; Max-Age=" + (60 * 60 * 24 * days) + "; path=/";
                },
                /* Create session cookie */
                Session: function(name, value) {
                    document.cookie = name + "=" + value + "; path=/";
                },
                Consume: function(name, key) {
                    var arr = this._Check(name);
                    var condition = undefined;
                    if (arr) {
                        arr = unescape(arr).split("&");
                        for (var i = 0; i < arr.length; i++) {
                            var t = arr[i].split("|");
                            for (var g = 0; g < t.length; g++) {
                                t[g] = t[g].split("=");
                            }
                            for (var counter = 0; counter < t.length; counter++) {
                                if (unescape(t[counter][0]) == key) {
                                    condition = t[counter][1];
                                    break;
                                }
                            }
                        }
                        return condition;
                    } else {
                        return condition;
                    }
                },
                /* Checks for key or key/value pair in cookie - hacked together for leadform*/
                Check: function(name, key, value) {
                    var arr = this._Check(name);
                    var condition = false;
                    if (arr) {
                        arr = unescape(arr).split("&");
                        for (var i = 0; i < arr.length; i++) {
                            var t = arr[i].split("|");
                            for (var g = 0; g < t.length; g++) {
                                t[g] = t[g].split("=");
                            }
                            for (var counter = 0; counter < t.length; counter++) {
                                if (arguments.length == 2) {
                                    if (unescape(t[counter][0]) == key) {
                                        condition = true;
                                        break;
                                    }
                                } else {
                                    if (unescape(t[counter][0]) == key & unescape(t[counter][1]) == value) {
                                        condition = true;
                                        break;
                                    }
                                }
                            }
                        }
                        return condition;
                    } else {
                        return condition;
                    }
                },
                /* Helper - returns value of specified cookie */
                _Check: function(name) {
                    var s = document.cookie.split(';');
                    for (var i = 0, l = s.length; i < l; i++) {
                        var c = s[i].toString(), f, r;
                        f = c.substring(0, c.indexOf("="))
                        r = c.substring(c.indexOf("=") + 1, c.length)
                        while (f.charAt(0) == " ") f = f.substring(1, f.length)
                        if (f == name) return r;
                    }
                }
            },
            GetDimensions: function(Width_Height_or_Both) {
                Width_Height_or_Both = Width_Height_or_Both.toLowerCase()
                switch (Width_Height_or_Both) {
                    case "width":
                        return { "width": width() }
                        break;
                    case "height":
                        return { "height": height() }
                        break;
                    case "both":
                        return { "width": width(), "height": height() }
                        break;
                    // If nothing, just return both...   
                    default:
                        return { "width": width(), "height": height() }
                        break;
                        window.location
                }
                function height() {
                    return Math.max(
            Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
            Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
            Math.max(document.body.clientHeight, document.documentElement.clientHeight)
          );
                }
                function width() {
                    return Math.max(
            Math.max(document.body.scrollWidth, document.documentElement.scrollWidth),
            Math.max(document.body.offsetWidth, document.documentElement.offsetWidth),
            Math.max(document.body.clientWidth, document.documentElement.clientWidth)
          );
                }
            }
        }
    },
    /* -- Teachers */
    Teachers: {
        /* Start - Liveball Marketing */
        LiveBall: {
            Private: function() {
                var playing = new Boolean();
                return function setter(condition) {
                    if (arguments.length == 0) return playing;
                    playing = condition;
                    if (playing == true) {
                        EF.Teachers.LiveBall.killTimer(EF.Teachers.LiveBall.Private._timer);
                        return playing;
                    } else if (playing == false) {
                        EF.Teachers.LiveBall.setTimer();
                        return playing;
                    }
                }
            },
            showModal: function() {
                /* Load ColorBox for pop-in -- Will eventually replace nryo and ThickBox */
                $.fn.colorbox({
                    href: EF.Teachers.LiveBall.Private._liveball,
                    iframe: true,
                    overlayClose: false,
                    innerWidth: EF.Teachers.LiveBall.Private._width,
                    innerHeight: EF.Teachers.LiveBall.Private._height,
                    opacity: 0.3,
                    onLoad: function() {
                        EF.Teachers.LiveBall.Private._temp.Loaded = true;
                        $("select").css("display", "none");
                        $("html").css("overflow-x", "hidden");
                        var dimensions = EF.$_util().GetDimensions('both');
                        $("#cboxOverlay").css({
                            "height": dimensions['height'],
                            "width": dimensions['width']
                        })
                    },
                    onCleanup: function() {
                        $("#cboxClose").css("display", "none")
                        $("select").css("display", "inline");
                        $("html").css("overflow-x", "auto");
                    },
                    onClosed: function() {
                        /* Create EFLD cookie */
                        EF.Global.Utilities.CookieManager.Session("EFLD", escape("Viewed=True"));

                        /* Increment counter */
                        var _count = parseInt(EF.Global.Utilities.CookieManager.Consume("EFFEDCK", "Count")) + 1;
                        EF.Global.Utilities.CookieManager.Bake("EFFEDCK", "Count=" + _count, "180");
                    }
                })
            },
            setTimer: function() {
                EF.Teachers.LiveBall.Private._timer = setTimeout('EF.Teachers.LiveBall.showModal()', EF.Teachers.LiveBall.Private._timeout);
            },
            killTimer: function(timer) {
                try {
                    clearTimeout(timer)
                } catch (err) { }
            },
            Init: function(url, timeout, width, height, iframe) {
                /* Create counter cookie, if nec. */
                if (!EF.Global.Utilities.CookieManager.Check("EFFEDCK", "Count")) {
                    EF.Global.Utilities.CookieManager.Bake("EFFEDCK", "Count=0", "180");
                }


                if (EF.Global.Utilities.CookieManager.Check("EFPBMKT", "IsLeadDisabled", "True") || EF.Global.Utilities.CookieManager.Check("EFLD", "Viewed", "True") || EF.Global.Utilities.CookieManager.Check("EFFEDCK", "Count", "3")) return /*silently*/;

                EF.Teachers.LiveBall.Private._liveball = url;
                EF.Teachers.LiveBall.Private._timeout = timeout || 22000;
                EF.Teachers.LiveBall.Private._width = width || 400;
                EF.Teachers.LiveBall.Private._height = height || 660;
                EF.Teachers.LiveBall.Private._init = url || undefined;
                this.setTimer()
            },
            FlashInit: function() {
                return EF.Teachers.LiveBall.Private._temp = new this.Private()
            }
        }
    }
}

/* Initialize Set/Kill Timer */
EF.Teachers.LiveBall.FlashInit();
EF.Teachers.LiveBall.Private._temp.Loaded = false;