
$(document).ready(function()
{
    var handler = function(event)
    {
        var features = "status=0,toolbar=0,location=0,menubar=0,directories=0";
        var url = this.href;
        var width;
        var height;

        var classList = this.className.split(' ');
        for (var i = 0; i < classList.length; i++)
        {
            if (classList[i].indexOf("new-window-size-") == 0)
            {
                var data = classList[i].substring(16);
                if (data)
                {
                    var pieces = data.split('-');
                    if (pieces.length == 2)
                    {
                        width = parseInt(pieces[0]);
                        height = parseInt(pieces[1]);
                    }
                }
            }
        }

        if (width && height)
        {
            features += ",resizable=0,scrollbars=0,width=" + width + ",height=" + height;
            window.open(url, "newWindow", features);
        }
        else
        {
            window.open(url, "newWindow");
        }

        event.preventDefault();
    };

    $("area.new-window").click(handler);
    $("a.new-window").click(handler);
});

