'use strict';
var play_1;
var play_2;
var play_3;
var play_4;
var play_5;
var title;
var helper;
var bg;
var sponsors;
Game1.Menu = function () {};

Game1.Menu.prototype = {

    create: function () {
        var style = {
            font: '70px Arial',
            fill: '#0080ca',
            align: 'center'
        };
        bg = this.game.add.sprite(0, 0, 'bg');
        bg.scale.setTo(1 / 2, 1 / 2);
        sponsors = this.game.add.sprite(0, 458, 'sponsors');
        sponsors.scale.setTo(1 / 2, 1 / 2);
        //this.sprite.anchor.setTo(0.5, 0.5);
        //this.sprite.scale.setTo(0.9,0.9);

        title = this.game.add.sprite(435 / 2, 158 / 2, 'title');
        title.scale.setTo(1 / 2, 1 / 2);
        helper = this.game.add.sprite(1310 / 2, 415 / 2, 'pomocnik');
        helper.scale.setTo(1 / 2, 1 / 2);
        //this.sprite.anchor.setTo(0.5, 0.5);

        //var button = new Phaser.Button(this.game,1302,516,'play_button', this.buttonCallback, this, 1,0,2);
        play_1 = this.game.add.sprite(446 / 2, 686 / 2, 'play_1');
        play_1.inputEnabled = true;
        play_1.name = "play_1";
        play_1.events.onInputOver.add(this.over, this);
        play_1.events.onInputDown.add(this.down, this);
        play_1.events.onInputOut.add(this.out, this);
        // play = this.game.add.button(446/2,686/2,'play_button', this.actionOnClick, this,'','','');
        play_1.scale.setTo(1 / 2, 1 / 2);
        // play.onInputOver.add(1, this);
        //  play.onInputOut.add(2,this);

        //play =  this.game.add.sprite(446, 686, 'play_button');
        play_1.inputEnabled = true;
        play_1.animations.add('off', [0], true);
        play_1.animations.add('on', [1], true);

        play_2 = this.game.add.sprite(646 / 2, 686 / 2, 'play_2');
        play_2.inputEnabled = true;
        play_2.name = "play_2";
        play_2.events.onInputOver.add(this.over, this);
        play_2.events.onInputDown.add(this.down, this);
        play_2.events.onInputOut.add(this.out, this);
        // play = this.game.add.button(446/2,686/2,'play_button', this.actionOnClick, this,'','','');
        play_2.scale.setTo(1 / 2, 1 / 2);
        // play.onInputOver.add(1, this);
        //  play.onInputOut.add(2,this);

        //play =  this.game.add.sprite(446, 686, 'play_button');
        play_2.inputEnabled = true;
        play_2.animations.add('off', [0], true);
        play_2.animations.add('on', [1], true);
        play_3 = this.game.add.sprite(846 / 2, 686 / 2, 'play_3');
        play_3.inputEnabled = true;
        play_3.name = "play_3";
        play_3.events.onInputOver.add(this.over, this);
        play_3.events.onInputDown.add(this.down, this);
        play_3.events.onInputOut.add(this.out, this);
        // play = this.game.add.button(446/2,686/2,'play_button', this.actionOnClick, this,'','','');
        play_3.scale.setTo(1 / 2, 1 / 2);
        // play.onInputOver.add(1, this);
        //  play.onInputOut.add(2,this);

        //play =  this.game.add.sprite(446, 686, 'play_button');
        play_3.inputEnabled = true;
        play_3.animations.add('off', [0], true);
        play_3.animations.add('on', [1], true);
        play_4 = this.game.add.sprite(1046 / 2, 686 / 2, 'play_4');
        play_4.inputEnabled = true;
        play_4.name = "play_4";
        play_4.events.onInputOver.add(this.over, this);
        play_4.events.onInputDown.add(this.down, this);
        play_4.events.onInputOut.add(this.out, this);
        // play = this.game.add.button(446/2,686/2,'play_button', this.actionOnClick, this,'','','');
        play_4.scale.setTo(1 / 2, 1 / 2);
        // play.onInputOver.add(1, this);
        //  play.onInputOut.add(2,this);

        //play =  this.game.add.sprite(446, 686, 'play_button');
        play_4.inputEnabled = true;
        play_4.animations.add('off', [0], true);
        play_4.animations.add('on', [1], true);
        play_5 = this.game.add.sprite(1246 / 2, 686 / 2, 'play_5');
        play_5.inputEnabled = true;
        play_5.name = "play_5";
        play_5.events.onInputOver.add(this.over, this);
        play_5.events.onInputDown.add(this.down, this);
        play_5.events.onInputOut.add(this.out, this);
        // play = this.game.add.button(446/2,686/2,'play_button', this.actionOnClick, this,'','','');
        play_5.scale.setTo(1 / 2, 1 / 2);
        // play.onInputOver.add(1, this);
        //  play.onInputOut.add(2,this);

        //play =  this.game.add.sprite(446, 686, 'play_button');
        play_5.inputEnabled = true;
        play_5.animations.add('off', [0], true);
        play_5.animations.add('on', [1], true);
    },
    onInputOver: function (sprite, pointer) {

    },
    down: function (sprite, pointer) {
        if (sprite.name == "play_1") {
            this.game.state.start('Game1');
        }
        if (sprite.name == "play_2") {
            this.game.state.start('Game2');
        }
        if (sprite.name == "play_3") {
            this.game.state.start('Game3');
        }
        if (sprite.name == "play_4") {
            this.game.state.start('Game4');
        }
        if (sprite.name == "play_5") {
            this.game.state.start('Game5');
        }
        //console.log('button down: '+sprite.name);
    },
    over: function (sprite, pointer) {
        sprite.animations.play('on', 1, true, false);
        console.log('button over' + sprite.name);
        if (!this.game.device.desktop)
            this.game.state.start('Game');
    },

    out: function (sprite, pointer) {
        sprite.animations.play('off', 1, true, false);
        // console.log('button out'+sprite.name);
    },
    update: function () {},

    actionOnClick: function () {
        this.game.state.start('Game');

    }
};