//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.  Error is
//thrown on IE8 if a child window(s) was already closed.
function closeAllWindows() 
{
    var openCount = openWindow.length;
    for(r=0;r<openCount;r++) 
    {
        if (openWindow[r]!=null)
        {
            try
            {
                if (!openWindow[r].closed)
                    openWindow[r].close();
            }        
            catch(err)
            {}                        
            
        }
    }
}

