window.addEvent('domready', function() {
	
	//We can use one Request object many times.
	var req = new Request.HTML({url:'/ajax/messages.php', 
		onSuccess: function(html) {
			
			//Clear the text currently inside the results div.
			$('top_messagebox').set('text', '');
			//Inject the new DOM elements into the results div.
			$('top_messagebox').adopt(html);
			
		},
		//Our request will most likely succeed, but just in case, we'll add an
		//onFailure method which will let the user know what happened.
		onFailure: function() {
			$('chat').set('top_messagebox', '_');
		}
	});
	
	var refresh = function(){
		
		this.send();
	};
	
	refresh.periodical(10000,req);

});
