// JavaScript Document

	function refresherMain(){
		if (!Ajax.chatWindow) Ajax.chatWindow= new Array();
		var content = new Ajax.PeriodicalUpdater('','/Community/chat_updater.php',{
			method: 'post',
			decay : 1,
			frequency: 10,
			onSuccess : function(transport){
				if(transport.responseText){
					var chats = transport.responseText.split(' ||| ');
					for(i in chats){
						if(parseInt(i) == parseFloat(i)){
							var ids = chats[i].split(' || ');
							var id = parseInt(ids[0]);
							chat(id,ids[1]);
						}
					}
				}
			}
		});
	}

	function chat(id,id_chat){
		if (!Ajax.chatWindow) Ajax.chatWindow= new Array();
		if(!Ajax.chatWindow[id_chat] || Ajax.chatWindow[id_chat].closed){
			var width = 500;
			var height = 400;
			var top = (screen.availHeight-height)/2;
			var left = (screen.availWidth-width)/2;
			Ajax.chatWindow[id_chat] = window.open('/Community/chat.php?id='+id+'&id_chat='+id_chat,'Chat'+id,'width='+width+',height='+height+',top='+top+',left='+left+',resizable=1,location=0');
		}
	}

	window.onload = function(){
		refresherMain();
	}
