
var HilitedUsers = Class.create();
HilitedUsers.prototype = {
	main : null,
	messages : null,
		
	initialize : function(main, messages){
		this.main = main;
		this.messages = messages;
	},
	
	getMessage : function(type, arg){
		var url = "";
		
		switch (type){
			case "static":
				url = "getMessages.php?type=user&user=" + arg + "&startOffset=0&amount=1";
				break;
			case "status":
				url = "getMostFrequentUserByStatus.php?status=" + arg;
				break;
			case "newestSwitcher":
				url = "getLastSwitcherByStatus.php?status=" + arg;
				break;
			case "lastQuitter":
				url = "getLastSwitcherByStatus.php?status=" + arg;
				break;
				
		}
		new Ajax.Request('app/' + url, 
			{
				method:'post', 
				//postBody:str,
				
				onSuccess: function(transport){
				  var response = transport.responseText || "no response text";
					if (response == "err"){
						//alert("post error");
					} else {
						var j = response.evalJSON();
						this.insertMessage(j[0], type);
					}
			    }.bind(this)
			}
		);
	},
	
	insertMessage : function(data, type){
//		alert("d=" + data.nick + "," + type + ",  this.main=" +  this.main);
		
		var title = this.messages.cutBanner(data.title);
		
		var s = this.main.getInclude("hilited_user", [data.nick, data.avatar, data.nick, title, data.description, data.link, data.status_id, status_names[data.status_id]]);
		new Insertion.Bottom($("hilited_users"), s);
	}
	

}



