function WindowManager(){ var windows = new Array(); this.self = this; var windowIndex = 0; Event.observe(window, 'keydown', keyboardHandler, false); this.windowExec = new PeriodicalExecuter( function (){ _WM.windowGarbageCollector(); }, 10 ); function keyboardHandler( event ){ if( event.altKey && ( event.keyCode == event.DOM_VK_W ) ){ _WM.closeWindow( -1 ); } } var getNewWindowId = function (){ return ++windowIndex; } this.getWindow = function ( windowId ){ return windows[windowId]; } this.openWindowBySource = function ( sourceText, title, width, height, initX, initY, name ){ var container = document.createElement( "DIV" ); container.id = "container["+getNewWindowId()+"]"; container.innerHTML = sourceText; document.body.appendChild( container ); this.openWindow( container, title, width, height, initX, initY, name ); } this.openWindow = function ( obj, titleText, width, height, initX, initY, name ){ var p = new PopUpWindow( obj, titleText, width, height, initX, initY, name ); p.id = windows.length; windows[ windows.length ] = p; return p.id; } this.openSingleWindow = function ( obj, titleText, width, height, initX, initY, name ){ this.closeAllWindows(); try{ return this.openWindow( obj, titleText, width, height, initX, initY ); }catch( e ){ log( "_WM.openSingleWindow(): "+e.message ); return -1; } } this.closeWindow = function ( windowId ){ try{ if( windowId == -1 ) windowId = windows[ windows.length -1 ].id; }catch( e ){ log( "_WM.closeWindow() failed for windowId("+windowId+"): "+e.message ); return false; } try{ windows[ windowId ].dispose(); }catch( e ){ log( "_WM.closeWindow() failed for windowId("+windowId+"): "+e.message ); return false; } return true; } this.removeDisposedWindow = function ( windowId ){ windows = windows.without( windows[windowId] ); } this.closeAllWindows = function (){ for( var winId = 0; winId < windows.length; winId++ ) this.closeWindow( winId ); } this.windowGarbageCollector = function (){ for( var i=0; i