 
     else
       composing = $(message).find 'composing'
-
       if composing.length > 0
         if $('#chat-' + jid_id).size()
           $('#chat-' + jid_id + ' #content-chat #message-area .chat-messages').append("<div class='chat-event'>" + name + " " + I18n.t("chat.typing") +  "</div>")
           Chat.scroll_chat jid_id
 
       body = $(message).find "html > body"
-
       if body.length == 0
         body = $(message).find 'body'
         if body.length > 0

  presence_value: (elem) ->
    if elem.hasClass 'online' then 3 else
      if elem.hasClass 'dnd' then  2 else
        if elem.hasClass 'away' then 1 else 0

  insert_contact: (elem) ->
    jid = elem.find('.roster-jid').text()


$(document).bind 'contact_added', (ev,data) ->
  $.each data.jid, (index) ->
    found = false
    Chat.list_of_pending_contacts.forEach (element) ->
      if element.name is data.name[index]
        name = element.name
        jid = element.jid
        index = jQuery.inArray(element,Chat.list_of_pending_contacts)
        iq = $iq({type: "set"}).c("query", {xmlns: "jabber:iq:roster"}).c("item", {jid: jid, name: name})
        Chat.connection.sendIQ iq
        Chat.connection.send $pres({to: jid, "type": "subscribe"})
        Chat.connection.send $pres({to: jid, "type": "subscribed"})
        Chat.list_of_pending_contacts.splice(index,1)
        $(document).trigger('pending_requests')
        found = true
        return
    unless found
      jid = data.jid[index] + Chat.domain
      iq = $iq({type: "set"}).c("query", {xmlns: "jabber:iq:roster"}).c("item", {jid: jid,name:data.name[index]})
      Chat.connection.sendIQ iq
      subscribe = $pres({to: jid, "type": "subscribe"})
      Chat.connection.send subscribe

$(document).bind 'change_status', (ev,data) ->
  if data.status is "offline"
