
function openChatWindow(profile_id) {

	var windowName = "chatWindow" + profile_id;

	ChatWindow = window.open("/cgi/chat.cgi?action=chat&profile_id="+profile_id,windowName,"width=650,height=500,menubar=0,status=1,resizable=1");
        ChatWindow.focus();

}

var cReqObj = createRequestObject();
var cTimer;

function checkChat() {
		
	var sURL = "http://www.carster.com/cgi/chat.cgi?action=check";

	cReqObj.open("get",sURL);
	cReqObj.onreadystatechange = handleSearchResponse;
	cReqObj.send(null);
}

function handleSearchResponse() {

        if (cReqObj.readyState == 4) {

                sBuf = cReqObj.responseText;

		if (sBuf) {
			openChatWindow(sBuf);
		}

		cTimer = setTimeout('checkChat()',9000);
        }
}

function createRequestObject() {
        if (navigator.appName == "Microsoft Internet Explorer")  return new ActiveXObject("Microsoft.XMLHTTP");
        else return new XMLHttpRequest();
}

checkChat();
