// JavaScript Document
function createAJAXObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var httpCM = createAJAXObject();
var httpIC = createAJAXObject();

function CheckMessageToUser(userID) 
{
	nocache = Math.random();
	var url='chkmsgtouser.php?userid='+userID+'&nocache = '+nocache;	
	httpCM.open('get',url );
	httpCM.onreadystatechange = responseFill;
	setTimeout("CheckMessageToUser("+userID+")",2000);
	httpCM.send(null);
}
function responseFill()
{
	if(httpCM.readyState == 4)
	{
		var response = httpCM.responseText;
		var res=response.split('@##@');
		var result ="";
		if(res.length>1)
			result = res[1].split('||');
		for(i=0;i<result.length;i++)
		{
			if(result[i])
			{	
				var resNew = result[i].split("###");
				var ChatWindow = window.open("chat/chatWin.php?expertt_id="+resNew[0], 'ChatWindow', 'width=320,height=260,scrollbars=0,resizable=0,location=0',resNew[0]+"-"+resNew[1]);
					ChatWindow.focus();

			}	
		}
		
	}
}

function ischatting(chatid) 
{
	nocache = Math.random();
	var url='chat/ischatting.php?chat_id='+chatid+'&nocache = '+nocache;	
	httpIC.open('get',url );
	httpIC.send(null);
}