function popup(pageToLoad, winName, width_left, height_right) {
    var window_args = "location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,hotkeys=0,";

    if (width_left > screen.availWidth) {
        width_left = screen.availWidth - 60;
    }
    if (height_right > screen.availHeight) {
        height_right = screen.availHeight - 60;
    }

    var xposition=0;
    var yposition=0;
    if (parseInt(navigator.appVersion) >= 4) {
        xposition = (screen.availWidth - width_left) / 2;
        yposition = (screen.availHeight - height_right) / 2;
    }

    var args = "width=" + width_left + "," + "height=" + height_right + ","
            + window_args
            + "screenx=" + xposition + "," + "screeny=" + yposition + ","
            + "left=" + xposition + "," + "top=" + yposition;

    return window.open(pageToLoad, winName, args);
}

var theURL = "http://www.d20srd.org/srd/";
var indexURL = "http://www.d20srd.org/indexes/";

function openSrd(extension) {
    var win = popup(theURL + extension, "srdWindow", 800, 600);
    win.focus();
}

function openSrdIndex(file) {
    var win = popup(indexURL + file, "srdWindow", 800, 600);
    win.focus();
}
