$(document).ready(function() {
    /*********************************************************************
    *iframe video pop in
    **********************************************************************/
    //function iframeVideoPopInObj() {
    iframeVideoPopInObj = function() {
        var _this = this;
        this.closed = true;
        this.getH = function() { if (typeof (window.innerHeight) == 'number') { return window.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { return document.documentElement.clientHeight; } else if (document.body && document.body.clientHeight) { return document.body.clientHeight; } return 0; };
        this.getW = function() { if (typeof (window.innerWidth) == 'number') { return window.innerWidth; } else if (document.documentElement && document.documentElement.clientWidth) { return document.documentElement.clientWidth; } else if (document.body && document.body.clientWidth) { return document.body.clientWidth; } return 0; };
        this.getT = function() { return ((_this.getH() - 526) / 2) + $("body").scrollTop(); };
        this.getL = function() { return ((_this.getW() - 740) / 2); };
        this.adjust = function() {
            if (!$.support.cssFloat)
                $("#iframeVideoPopInBox").css({ top: _this.getT(), left: _this.getL() });
            else
                $("#iframeVideoPopInBox").animate({ top: _this.getT(), left: _this.getL() }, 100);
        };
        this.open = function(url, vidWidth, vidHeight, campaign) {
            if (_this.closed) {
                _this.closed = false;
                $("#iframeVideoPopInBox").show();
                var cmpid = (typeof campaign != "undefined") ? "?cmpid=" + campaign : "";
                $("body").bind("resize", iframeVideoPopIn.adjust);
                $("div#iframeVideoPopInBox").show();
                /*$("body").append('<div id="iframeVideoPopInBox">'
                + '<div style="text-align:right;padding:3px;"><a class="closeVideoPopIn" style="color:#FC6E2A; margin-right: 10px;" href="#">Close</a></div>'*/
                //$("#iframeVideoPopInBox").append('<iframe src="" width="" height="" frameborder="0" scrolling="no"></iframe>');
                $("#iframeVideoPopInBox").append('<iframe src= "' + url + cmpid + '" width="' + (vidWidth + 20) + '" height="' + (vidHeight + 20) + '" frameborder="0" scrolling="no"></iframe>');
                $("#iframeVideoPopInBox").css({ position: "absolute", top: "0", left: "0", opacity: "0", filter: "alpha(opacity=0)" });
                $("#iframeVideoPopInBox").css({ border: "2px solid #ffffff", top: _this.getT() + "px", left: _this.getL() + "px", width: (vidWidth + 20) + "px", height: (vidHeight + 40) + "px", zIndex: "200", textAlign: "center", backgroundColor: "white", fontFamily: "arial", fontSize: "12px", color: "black" });
                $("#iframeVideoPopInBox").fadeTo(500, 1);
            }
        };
        this.close = function() {
            $("#iframeVideoPopInBox").fadeTo(500, 0, function() {
                _this.closed = true;
                //$("#iframeVideoPopInBox").remove();
                $("#iframeVideoPopInBox iframe").remove();
                $("#iframeVideoPopInBox").hide();
                $(window).unbind("resize", iframeVideoPopIn.adjust);
            });
        };
    }
    var iframeVideoPopIn = new iframeVideoPopInObj();
    $('a.closeVideoPopIn').click(function() {
        iframeVideoPopIn.close();
        return false;
    });

    /* eStar Intro Video controls */
    $('a.estarIntroVideo').click(function() {
        iframeVideoPopIn.open('/SyndicatedPlayer/vidplayer.html#1', 655, 375);
        return false;
    });
    var estarIntro = $.query.get('estarIntro');
    if (estarIntro == 'true') {
        iframeVideoPopIn.open('/SyndicatedPlayer/vidplayer.html#1', 655, 375);
    }
});
