function Forum(ob) {
	this.main = ob;
	this.topics = new Array();
	this.generateFunc = undefined;
	this.setGenerateFunction = function(func) {
		this.generateFunc = func;
	}
	this.addTopic = function(topic) {
		var found = false;
		for (i in this.topics) {
			if (this.topics[i].id === topic.id) {
				this.topics[i] = topic;
				found = true;
			}
		}
		if (!found) {
			this.topics.push(topic);
		}
		if (this.generateFunc !== undefined) {
			this.generateFunc(this.topics);
		}
	}
	this.getTopics = function() {
		return this.topics;
	}
	this.updateTopics = function () {
		$.ajax({
			url: "site-engines/forum/get-topics.php",
			context: this,
			success: function (data) {
			var response = jQuery.parseJSON(data+"");
			if (response.state !== undefined) {
					for(i in response.topics) {
						this.addTopic(response.topics[i]);
					}
			} else {
				alert("Fail: state not set");
			}
			}
		});
	}
	this.updateTopics();
}
