   singletons      : {}
   subscriptions   : []
   classes         : {}
-
-  apiUri: KD.config.apiUri
-  appsUri: KD.config.appsUri
+  apiUri          : KD.config.apiUri
+  appsUri         : KD.config.appsUri
 
   whoami:-> KD.getSingleton('mainController').userAccount
-  
+
   isLoggedIn:-> @whoami() instanceof KD.remote.api.JAccount
-  
+
   isMine:(account)-> @whoami().profile.nickname is account.profile.nickname
 
   checkFlag:(flag, account = KD.whoami())-> account.globalFlags and flag in account.globalFlags
 
-  setAuthKey:->
+  requireLogin:(errMsg, callback)->
 
-  requireLogin:(errMsg, callback)->
     [callback, errMsg] = [errMsg, callback] unless callback
+
     if KD.whoami() instanceof KD.remote.api.JGuest
       # KDView::handleEvent {type:"NavigationTrigger",pageName:"Login", appId:"Login"}
       new KDNotificationView


  getKDViewInstanceFromDomElement:(domElement)->
    @instances[$(domElement).data("data-id")]


  # for now it is just a short hand method for propagate but in nodejs fashion
  emit: (eventType, args)->
    for subscription in @subscriptions
      if eventType is subscription.KDEventType
        subscription.callback.apply null,args

  propagateEvent: (KDEventType, publishingInstance, value)->
    for subscription in @subscriptions

  @

# Cross-Browser DOM dependencies
window.URL                   = window.URL                   ? window.webkitURL                   ? null
window.BlobBuilder           = window.BlobBuilder           ? window.WebKitBlobBuilder           ? window.MozBlobBuilder           ? null
window.requestFileSystem     = window.requestFileSystem     ? window.webkitRequestFileSystem     ? null
window.requestAnimationFrame = window.requestAnimationFrame ? window.webkitRequestAnimationFrame ? window.mozRequestAnimationFrame ? null

# FIXME: add to utils.coffee
String.prototype.capitalize   = ()-> this.charAt(0).toUpperCase() + this.slice(1)
String.prototype.decapitalize = ()-> this.charAt(0).toLowerCase() + this.slice(1)
String.prototype.trim         = ()-> this.replace(/^\s+|\s+$/g,"")

# KD Global
KD = @KD or {}

@KD = $.extend (KD), do ->

  # private member for tracking z-indexes
  zIndexContexts  = {}
  debugStates     : {}
