function filter(list, func) {
    var result = [];
    func = func || function(v) {return v};
    map(list, function(v) { if (func(v)) result.push(v) } );
    return result;
}

function isUndefined(v) {
    var undef;
    return v===undef;
}

var _POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,width=1000,height=660,titlebar=0,toolbar=0';

function raw_popup(url, target, features) {
     if (isUndefined(features)) features = _POPUP_FEATURES;
    if (isUndefined(target  )) target   = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    return theWindow;
}

function link_popup(src, features) {
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}

