function popOver(url, w, h)
{
    var spec = (h && w) ? "toolbar=0,menubar=0,status=1,location=0,scrollbars=1" : "toolbar=1,menubar=1,status=1,location=1,scrollbars=1,resizable=1,";
    if (!h) h = (window.screen) ? window.screen.height : window.outerHeight;
    if (!w) w = (window.screen) ? window.screen.width  : window.outerWidth;
    var x =  (window.screenX) ? window.screenX : (window.screenLeft) ? window.screenLeft : 100;
    var y =  (window.screenY) ? window.screenY : (window.screenTop)  ? window.screenTop  : 100;
    spec += "top=" + y + ",left=" + x + ",width=" + w + ",height=" + h;
    var ie7 = (window.clientInformation && window.clientInformation.appVersion.indexOf("IE 7") > 0);
    var popName = "popOver_" + String((new Date()).valueOf());
    var pop = (true || !ie7) ? window.open(url, popName, spec, true) : window.open(url);
    return pop;
}

function popUnder(url, w, h)
{
    if (!h) h = (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight - 10 : (document.body.clientHeight) ? document.body.clientHeight - 10 : 700;
    if (!w) w = (document.documentElement && document.documentElement.clientWidth)  ? document.documentElement.clientWidth  - 10 : (document.body.clientWidth)  ? document.body.clientWidth  - 10 : 950;
    var x =  (window.screenX) ? window.screenX : (window.screenLeft) ? window.screenLeft : 100;
    var y =  (window.screenY) ? window.screenY : (window.screenTop)  ? window.screenTop  : 100;
    var spec = "toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,";
    spec += "top=" + y + ",left=" + x + ",width=" + w + ",height=" + h;
    ClickPop.Private.PreInit(null, url, spec);
    ClickPop.Private.CreatePop(null);
}

var ClickPop = {
    Private: {
        JsHost: null,
        PopUrl: "",
        Spec: "",
        PreInit: function (target, url, spec) {
            this._Top = self;
            if (top != self) {
                try {
                    if (top.document.location.toString()) {
                        this._Top = top;
                    }
                } catch (err) { }
            }

            ClickPop.Private.PopUrl = url;
            ClickPop.Private.Spec = spec;
            ClickPop.Private.AddEvent(target, "click", function (e) {
                ClickPop.Private.CreatePop(e);
            });
        },
        CreatePop: function (e) {

            var popURL = "about:blank";
            var popID = "ad_" + Math.floor(89999999 * Math.random() + 10000000);
            this.PopWin = this._Top.window.open(popURL, popID, ClickPop.Private.Spec);
            if (this.PopWin) {
                this.PopWin.blur();
                if (navigator.userAgent.toLowerCase().indexOf("applewebkit") > -1) {
                    this._Top.window.blur();
                    this._Top.window.focus();
                }

                this.PopWin.Init = function (e) {
                    with (e) {
                        this.Params = e.Params;
                        this.Main = function () {
                            var popURL = this.Params.PopURL;
                            window.location = popURL;
                            if (typeof window.mozPaintCount != "undefined") {
                                var x = this.window.open("about:blank");
                                x.close();
                            }
                            try {
                                opener.window.focus();
                            } catch (err) { }
                        };
                        this.Main();
                    }
                };
                this.PopWin.Params = {
                    PopURL: ClickPop.Private.PopUrl
                };
                this.PopWin.Init(this.PopWin);
            }
            return true;
        },
        AddEvent: function (target, eventName, handlerName) {
            if (!target)
                return;

            if (target.addEventListener) {
                target.addEventListener(eventName, eval(handlerName), false);
            } else if (target.attachEvent) {
                target.attachEvent("on" + eventName, eval(handlerName));
            } else {
                var originalHandler = target["on" + eventName];
                if (originalHandler) {
                    target["on" + eventName] = eval(handlerName);
                } else {
                    target["on" + eventName] = eval(handlerName);
                }
            }
        }

    }
};
