var popupWindow = {

    visible: false,
    element: null,
    blinder: null,
    iframe: null,
    transitionTime: 500,

    initialize: function() {

        this.element = $(".popup-window");
        this.blinder = $(".popup-blind");
        this.iframe = $(".popup-window iframe")[0];

        this.iframe.onload = function() {
            if (this.src && this.src != "about:blank" && this.src != "")
                popupWindow.element.fadeIn(popupWindow.transitionTime);
        };

        $("a").each(function(idx, elm) {

            if (/popup/i.test(elm.rel)) {
                $(elm).click(function(e) {

                    popupWindow.show(elm.href);
                    e.preventDefault();

                });
            }

        });

    },


    show: function(url) {
        this.blinder.fadeTo(this.transitionTime, 0.6, function() { popupWindow.iframe.src = url; });
    },

    hide: function() {
        this.blinder.fadeOut(this.transitionTime);
        this.element.fadeOut(this.transitionTime);
    },
    close: function() { this.hide(); }
};

$(function() {
    popupWindow.initialize();
});
