     $("#chat-" + jid_id).find('.chat-messages').append(
       "<div class='chat-message border-history'></div>")
     Chat.scroll_chat jid_id
+
+#  creating_room: (iq) ->
+#    console.log "sala"
+#    console.log iq
 
 $ ->
   # trigger to start the chat

        if pres > cmp_pres
          $(element).before elem
          inserted = true
        else
          if pres is cmp_pres
            if jid < cmp_jid
              $(element).before elem
              inserted = true
        return

      if not inserted then $('#roster-area ul').append elem

    else $('#roster-area ul').append elem


  insertChatArea: (jid,jid_id,status,name) ->
    $("#chat-bar").append(


$(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"
