     
     $('form#update_profile').bind 'ajax:error', (xhr, status, error)->
       $('p.alert').text(error)
+  toggleProfile:  ->
+    if @contextView.profileState() is 'none'
+      @contextView.expandProfile()
+    else
+      @contextView.contractProfile()
 
 class ContextView
   constructor: (containerSelector) ->

    @$container.find('.cancel').click (event) =>
      @contextView.showProfile()
    
    $(containerSelector).find('.context, .profile').click (event) =>
      if @contextView.profileState() is 'none'
        @contextView.expandProfile()
      else
        @contextView.contractProfile()
    
    $('form#update_profile').bind 'ajax:beforeSend', (xhr, settings)=>
      @contextView.showProfile()

window.contextController = null

$(document).ready ->
  window.contextController = new ContextController('#contextPanel')

class ContextController
  constructor: (containerSelector) ->
