/**Chat handle 9oloob, developped by webhouse.com, for 9oloob, chat free with arabe dating. wedding marriage rencontre. Inspired by ajaxchat.
We develop web applications in arabic, please contact us in www.webwhouse.com


*/
function photourl(data){
	if(data=="man1"|| data=="women2"){
		return ("9oloobdata/"+data+".gif");
	}	else {
		return ("9oloobdata/"+data+"t.jpg");
	}
}
function received_9oloob_message(data){
	if(document.getElementById("9oloobmessage") != null){
		if(data!='message9oloob'){
			document.getElementById("9oloobmessage").innerHTML=data;	
		} else {
			document.getElementById("9oloobmessage").innerHTML='';
		}
	}
}
function update_9oloob_present(present,visiteur){
	document.getElementById("nbrpresents").innerHTML=present;
	document.getElementById("nbrvisiteurs").innerHTML=visiteur;
	
}
function affiche_users(data){
	if(document.getElementById("LTuser_status").contentWindow.document.getElementById(data['id']) == null){
		document.getElementById("LTuser_status").contentWindow.document.getElementById("data").innerHTML += "<div id='"+data['id']+"'><a href='afmochtarek.php?moch="+data['name']+"' target='_blank'>"+data['name']+"</a></div>";
		
	}
     	  
	
}
var users_images = new Array();
	
   function remove_msg(element)
   {
	 var el = document.getElementById(element);
	 el.parentNode.removeChild(el);
   }
   //-----------------------------------------------------------------------------------

function compute_time(timei){
	var rep=new Array();
	today = new Date();
	total=today.getHours()*3600+today.getMinutes()*60+today.getSeconds()-timei;
	if(total<0)total+=(3600*24);
	rep['hour']=parseInt(total/3600);
	total=total%3600;
	rep['min']=parseInt(total/60);
	rep['sec']=total%60;
	return rep;
	 
}
function message_received(data){
	var timedif=compute_time(data['timedif']);
	var out = "";
	out = "<TABLE cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=\"100%\"><tr><td><a href=\"afmochtarek.php?moch="+data['username']+"\" target=\"_blank\"><img  src='"+photourl(data['image'])+"'></a></td><td width=100%><table><tr><td><b>"+data['username']+"</b></td><td> (<span style='color:#aaaaaa;'>"+timedif['hour']+ ":"+timedif['min']+ ":"+timedif['sec']+"</span>)</td></tr></table><br>"+data['message']+"</td></tr></TABLE>";
	
	var ancien=document.getElementById("IFRAME_TEXT").contentWindow.document.getElementById("data").innerHTML;
	/*if(ancien.length>10000){
		ancien=ancien.slice(5000);
		ancien=ancien.slice(ancien.indexOf('<table border="0" cellpadding="2" cellspacing="0" width="100%">'));
	}*/
	var lignes=ancien.toLowerCase().split('<table ');
	var tmp='';
	if(lignes.length>20){
			for(var i=lignes.length-20;i<lignes.length;++i){
				tmp+='<TABLE '+lignes[i];
			}
	//		ancien=tmp;
	}
	document.getElementById("IFRAME_TEXT").contentWindow.document.getElementById("data").innerHTML = ancien + out;
     IFRAME_TEXT.scrollTo(0,document.getElementById("IFRAME_TEXT").contentWindow.document.body.scrollHeight);
//	 alert(document.getElementById("IFRAME_TEXT").contentWindow.document.getElementById("data").innerHTML);
}
   //-----------------------------------------------------------------------------------

   function clear_msg(){
     document.getElementById("IFRAME_TEXT").contentWindow.document.getElementById("data").innerHTML = '';
   }
   
   function config_start(url)
   {
     window.open(url,"","width=530,height=440,scrollbars=1,resizable=1");
   }


   
   function private_message_received(data)
   {
     var out = "<TABLE cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=\"100%\" ><tr><td><b>"+data['user_name']+"</b>: <a href='#' onclick='parent.config_start(\"./private.php?private_id="+data['user_id']+"\")'><img valign=middle src=\""+ChatTemplatePath+"img/prv_msg.bmp\" border=0></a> <span style='color:#AAAAAA'> "+data['text']+"</span></td></tr></TABLE>";

     document.getElementById("IFRAME_TEXT").contentWindow.document.getElementById("data").innerHTML += out;
     IFRAME_TEXT.scrollTo(0,document.getElementById("IFRAME_TEXT").contentWindow.document.body.scrollHeight);
	 
   }
  
   
   //-----------------------------------------------------------------------------------

   var isNS4 = (navigator.appName=="Netscape")?1:0;
   function key_u(code)
   {
     if(code == 13)
     {
       send_info(document.getElementById('message').value);
       document.getElementById('message').value = '';
     }
   }

