 var v_xhr_l = xml_http_request(); var v_xhr_s = xml_http_request(); var v_xhr_u = xml_http_request(); var v_serv_lastid; var v_timeout_chat; var v_timeout_users; var v_css_message;  window.onload = window_load;  function window_load() { v_serv_lastid = '-1'; clearTimeout(v_timeout_chat); clearTimeout(v_timeout_users); v_css_message = true; if (v_xhr_l) { chat_load(); users_load(); get_id('chat_user').focus(); } else { var v_html = '<p>&nbsp;</p>'; v_html += '<p>ATTENTION : Votre navigateur ne supporte pas les objets <a href="http://openweb.eu.org/articles/objet_xmlhttprequest/">XMLHttpRequest</a>.</p>'; v_html += '<p>Pour utiliser ce chat, nous vous invitons à télécharger la dernière version de <a href="http://www.mozilla.com/">Mozilla Firefox</a>.</p>'; v_html += '<p>&nbsp;</p><p>&nbsp;</p><p>Informations sur votre navigateur actuel :</p>CCBot/1.0 (+http://www.commoncrawl.org/bot.html)<p></p>'; get_id('chat_users').innerHTML = ''; get_id('chat_room').innerHTML = v_html; } }  function window_mini() { if (get_id('window0101div').className == 'window_block') { get_id('window0101div').className = 'window_mini_block'; get_id('window0102div').className = 'window_mini_title'; get_id('window0103div').className = 'window_mini_block'; } else { get_id('window0101div').className = 'window_block'; get_id('window0102div').className = 'window_title'; get_id('window0103div').className = 'window_block'; } }  function key_press(v_event) { if (v_event.keyCode == 13 || v_event.keyCode == 3) { chat_send(); } }  function get_id(v_id) { return document.getElementById(v_id); }  function get_node(v_nodes,v_tag_name) { var v_return = ''; if (v_nodes.getElementsByTagName(v_tag_name)[0] != null && v_nodes.getElementsByTagName(v_tag_name)[0].firstChild != null) { v_return = v_nodes.getElementsByTagName(v_tag_name)[0].firstChild.nodeValue; } return v_return; }  function get_input(v_id) { var v_return = ''; if (get_id(v_id) != null) { v_return = encodeURIComponent(get_id(v_id).value); } return v_return; }  function xml_http_request() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if (window.ActiveXObject) { try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { return new ActiveXObject('Microsoft.XMLHTTP'); } } else { return false;  } }  function chat_send() { if (chat_control_send()) { clearTimeout(v_timeout_chat);  v_xhr_s.open('POST', 'chat_xml.php', true); v_xhr_s.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); v_xhr_s.onreadystatechange = chat_state_send;  var v_url = 'ajax=send'; v_url += '&lastid='+encodeURIComponent(v_serv_lastid); v_url += '&user='+get_input('chat_user'); v_url += '&password='+get_input('chat_password'); v_url += '&email='+get_input('chat_email'); v_url += '&message='+get_input('chat_message'); v_xhr_s.send(v_url); } }  function chat_state_send() { if (v_xhr_s.readyState == 4 && v_xhr_s.status == 200) { get_id('chat_message').value = ''; get_id('chat_message').focus();  var v_chat_room = get_id('chat_room'); var v_chat_xml = v_xhr_s.responseXML;  var v_serv_console = get_node(v_chat_xml,'console');  v_chat_room.innerHTML += (v_serv_console) ? '<ul class="console"><li>'+ v_serv_console +'</li></ul>' : '';   chat_scroll(); chat_loading(false); chat_load(); } else { chat_loading(true); } }  function chat_control_send() { var v_errors = ''; var v_focus = ''; if (get_id('chat_user').value.search(/\s*\S{2,}/)) { v_errors += 'Votre PSEUDO est incorrecte (ex: Surnom)\n'; v_focus = 'chat_user'; } if (get_id('chat_email').value.search(/\s*\S+\@\S+\.\S+/)) { v_errors += 'Votre EMAIL est incorrecte (ex: mail@fournisseur.fr)\n'; v_focus = (v_focus) ? v_focus : 'chat_email'; }  if (v_errors != '') { alert(v_errors); get_id(v_focus).focus(); return false; } else { return true; } }  function chat_load() { v_xhr_l.open('POST', 'chat_xml.php', true); v_xhr_l.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); v_xhr_l.onreadystatechange = chat_state_load;  var v_url = 'ajax=load'; v_url += '&lastid='+encodeURIComponent(v_serv_lastid); v_url += '&user='+get_input('chat_user'); v_url += '&password='+get_input('chat_password'); v_url += '&email='+get_input('chat_email'); v_xhr_l.send(v_url);  v_timeout_chat = setTimeout('chat_load()', 3000); }  function chat_state_load() { if (v_xhr_l.readyState == 4 && v_xhr_l.status == 200) { var v_chat_room = get_id('chat_room'); var v_chat_xml = v_xhr_l.responseXML;  var v_chat_nodes = v_chat_xml.getElementsByTagName('chat');   var v_serv_command = get_node(v_chat_xml,'command'); v_serv_lastid = get_node(v_chat_xml,'lastid');  if (v_serv_command == 'load') { } else if (v_serv_command == 'clean') { chat_clean(); } else if (v_serv_command == 'ban') { clearTimeout(v_timeout_users); get_id('chat_users').innerHTML = '';  clearTimeout(v_timeout_chat); v_css_message = true; chat_clean(); }  for (i = 0; i < v_chat_nodes.length; i++) { var v_html = ''; if (v_css_message) { v_css_message = false; v_html += '<ul class="ul1" onmouseover="this.className=\'mouseover1\';" onmouseout="this.className=\'mouseout1\';">'; } else { v_css_message = true; v_html += '<ul class="ul2" onmouseover="this.className=\'mouseover2\';" onmouseout="this.className=\'mouseout2\';">'; } var v_html_infos = ''; v_html_infos += (get_node(v_chat_nodes[i],'datetime')) ? '<li>'+get_node(v_chat_nodes[i],'datetime')+'</li>' : ''; v_html_infos += (get_node(v_chat_nodes[i],'id')) ? '<li>'+get_node(v_chat_nodes[i],'id')+'</li>' : ''; v_html += (v_html_infos) ? '<ul class="infos">'+v_html_infos+'</ul>' : ''; v_html += (get_node(v_chat_nodes[i],'time')) ? '<li class="time">'+ get_node(v_chat_nodes[i],'time') +'</li>' : ''; v_html += (get_node(v_chat_nodes[i],'user')) ? '<li class="user">'+ get_node(v_chat_nodes[i],'user') +'</li>' : ''; v_html += (get_node(v_chat_nodes[i],'message')) ? '<li class="message">'+ get_node(v_chat_nodes[i],'message') +'</li>' : '<li class="message">?</li>'; v_html += '</ul>'; v_chat_room.innerHTML += v_html; }   chat_scroll(); chat_loading(false); } else { chat_loading(true); } }  function chat_loading(v_loading) { var v_img = (v_loading) ? 'chat_loading.gif' : 'chat_load.gif'; get_id('chat_loading').innerHTML = '<img src="'+v_img+'" alt="Loading" title="Activité du serveur ('+v_serv_lastid+')" />'; }  function chat_separator() { get_id('chat_room').innerHTML += '<div class="separator"></div>'; chat_scroll(); get_id('chat_message').focus(); }  function chat_clean() { get_id('chat_room').innerHTML = '<div class="clean"></div>'; chat_scroll(); get_id('chat_message').value = ''; }  function chat_icon(v_icon) { get_id('chat_message').value += ' '+v_icon ; get_id('chat_message').focus(); }  function icon_show() { get_id('chat_icon').style.display = (get_id('chat_icon').style.display == 'block') ? 'none' : 'block'; }  function chat_scroll() { if (!get_id('chat_scroll').checked) { get_id('chat_room').scrollTop = get_id('chat_room').scrollHeight; } }  var v_css_height = 400; function chat_resize(v_mode) { if (v_mode == '+') { v_css_height += 20; v_css_height = (v_css_height > 1000) ? 1000 : v_css_height; } else if (v_mode == '-') { v_css_height -= 20; v_css_height = (v_css_height < 100) ? 100 : v_css_height; } else { v_css_height = 500; }  get_id('chat_room').style.height = v_css_height+'px'; get_id('chat_users').style.height = (v_css_height-21)+'px'; chat_scroll(); }  var v_css_zoom = 100; function chat_zoom(v_mode) { if (v_mode == '+') { v_css_zoom += 10; v_css_zoom = (v_css_zoom > 200) ? 200 : v_css_zoom; } else if (v_mode == '-') { v_css_zoom -= 10; v_css_zoom = (v_css_zoom < 50) ? 50 : v_css_zoom; } else { v_css_zoom = 100; }  get_id('chat_room').style.fontSize = v_css_zoom+'%'; get_id('chat_zoom').innerHTML = v_css_zoom+'%'; chat_scroll(); }   function users_load() { v_xhr_u.open('POST', 'chat_xml.php', true); v_xhr_u.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); v_xhr_u.onreadystatechange = users_state_load;  var v_url = 'ajax=users'; v_url += '&user='+get_input('chat_user'); v_url += '&password='+get_input('chat_password'); v_url += '&email='+get_input('chat_email'); v_xhr_u.send(v_url);  v_timeout_users = setTimeout('users_load()', 5000); }  function users_state_load() { if (v_xhr_u.readyState == 4 && v_xhr_u.status == 200) { var v_chat_users = get_id('chat_users'); var v_users_xml = v_xhr_u.responseXML; var v_users_nodes = v_users_xml.getElementsByTagName('users');  var v_html = ''; for (i = 0; i < v_users_nodes.length; i++) { v_html += '<ul onmouseover="this.className=\'mouseover\';" onmouseout="this.className=\'mouseout\';">'; v_html += (get_node(v_users_nodes[i],'user')) ? '<li class="user">'+ get_node(v_users_nodes[i],'user') +'</li>' : '<li class="user">?</li>';  var v_html_infos = ''; v_html_infos += (get_node(v_users_nodes[i],'id')) ? '<li>'+get_node(v_users_nodes[i],'id')+'</li>' : ''; v_html_infos += (get_node(v_users_nodes[i],'ip')) ? '<li>'+get_node(v_users_nodes[i],'ip')+'</li>' : ''; v_html_infos += (get_node(v_users_nodes[i],'email')) ? '<li>'+get_node(v_users_nodes[i],'email')+'</li>' : ''; v_html += (v_html_infos) ? '<ul class="infos">'+v_html_infos+'</ul>' : ''; v_html += '</ul>'; } v_chat_users.innerHTML = v_html;  users_loading(false); } else { users_loading(true); } }  function users_loading(v_loading) { var v_img = (v_loading) ? 'chat_loading.gif' : 'chat_load.gif'; get_id('users_loading').innerHTML = '<img src="'+v_img+'" alt="Loading" title="Activité du serveur" />'; } 