// Based on a simplified http://www.alistapart.com/articles/popuplinks
// modyfied by Francis Booth for width+height+scrollbars+resizable atribute controlls
// ideajunction.co.uk - February 2008

// These defaults should be changed the way it best fits your site
var _POPUP_FEATURES = 'location=0,statusbar=0,menubar=0';

function raw_popup(url, target, width, height, scrollbars, resizable) {
    // pops up a window containing url optionally named target, optionally having features
    if (isUndefined(width)) width = 200;
    if (isUndefined(height)) height = 200;
    if (isUndefined(scrollbars)) scrollbars = 0;
    if (isUndefined(resizable)) resizable = 0;
	features = _POPUP_FEATURES+',scrollbars='+scrollbars+',resizable='+resizable+',width='+width+',height='+height;
    if (isUndefined(target)) target = '_blank';
    var theWindow = window.open(url, target, features);
    theWindow.focus();
    // commented out for Flash popups to work in FF // return theWindow;
}

function link_popup(src, width, height, scrollbars, resizable) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', width, height, scrollbars, resizable);
}

// MISC CLEANING-AFTER-MICROSOFT STUFF
function isUndefined(v) {
    var undef;
    return v===undef;
}
