//  @import com.hedgehoglab.application.view.BaseView;

function UserActionsView(scope){
	BaseView.call(this,scope);
	var _this=this;
	var _last_state=null;
	
	this.set_state=function(state){
		//	Add the class, to put it into a state
		if(_last_state!=null){
			$('.PropertyPane',scope.element).removeClass(_last_state);
		}
		$('.PropertyPane',scope.element).addClass(state);
		
		_last_state=state;
	};
	
	this.disable_action=function(action_id,message){
		var el=$("#"+action_id,scope.element);
		$('a',el).attr('disabled',"disabled");
		if(message){
			$('a',el).attr('title',message);
		}else{
			$('a',el).attr('title',"");
		}
		$('a',el).addClass('disabled');
	};
	
	this.enable_action=function(action_id,message){
		var el=$("#"+action_id,scope.element);
		if(message){
			$('a',el).attr('title',message);
		}else{
			$('a',el).attr('title',"");
		}
		$('a',el).removeAttr('disabled',"disabled");
		$('a',el).removeClass('disabled');
	};
	
	this.set_toggle=function(action_id,state){
		var el=$("#"+action_id,scope.element);
		var rel=el.attr('rel').split(":");
		if(state){
			$('a',el).html(rel[1]);
		}else{
			$('a',el).html(rel[2]);
		}
	};
	
	
	if(scope.state) _this.set_state(scope.state);
	$('.PropertyPane li.hide',scope.element).removeClass('hide');
	
	$('.PropertyPane li a').bind('click',function(e){
		if($(this).attr('disabled')=='disabled'){
			
		}else{
			var rel=$(this).parent().attr('rel')
			if(rel) rel=rel.split(":");
			_this.raise_event('on_action_clicked',{action_id:$(this).parent().attr('id'),update:function(state){
				//	When update is called handle the 
			}});
			
		}
		return false;
	});
	
	function handle_toggle(element,rel,state){
		if(state){
			element.html(rel[2]);
		}else{
			element.html(rel[1]);
		}
	}
}