function TagController()
{
	this.reqWidgetQueue= new Array();//queue with the widgets that made a request through this controller object
	var self=this;
	this.localWidgetReff = null;
	this.ref=null;
	this.ref_err=null;
	this.applytag=function(link_id,tags)
	{
		this.ref=link_id;
		this.ref_err=document.getElementById('mesaj_err_tag');
		var rqid=RequestManager.getInstance().createRequest(TagController.getInstance(),URL+"index.php?page=tag&action=add&link_id="+link_id+'&tag='+tags);
		RequestManager.getInstance().startRequest(rqid);
	}
	/**
	 * @param The manager index of the request 
	 * @desc This method is a handler for the completition of one request
	 */
	this.handleResponse=function (managerIndex)
	{	
		this.ref_err.innerHTML="";
		var respContent=RequestManager.getInstance().getRequestObj(managerIndex).getResponseContent();
		
		result=eval(respContent);
		this.ref_err.innerHTML=result[0]['value'];
		if(result[0]['text']=='ok')
		{
			document.getElementById('tags_nr').innerHTML=result[1]['value'];
			//call to get list of tags and to refresh existing tag list
			RequestManager.getInstance().createRequest(TagListController.getInstance().getTagList(this.ref));
		}
		return true;					
	}
}

TagController.__instance__=null;

TagController.getInstance=function()
{
	if(TagController.__instance__==null)
	{
		TagController.__instance__=new TagController();
	}
	return TagController.__instance__;
}
