you think how to create facebook or gamil type chat in your site. don't worry i can solve your proble. here we provide a some facebook or gmail type chat script in php with codeigniter framework.if you know codeigniter framework in php you can easily put this php script in your live web site.
in this example numbers of more user can chat at a time from diffrent diffrent places with him/her friend.you can see below image. or click link to download your example.