function SocialSearchApp() {
	this.tagCloud = new TagCloud($("#popular_tagcloud"),"","");
	SocialSearchApp.baseConstructor.call(this, $("#searchComponent"), new ALOEServiceConnector(this)); 
		
	this.componentController.register(this.tagCloud);
	// second init call, could be done smarter probably
	this.componentController.init();
}

SocialSearchApp.extend(PagedSearch);

SocialSearchApp.prototype.getSubscriptionEvents=function(){
	return [new SubscriptionEvent("tagSelect", this.onTagSelect)];
}

SocialSearchApp.prototype.onTagSelect=function(type, args){
	$tagElem=args[0];
	console.log("SocialSearchApp.onTagSelect ", $tagElem);
	if($tagElem.hasClass("selected")){
		// click on selected item
		this.doTermSearch("");
	} else {
		// click on not selected item
		this.doTermSearch($tagElem.text());
	}
}
	
SocialSearchApp.prototype.initDOMElems = function(){
	SocialSearchApp.superClass.initDOMElems.call(this);
	this.$searchForm=$("#keywordSearchForm");
	this.$keywordInputField=$("#searchBox");

	var _this = this;
	this.$searchForm.submit(
		function(){
			_this.doTermSearch(_this.$keywordInputField.val());
			return false;
		}
	);
}

SocialSearchApp.prototype.onStateChange=function(event){	
	SocialSearchApp.superClass.onStateChange.call(this, event);
	console.log("SocialSearchApp.onStateChange");
	this.tagCloud.selectTagsByNames(this.query.constraints.searchTerm);
	this.$keywordInputField.val(this.query.constraints.searchTerm.join(" "));
}