'use strict';
var play;
var title;
var helper;
var bg;
var sponsors;
var definicja;
var definicja_audio;
var definicja_audio2;
var inDefinition;
var definition_text;
Game1.Menu = function() {};
	Game1.Menu.prototype = {
		create: function() {   
		inDefinition = 0;     
		var style = { font: '70px Arial', fill: '#0080ca', align: 'center'};
		bg = this.game.add.sprite(0, 0, 'bg');    
		sponsors = this.game.add.sprite(0,458*2,'sponsors');
		title = this.game.add.sprite(422, 158, 'title');
		helper = this.game.add.sprite(1366, 430, 'pomocnik');
		play = this.game.add.sprite(488,630,'play_button');
		play.inputEnabled =true;
		play.name = "play";
		play.events.onInputOver.add(this.over,this);
		play.events.onInputDown.add(this.down, this);
		play.events.onInputOut.add(this.out,this);
		play.inputEnabled = true;
		play.animations.add('off',[0], true);
		play.animations.add('on',[1], true);     
	},  
	showDefinition: function () {
		inDefinition = 1;
		play.inputEnabled = false;
		definicja_audio.play();
		this.guiHelp = this.game.add.sprite(1210, 350, 'guiPomocnik_good');
		this.guiHelp.fixedToCamera = true;
		this.guiBubble = this.game.add.sprite(95, 96, 'Finish');
		this.guiBubble.scale.setTo(1.3,1.3); 
		this.guiBubble.fixedToCamera = true;
		definition_text.fixedToCamera = true;   
    },
    hideDefinition: function () {
		inDefinition = false;
        play.inputEnabled = true;
        definicja.inputEnabled = true;
        this.guiHelp.visible = false;
        this.guiBubble.visible = false;
        definition_text.visible = false;
    },  
	onInputOver: function(sprite, pointer){
	},
	down: function(sprite, pointer) {
		if (sprite.name == 'play'){
			this.game.state.start('Game');
		}
		else
		{
			this.showDefinition();  
		}
	},      
	over: function(sprite, pointer) {
		play.animations.play('on',1,true,false);
		if (!this.game.device.desktop)
			this.game.state.start('Game');
	},
	out: function(sprite, pointer) {
		play.animations.play('off',1,true,false);
	},
    update: function() {
    },
	actionOnClick: function() {
		this.game.state.start('Game');
	}
};