var reddit=0;
var xmlHttp3 = getXmlHttpRequestObject();
var mTimer200032;
var lastm;
var lastg;
function WhosOnline()
{
xmlHttp3=GetxmlHttpObject3()
if (xmlHttp3==null)
{
alert ("Your browser does not support AJAX!");
return;
}
xmlHttp3.onreadystatechange=stateChanged3;
xmlHttp3.open("GET","http://www.atheistnation.net/video/onlinenow.php",true);
xmlHttp3.send(null);
mTimer200032 = setTimeout('WhosOnline();',60000);
}
function stateChanged3()
{
if (xmlHttp3.readyState==4)
{
var m_node = xmlHttp3.responseXML.getElementsByTagName("m")[0].firstChild.nodeValue;
var g_node = xmlHttp3.responseXML.getElementsByTagName("g")[0].firstChild.nodeValue;
var l_node = xmlHttp3.responseXML.getElementsByTagName("l")[0].firstChild.nodeValue;
if (document.getElementById("chatonlinem")==null) {
document.getElementById("chatonline").innerHTML="
Users Online: guests, members:
";
}
document.getElementById("chatonlinem").innerHTML = m_node;
document.getElementById("chatonlineg").innerHTML = g_node;
document.getElementById("showmembers").innerHTML = l_node;
}
}
function GetxmlHttpObject3()
{
var xmlHttp3=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp3=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp3=new ActiveXObject("Msxml3.XMLHTTP");
}
catch (e)
{
xmlHttp3=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp3;
}
var sendReq = getXmlHttpRequestObject();
var receiveReq = getXmlHttpRequestObject();
var lastMessage = 1179786;
var message = 0;
var mTimer;
var mTimer9;
var mTimer10;
var mTimer12;
var mTimer13;
var updating;
var updatespeed=10000; // default update speed
var speedslow = 750; // how much to slow update speed when no messages received
var speedfast = 1500; // how much to speed up update speed for each new message received
var speedmax = 6000; // shortest possible update speed
var speedmin = 15000; // longest possible update speed
var pingcode = 207;
var timechange=0;
//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
} else {
document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object. Consider upgrading your browser.';
}
}
//Gets the current messages from the server
function getChatText() {
if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
receiveReq.open("GET", 'http://www.atheistnation.net/chat/getChat.php?chat=1&last=' + lastMessage, true);
receiveReq.onreadystatechange = handleReceiveChat;
receiveReq.send(null);
}
}
//Add a message to the chat server.
function sendChatText() {
getChatText();
if(document.getElementById('txt_message').value == '') { }
if (sendReq.readyState == 4 || sendReq.readyState == 0) {
sendReq.open("POST", 'http://www.atheistnation.net/chat/getChat.php?chat=1&last=' + lastMessage, true);
sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
sendReq.onreadystatechange = handleSendChat;
var mystring2 = document.getElementById('txt_message').value;
var mystring = escape(mystring2);
var param = 'message=' + mystring;
param += '&chat=1';
sendReq.send(param);
document.getElementById('txt_message').value = '';
document.getElementById('msgstatus').innerHTML = '';
mTimer11 = setTimeout('clearmsgstatus();',10); //Refresh our chat in 10 milliseconds
mTimer15 = setTimeout("document.getElementById('chatstatus').innerHTML = '';",500);
//this avoids a flicker-effect when the chat loads very quickly
}
else {
document.getElementById('chatstatus').innerHTML = '';
}
}
//When our message has been sent, update our page.
function handleSendChat() {
//Clear out the existing timer so we don't have
//multiple timer instances running.
clearInterval(mTimer);
getChatText();
}
//Function for handling the return of chat text
function handleReceiveChat() {
if (receiveReq.readyState == 4) {
var chat_div = document.getElementById('div_chat');
var xmldoc = receiveReq.responseXML;
var message_nodes = xmldoc.getElementsByTagName("message");
var ping_nodes = xmldoc.getElementsByTagName("ping");
var code_node = ping_nodes[0].getElementsByTagName("code");
var pingcode2 = code_node[0].firstChild.nodeValue;
if (pingcode2 != pingcode) {
document.getElementById('chatloading').innerHTML = '
Your chat is being automatically reset by the server...
(Loading times may vary depending on server load and connection speed)
';
document.getElementById('div_chat').innerHTML = '';
lastMessage = 0;
pingcode = pingcode2;
chatreset();
handleSendChat();
mTimer13 = setTimeout('chatreset();',5000); //Refresh our chat in 5 seconds
}
var new_nodes = xmldoc.getElementsByTagName("new");
var new_node = new_nodes[0].getElementsByTagName("minutesago");
var checknode2 = new_node[0].firstChild.nodeValue;
if (checknode2 != 6666666666) {
if (checknode2 == 1 ) { var sornot = "minute"; }
else { var sornot = "minutes"; }
document.getElementById('lasttime').innerHTML = checknode2 + ' ' + sornot;
timechange = checknode2;
clearInterval(mTimer12);
mTimer12 = setTimeout('changetime();',60000); //Refresh in 60 seconds
}
var new_node = new_nodes[0].getElementsByTagName("yes");
var checknode = new_node[0].firstChild.nodeValue;
if (checknode > 0) {
var div1 = document.getElementById('newchatmsgnotice');
if (div1.style.display == 'none') {
document.getElementById('newchatmsgnotice').style.display = 'block';
}
}
var n_messages = message_nodes.length
if (n_messages > 0) { updatespeed=updatespeed-speedfast*n_messages; if (updatespeed < speedmax) { updatespeed=speedmax; } }
else { updatespeed=updatespeed+speedslow; }
if (updatespeed >= speedmin) { updatespeed=speedmin; }
for (i = 0; i < n_messages; i++) {
var user_node = message_nodes[i].getElementsByTagName("user");
var text_node = message_nodes[i].getElementsByTagName("text");
var time_node = message_nodes[i].getElementsByTagName("time");
var video_node = message_nodes[i].getElementsByTagName("video");
var name2_node = message_nodes[i].getElementsByTagName("name2");
var level_node = message_nodes[i].getElementsByTagName("level");
if (level_node[0].firstChild.nodeValue == "3") {
chat_div.innerHTML += '