var Anticlicker = cc.Layer.extend({
	_background:null,
	_clickCounter:0,
	_deltaFrame:0,
	_deltaFrameUpdate:0,
	_listener:null,
	
	ctor:function () {
		this._super();
		
		this._background = new cc.Sprite(res.anticlicker_png);
		this._background.setVisible(false);
		this._background.attr({
			x:0,
			y:0,
			anchorX:0,
			anchorY:0,
		})
		this.addChild(this._background, BACKGROUND);
	},
	
	performBlock:function(){
		cc.audioEngine.playEffect(res.anticlicker_mp3);		
	
		
		this._background.setVisible(true);
		
		GameManager.getInstance().setGameState(SS.GAME_STATE.FROZEN);
		
		cc.director.getScheduler().scheduleCallbackForTarget(this, this.unblock, 0, 0, 5, false);	
	},
	
	unblock:function(){
		this._background.setVisible(false);
		GameManager.getInstance().setGameState(SS.GAME_STATE.PLAYING);
	},
	
	
	checkClick:function(flag){
		var df = cc.director.getTotalFrames();
		if(flag || df - this._deltaFrame >= ANTICLICKER_TIME_BETWEEN_CLICKS && this._deltaFrame)
			this._clickCounter = 0;
		else{
			this._clickCounter++;
		}
		if(this._clickCounter>= ANTICLICKER_CLICKS_COUNT){	
			this.performBlock();
		}
		this._deltaFrame = df;			
	}
});
