interface Templates {
	mobileLanding: Template;
}

Template.mobileLanding.onRendered(function() {
	this.setVar('answer', 'missing');
	this.setVar('activeSlide', 0);
});

Template.mobileLanding.helpers({

	questions: function() {
		return [
			{
				question: 'WHERE WILL EURO 2016 BE HELD?',
				answers: [
					{
						name: 'France',
						correct: 'true',
						icon: 'France-icon',
					},
					{
						name: 'Germany',
						correct: 'false',
						icon: 'Germany-icon'
					}
				]
			},
			{
				question: 'WHO WON LAST EURO 2012 TOURNAMENT?',
				answers: [
					{
						name: 'Brazil',
						correct: 'false',
						icon: 'Brazil-icon'
					},
					{
						name: 'Spain',
						correct: 'true',
						icon: 'Spain-icon'
					}
				]
			},
			{
				question: 'This site is about:',
				answers: [
					{
						name: 'Sports Betting',
						correct: 'true',
						icon: 'sportsBet'
					},
					{
						name: 'Hot Chicks',
						correct: 'false',
						icon: 'hotChick'
					}
				]
			}
		];
	},

	landingRegistrationComplete: function() {
		return Session.get('landingRegistrationComplete');
	}

});

Template.mobileLanding.events({

	'click .item a': function() {
		var tpl = Template.instance();
		var activeSlide = tpl.getVar('activeSlide');
		tpl.setVar('current', this.name);

		if (this.correct == 'true') {
			tpl.setVar('answer', 'correct');
			if (activeSlide < 2) {
				tpl.setVar('activeSlide', (activeSlide + 1));
			}
			else {
				Pages.redirect('/landing-register');
			}
		}
		if (this.correct == 'false') {
			tpl.setVar('answer', 'incorrect');
		}
	}

});