       'height='+height+',width='+width+',top='+top+',left='+left+',menubar=no'
     )
     window.addEventListener 'message', @hasLoggedIn
+
+  @openRequest: (method, url, async = true) ->
+    request = new XMLHttpRequest()
+    request.beforeSend = (xhr) ->
+      xhr.withCredentials = true
+    request.open(method, url, async)
+    request.setRequestHeader('Accept', 'application/json')
+    request.setRequestHeader('Content-Type', 'application/json')
+
+    request

      elem.className = newClass.replace(/^\s+|\s+$/g, '')

  @get: (url, callback) ->
    request = new XMLHttpRequest
    request.withCredentials = true
    request.open('GET', url, true)
    request.setRequestHeader('Content-Type', 'application/json')
    request.onload = () ->
      if request.status >= 200 and request.status < 400
        callback(JSON.parse(request.responseText))
    request.send()

  @post: (url, data, callback) ->
    request = new XMLHttpRequest()
    request.withCredentials = true
    request.open('POST', url, true)
    request.setRequestHeader('Content-Type', 'application/json')
    request.onload = () ->
      if request.status >= 200 and request.status < 400
        callback(JSON.parse(@responseText))

      return false

  @getUser: ->
    request = @openRequest('GET', '@{UserR}', false)
    request.send()
    if request.status is 200
      @user = JSON.parse(request.responseText).user
