var chatInitiated = false;
$(function()
{
if(chatInitiated)
{
initiateChatBox();
checkChat();
}
});
function checkChat()
{
$.post('./xhr/chat_server.php', {'type': 'check'}, function(data)
{
if(typeof(data) == 'string' && data.length > 0)
{
if(!chatInitiated)
{
initiateChatBox();
}
$('#chat_screen').html(data+'
');
var objDiv = document.getElementById("chat_screen");
objDiv.scrollTop = objDiv.scrollHeight;
setTimeout('checkChat()', 2500);
}
else if(chatInitiated)
{
$('#toolboxwrap').remove();
chatInitiated = false;
}
});
}
function sendLine()
{
var line = $('#newLine').val();
if(line.length > 0)
{
$.post('./xhr/chat_server.php', {'type': 'newLine', 'newLine': line}, function(data, textStatus)
{
if(textStatus == 'success')
{
if(typeof(data.err) != undefined)
{
$('#chat_screen').append(''+data)+'
';
var objDiv = document.getElementById("chat_screen");
objDiv.scrollTop = objDiv.scrollHeight;
}
}
});
$('#newLine').val('');
}
}
function makeSupportRequest(name, desc)
{
if(name.length > 0 && desc.length > 0)
{
$.post('./xhr/chat_server.php', {'type': 'request', 'name': name, 'desc': desc}, function(data){if(data == ':::error:::'){alert('Erreur!')}});
$('#supportRequest').remove();
setTimeout('checkChat()', 3500);
}
else
alert('Les champs sont pas là pour rien!');
}
function toggleChat()
{
$('#chat_screen').toggle();
$('#chat_writer').toggle();
}
function initiateChatBox()
{
$('body').append('