﻿
var Tour = {

    config: [
        { image: 'main.jpg', text: 'Добро пожаловать в Ravensteel! Единственную настоящую тактическую игру в браузере!' },
        { image: 'shop.jpg', text: 'Покупай боевые машины, оружие и устройства и...' },
        { image: 'hangar.jpg', text: '... собирай эффективные конфигурации боевых машин' },
        { image: 'barracks.jpg', text: 'Нанимай и обучай пилотов и пусть они внушают страх в сердца врагов!' },
        { image: 'modules.jpg', text: 'Улучшай свой космический корабль, делая его быстрее, мощнее, эффективнее!' },
        { image: 'space.jpg', text: 'Летай по галактике, добывай ресурсы и захватывай вражеские планеты... ' },
        { image: 'quests.jpg', text: '... выполни сотню уникальных заданий и бесчисленное множество тактических битв ...' },
        { image: 'combat.jpg', text: '... в мире &quot;Ravensteel&quot;' }
    ],

    start: function() {
        //hide start div
        $("contentMain").hide();

        //        var offset = $('tourBtnStart').cumulativeOffset();
        //        $("tourTable").style.left = Math.round(offset[0] + ($('tourBtnStart').getWidth() - $("tourTable").getWidth()) / 2) + "px";
        //        $("tourTable").style.top = offset[1] - 50+"px";

        //show tour div
        $("tourTable").show();

        this.stepIdx = 0;
        this._step();
    },

    stop: function() {
        //hide start div
        $("contentMain").show();
        //show tour div
        $("tourTable").hide();
    },

    play: function(dir) {
        this.stepIdx += dir;
        if (this.stepIdx >= this.config.length) {
            window.location.href = "register.aspx";
            return;
        }
        else if (this.stepIdx < 0) {
            this.stop();
        }
        this._step();
    },

    _step: function() {
        this.stepIdx = Math.max(0, Math.min(this.stepIdx, this.config.length - 1));

        var data = this.config[this.stepIdx];

        $("tourImage").src = "site/tour/" + data.image;
        //$("tourTitle").update(data.title);
        $("tourText").update(data.text);

        if (this.stepIdx == this.config.length - 1) {
            $("tourBtnNext").update("РЕГИСТРАЦИЯ");
        }
        else {
            $("tourBtnNext").update("продолжить &gt;&gt;");
        }
    }

}
