 ###
 app router
 ###
+
+createMapChunkRouter = (name, next) ->
+  #if needed, link to next level
+  ChunkRouter = if next
+    Ember.LayoutState.extend {
+      next: next
+      nexts: Ember.LayoutState.create {
+        viewClass: Em.View.extend {}
+        enter: (stateManager, transition) ->
+          @_super stateManager, transition
+          Weathermaps.current.set 'lock', false
+      }
+    }
+  else
+    Ember.LayoutState
+  #create instance
+  ChunkRouter.create {
+    route: ':'+name
+    viewClass: Em.View.extend {}
+    enter: (stateManager, transition) ->
+      @_super stateManager, transition
+      Weathermaps.current.set 'lock', true
+      chunk = stateManager.getPath 'params.'+name
+      Weathermaps.current.set name, chunk
+      if not next
+        Weathermaps.current.set 'lock', false
+  }
 
 Weathermaps.routeManager = Ember.RouteManager.create {
   rootView: Weathermaps.main

    viewClass: Em.View.extend {
      templateName: 'map'
    }
    group: Ember.LayoutState.create {
      route: ":group"
      viewClass: Em.View.extend {}
      enter: (stateManager, transition) ->
        @_super stateManager, transition
        group = stateManager.getPath 'params.group'
        Weathermaps.current.set 'group', group
    }
  }
}


      ""
  ).property('group', 'map', 'date', 'time')
  permalink: (->
    if @get 'lock'
      return false
    if Weathermaps.routeManager
      group = @get('group')
      map = @get('map')
