var mfw = (function($) {

    var _attachPopupHandlers = function() {
        $('.popup').each(function(i, e) {
            var $e = $(e);
            var dims = /popup_(\d+)_(\d+)/.exec($e.attr('class'));
            var w = parseInt(dims[1], 10), h = parseInt(dims[2], 10);

            $e.click(function(ev) {
                _openPopup(ev, $e.attr('href'), w, h);
            });

        });
    }


    var _openPopup = function(e, href, w, h) {
        e.preventDefault();
        window.open('popup/' + href, 'image', 'width=' + (w + 40) + ',height=' + (h + 200));
    }

    var _p = {
        init: function() {
            _attachPopupHandlers();
        }
    }

    return _p;

})($);

$(document).ready(mfw.init);
