 			else
 				template.unreadCount.set 0
 	, 300
-
-	Meteor.setInterval ->
-		if template.atBottom
-			wrapper.scrollTop = wrapper.scrollHeight - wrapper.clientHeight
-			newMessage.className = "new-message not"
-	, 100
-
-	wrapper.addEventListener 'touchstart', ->
-		template.atBottom = false
-
-	wrapper.addEventListener 'touchend', ->
-		onscroll()
-		readMessage.enable()
-		readMessage.read()
-
-	wrapper.addEventListener 'scroll', ->
-		template.atBottom = false
-		onscroll()
-		updateUnreadCount()
-
-	wrapper.addEventListener 'mousewheel', ->
-		template.atBottom = false
-		onscroll()
-		readMessage.enable()
-		readMessage.read()
-
-	wrapper.addEventListener 'wheel', ->
-		template.atBottom = false
-		onscroll()
-		readMessage.enable()
-		readMessage.read()
 
 	# salva a data da renderização para exibir alertas de novas mensagens
 	$.data(this.firstNode, 'renderedAt', new Date)

	# ScrollListener.init()

	wrapper = this.find('.wrapper')
	newMessage = this.find(".new-message")

	template = this

	wrapperOffset = $('.messages-box > .wrapper').offset()

	onscroll = _.throttle ->
		template.atBottom = wrapper.scrollTop >= wrapper.scrollHeight - wrapper.clientHeight
	, 200

	updateUnreadCount = _.throttle ->
		firstMessageOnScreen = document.elementFromPoint(wrapperOffset.left+1, wrapperOffset.top+50)

			if error
				toastr.error error.reason

	'load img': (e, template) ->
		template.sendToBottomIfNecessary?()


Template.room.onCreated ->
	# this.scrollOnBottom = true
	# this.typing = new msgTyping this.data._id
