
generic.popup = function(/*Object*/args) {
    var activatorNode = $(args.activator);
    if (!activatorNode) { return false; }
        
    //console.log("creating popup for "+activatorNode); 
    var specs = Object.toQueryString(Object.extend(generic.popup.defaults, args));
    var specs = specs.replace(/\&/g, ",");
     
    var open = function() {
        var win = window.open(args.url, args.name, specs);
        if (!win) generic.popup.errorAction(); 
    };

    activatorNode.observe("click", open); 
    
    return true;
}

generic.popup = Object.extend(generic.popup, {
    defaults: {  
        height: 500,
        width: 500,
        top: 25,
        left: 25,
        resizable: "yes",
        scrollbars: "yes",
        status: "no",
        toolbar: "no",
        menubar: "no",
        location: "no"
    },
    errorAction: function() {
         var msg = global.rb.popup_error_message;
         if (msg) alert(msg);
    }
});
