 }
 
 import flash.display.DisplayObject;
+import flash.display.Sprite;
 import flash.geom.Rectangle;
 import flash.events.Event;
 import flash.events.IEventDispatcher;
 import flash.events.MouseEvent;
+import flash.display.Stage;
+import flash.geom.Point;
+
 import mx.core.IUIComponent;
+import mx.core.mx_internal;
 import mx.effects.Effect;
 import mx.managers.ISystemManager;
-import flash.display.Stage;
 import mx.managers.ISystemManager2;
-import flash.geom.Point;
+import mx.managers.PopUpManagerImpl;
 
 ////////////////////////////////////////////////////////////////////////////////
 //

    	sm.numModalWindows++;

        // Add it to the collection just below the popup
        childrenList.addChildAt(modalWindow,
            childrenList.getChildIndex(DisplayObject(popup)));
        
        // force into the automation hierarchy
        if (popup is IAutomationObject)
            IAutomationObject(popup).showInAutomationHierarchy = true;
        
        // set alpha of the popup and get it out of the focus loop
        if (popupStyleClient)
            modalWindow.alpha = popupStyleClient.getStyle("modalTransparency");
		else
			modalWindow.alpha = 0;
			
        modalWindow.tabEnabled = false;
        
        const s:Rectangle = sm.screen;
        const g:Graphics = modalWindow.graphics;
        
        if (sm.isTopLevel() && systemManagerModal)
        {
        	// trace("createModalWindowForPopup: toplevel and using systemManagerModal mode");
        	s.width = DisplayObject(SystemManager(sm).application).width;
        	s.height = DisplayObject(SystemManager(sm).application).height;
        	
        }
        else if (smp)
        {
			var sandboxScreen:Rectangle = ISystemManager2(smp.systemManager).screen;
			s.width = sandboxScreen.width;

    public var blur:Effect;
    
    /**
     *  @private
     * 
     */
    public var blurTarget:Object;
     
    /**
     *   @private
     * 
     *   The host of the modal dialog.
     */
    public var systemManager:ISystemManager2;
    
    //--------------------------------------
    //  fields only for remote modal windows
    //--------------------------------------

    /**
     *   @private
     * 
     *   Is this popup just a modal window for a popup 
     *   in an untrusted sandbox?
     */
    public var isRemoteModalWindow:Boolean;
    
    /**
     *   @private
     */
    public var modalTransparencyDuration:Number;
    
    /**
     *   @private
     */
    public var modalTransparency:Number;
    
    /**
     *   @private
     */
    public var modalTransparencyBlur:Number;
    
    /**
     *   @private
     */
    public var modalTransparencyColor:Number;
    
    /**
     *   @private
     * 
     *   Object to exclude from the modal dialog. The area of the 
     *   display object will be excluded from the modal dialog.
     */  
    public var exclude:IUIComponent;
     
    /**
     *   @private
     * 
     *   Mask created from the modalWindow and exclude fields.
     */  
    public var modalMask:Sprite;

    //--------------------------------------------------------------------------
    //
    //  Event handlers
