/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttpSB1 = false;
var xmlHttpSB2 = false;
var cid;
var mbpage;
var memberid;
var prevresponse;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttpSB1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttpSB1 = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttpSB1 = false;
  }
}
@end @*/

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttpSB2 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttpSB2 = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttpSB2 = false;
  }
}
@end @*/

if (!xmlHttpSB1 && typeof XMLHttpRequest != 'undefined') {
  xmlHttpSB1 = new XMLHttpRequest();
}

if (!xmlHttpSB2 && typeof XMLHttpRequest != 'undefined') {
  xmlHttpSB2 = new XMLHttpRequest();
}

// getElementById Special to handle quirky browsers
// most will use getElementById()
function getElementById_sSB(id){
  var obj = null;
  if(document.getElementById){
  /* Prefer the widely supported W3C DOM method, if available:- */
  obj = document.getElementById(id);
  }else if(document.all){   /* Branch to use document.all on document.all only browsers. Requires that IDs are unique to the page and do not coincide with NAME attributes on other elements:- */
  obj = document.all[id];
  }
  /* If no appropriate element retrieval mechanism exists on this browser this function always returns null:- */
  return obj;
  }

function getNewShoutBoxData(tmemberid, first) {

	memberid = tmemberid;
	
  // Build the URL to connect to
  var url = "/message_board/newshoutbox/get_new_data.php?member_id=" + memberid + "&first=" + first + "&rand=" + (Math.floor(Math.random()*99999));
  
  // Open a connection to the server
  xmlHttpSB1.open("GET", url, true);

  // Setup a function for the server to run when it's done
  xmlHttpSB1.onreadystatechange = updateShoutBox;

  // Send the request
  xmlHttpSB1.send(null);
}

function getWhoIsOnline() {

	var url = "/message_board/newshoutbox/get_who_is_online.php?rand=" + (Math.floor(Math.random()*99999));
  
  // Open a connection to the server
  xmlHttpSB2.open("GET", url, true);

  // Setup a function for the server to run when it's done
  xmlHttpSB2.onreadystatechange = updateWhoIsOnline;

  // Send the request
  xmlHttpSB2.send(null);
}

function updateShoutBox() {
  if (xmlHttpSB1.readyState == 4) {
    var response = xmlHttpSB1.responseText;
		if(response != prevresponse) {
     updateShoutBoxDisplay(response);
		 }
		prevresponse = response;
		setTimeout('getNewShoutBoxData(\''+memberid+'\', 0)', 1000);
		}
}

function updateWhoIsOnline() {
  if (xmlHttpSB2.readyState == 4) {
    var response = xmlHttpSB2.responseText;
		if(response != prevresponse) {
     updateWhoIsOnlineDisplay(response);
		 }
		prevresponse = response;
		setTimeout('getWhoIsOnline()', 6000);
		}
}

function scrollAgain()  {
	IFRAME_TEXT.scrollTo(0,document.getElementById("IFRAME_TEXT").contentWindow.document.body.scrollHeight);
	}
