//The openWindow array will hold the handles of all open child windows
var openWindow = new Array();

//Track open adds the new child window handle to the array.
function trackOpen(winName) {
    openWindow[openWindow.length]=winName;
}

function removeOpen(winName){
    var openCount = openWindow.length;
    for(r=0;r<openCount;r++) {
        if (openWindow[r]==winName){
            openWindow[r]=null;
        }
    }
}

//loop over all known child windows and try to close them.  No error is
//thrown if a child window(s) was already closed.
function closeAllWindows() {
    var openCount = openWindow.length;
    for(r=0;r<openCount;r++) {
        if (openWindow[r]!=null){
            openWindow[r].close();
        }
    }
}
