       listener      : @
       callback      : =>
         delete @windowResizeListeners[instance.id]
-  
+
   setWindowProperties:(event)->
     @winWidth  = $(window).width()
     @winHeight = $(window).height()
-  
+
   notifyWindowResizeListeners:(event, throttle = no, duration = 17)->
     event or= type : "resize"
     if throttle

      @unsetDragView e if @dragView
      @propagateEvent (KDEventType: 'ReceivedMouseUpElsewhere'), e
    , yes
    
    document.body.addEventListener 'mousemove', (e)=>
      @redirectMouseMoveEvent e
    , yes
    

    window.onbeforeunload = (event) =>
      # event.preventDefault();
      # event.stopImmediatePropagation();
      # event.stopPropagation();

      event or= window.event
      msg = "Please make sure that you saved all your work."
      
      event.returnValue = msg if event # For IE and Firefox prior to version 4

      return msg unless window.location.hostname isnt 'localhost'

  setDragInAction:(action = no)->
    $('body')[if action then "addClass" else "removeClass"]("dragInAction")
    @dragInAction = action
  
  setMainView:(view)->
    @mainView = view
  
  getMainView:(view)->
    @mainView


    @bindEvents()
    @setWindowProperties()
    super

  addLayer: (layer)->

    unless layer in @layers
      @layers.push layer

  removeLayer: (layer)->

    if layer in @layers
      index = @layers.indexOf(layer)
      @layers.splice index, 1

  bindEvents:()->

    $(window).bind "keydown keyup keypress",@key
