gPopupWindowCommonPropString = "dependent=no,resizable=yes,personalbar=no,menubar=no,directories=no,toolbar=no,scrollbars=yes";
gDefaultWinName = "detailPopup";
gDefaultHeight = "400";
gDefaultWidth = "500";
gPopupWindowURLArgString = "focus=false&resize=true";
gPopupDefaultURLString = "";

gPopups = new Array();

function checkOpenPopup(pWinName, pWidth, pHeight, pURL, pOpener){
    widthString = "width=";
    if(pWidth == null){
        widthString += gDefaultWidth;
    }else{
        widthString += pWidth;
    }
    heightString = "height=";
    if(pHeight == null){
        heightString += gDefaultHeight;
    }else{
        heightString += pHeight;
    }
    propString = widthString + "," + heightString + "," + gPopupWindowCommonPropString;

    winName = gDefaultWinName;
    if(pWinName != null){
        winName = pWinName;
    }

    urlString = gPopupDefaultURLString;
    if(pURL != null){
        urlString = pURL;
    }
    if(urlString.indexOf("?") > -1){
        urlString += "&";
    }else{
        urlString += "?";
    }
    urlString += gPopupWindowURLArgString;

    useOpener = window;
    if(pOpener != null){
        useOpener = pOpener;
    }

    newWin = useOpener.open(urlString, winName, propString);
    newWin.focus();
    gPopups[gPopups.length] = newWin;
    return newWin;
}

function checkClosePopups(){
    for(y=0;y<gPopups.length;y++){
        if((gPopups[y] != null) && (!gPopups[y].closed)){
            gPopups[y].close();
            gPopups[y] = null;
        }
    }
}
