var el = document.getElementsByClassName('chat__list')[0];
var jqEl = $('.chat__list');
var report;
var iGuest = 0;
$('.send').click(function() {
submit();
});
$(".write_text").keypress(function(e) {
if (e.which == 13) {
submit();
}
});
var manager = $('.msg_manageer span');
var guest = $('.msg_manageer_after span');
var guestCount = $('.msg_manageer_after span').length - 1;
var i = 0;
var iGuest = 0;
var itemCount = $('.msg_manageer span').length - 1;
var toScroll;
var isTyping = true;
var e = setInterval(function() {
if (i <= itemCount) {
if (i == itemCount) {
isTyping = false;
}
addMassenge(manager, i);
toScroll = el.scrollHeight;
if (el.scrollHeight >= $('.chat__list').height()) {
forScroll();
}
i++;
} else {
clearInterval(e);
}
}, 1000);
function addMassenge(container, counter) {
$('.loader').fadeToggle('.is_typing');
$(".add_messages").append('' + $(container[counter]).html() + '');
if (isTyping) {
$('.loader').toggle('.is_typing');
}
if (i == itemCount + 1 && counter == guestCount) {
setTimeout(function() {
if (i == itemCount + 1 && counter == guestCount) {
$('.form_js').show();
forScroll();
}
}, 3000);
}