curr_url = window.location.href;
//reffer   = window.history.previous; 
reffer='';
var session_id = $.ajax({  url: "chat/client/client_init.php" ,data: "curr_url="+curr_url,  async: false }).responseText;


function refresh_client_status()
{


	var client_id = '<?=$client_id?>';
	var html = $.ajax({  url: "chat/client/chat_init.php",  async: false }).responseText;
	
	
//	$("#hiddenpanel").load("chat/client/chat_init.php"  );
//	if($("#hiddenpanel").html() == 1 || $("#hiddenpanel").html() == 2 )
//		startChat();
  	
	if(html ==1 || html == 2)	
		startChat(html);

	setTimeout(refresh_client_status,5000);

}

refresh_client_status();

 
function startChat( chat_option )
{  
/* 	if(chat_option == 1) 
		popupwindow = window.open('chat/client/client_chat.php','_client_<?=$row['client_id']?>' ,'width=350, height=450' );
 */
	if(chat_option == 2)
	{
		curr_url = window.location.href;
		parent.window.location.href = 'chat/client/frameset.php?url='+curr_url;
	}
}
