var fitInQuiz = {
	"production" : {
		"none" : {
			"answers" : [
				{
					"text" : "Then you've come to the right place. Check out our Apprenticeship and intern schemes, where you'll find all you need to know about getting started in TV",
					"link" : "/work-experience-and-apprenticeships"
				},
				{
					"text" : "Or, if you've got more enthusiasm and energy than you know what to do with, you might make a splash in our Runners pool.",
					"link" : "/working-here/itv-studios/runners"
				},
				{
					"text" : "If your talents include an ability to track down every last scrap of information, a keen eye for detail and an all-or-nothing approach, we need you to make sure our programmes are always accurate as a Researcher.",
					"link" : "/working-here/itv-studios/researchers"
				},
				{
					"text" : "And if you know a good story when you see one and have the drive to write, film and present them to millions of people every night, you'll fit right in on one of our busy regional newsrooms as a News Trainee.",
					"link" : "/working-here/news/news-trainee"
				}
			]
		},
		"medium" : {
			"answers" : [
				{
					"text" : "If you know your figures, work logically and methodically, and have organisational skills that could organise a small army, you might fit in as a Production Assistant.",
					"link" : "/working-here/itv-studios"
				},
				{
					"text" : "And we're always on the look-out for people who know how to lead, motivate and manage our talented teams. So if you're a people manager extraordinaire, see what we've got on offer right now.",
					"link" : "https://itv.taleo.net/careersection/2/jobdetail.ftl?lang=en&job=11808"
				}
			]
		},
		"high" : {
			"answers" : [
				{
					"text" : "You'll be right at home in our Studios. They produce content everyday - from one-off programmes to whole series, live TV to cutting edge documentaries.",
					"link" : "/working-here/itv-studios"
				},
				{
					"text" : "In fact, if live TV is your bag, you could consider a move into News. We're always looking for great all-rounders who are keen to write, shoot and edit the stories that matter.",
					"link" : "/working-here/news"
				}
			]
		}
	},
	"supporting" : {
		"none" : {
			"answers" : [
				{
					"text" : "Chances are one of our great Internships or Apprenticeship schemes will suit you down to the ground.",
					"link" : "/work-experience-and-apprenticeships"
				},
				{
					"text" : "We also offer a wide variety of office support roles. There's sure to be one that matches your personality and skill set.",
					"link" : "https://itv.taleo.net/careersection/2/jobdetail.ftl"
				}
			]
		},
		"medium" : {
			"answers" : [
				{
					"text" : "If that experience has helped you develop a sharp eye for detail and flawless data entry skills - whatever pressures you're under - we could have the ideal role for you in Business Delivery.",
					"link" : "/working-here/technology-and-business-delivery"
				},
				{
					"text" : "But if Admin is your forte or you've picked up the sort of skills that would be welcome anywhere, have a look on our Job Search &amp; Apply page to see where you could fit in.",
					"link" : "https://itv.taleo.net/careersection/2/jobdetail.ftl?lang=en&job=11909"
				}
			]
		},
		"high" : {
			"answers" : [
				{
					"text" : "Legal - If you're a qualified lawyer ready to handle contracts on Corrie or mergers and acquisitions on our central legal team, then Legal is the place for you.",
					"link" : "/working-here/corporate-business-support#legal"
				},
				{
					"text" : "Finance - And whether you're a certified accountant or an experienced analyst, we've got Finance opportunities up and down the country that will make the most of your head for figures.",
					"link" : "/working-here/corporate-business-support#Finance"
				},
				{
					"text" : "PR - Communications - If you're a dab hand at keeping the press posted and are ready to promote programmes and share our success, you'll be right at home with the rest of the PR &amp; Communications team.",
					"link" : "/working-here/corporate-business-support#Comms"
				},
				{
					"text" : "Marketing - If you know how to boost brands and grow audiences on the scale we require, you should join the rest of our Marketing experts in Corporate Services.",
					"link" : "/working-here/marketing-and-research"
				},
				{
					"text" : "Research - But if you're more interested in the why of things, there's a place for someone of your talent in Research &amp; Development.",
					"link" : "/working-here/marketing-and-research"
				},
				{
					"text" : "HR - If you're a people person who knows your TUPE from your ET3s and your P45s from your Pensions, you'll hit the ground running in HR.",
					"link" : "/working-here/corporate-business-support#HR"
				},
				{
					"text" : "Technology - If you're multi-talented on multiple platforms and are ready to put your technical know-how to the test, there's no better place than our Technology, Platforms &amp; Business Delivery team.",
					"link" : "/working-here/technology-and-business-delivery"
				},
				{
					"text" : "Creative/Design - If you've got the creative flair or design talent it takes to get people talking, we want to hear from you.",
					"link" : "/working-here/marketing-and-research"
				},
				{
					"text" : "Other - If you've got this far, you're either one of a kind, none of the above or are just having trouble narrowing it down. We don't blame you - there's a lot to choose from. See all the options on our Job Search &amp; Apply page.",
					"link" : "https://itv.taleo.net/careersection/2/jobsearch.ftl?lang=en"
				}
			]
		}
	}
}

function resetQuiz() {
	$('#whereWouldYouFitInQuiz').data('route', '');
	$('#whereWouldYouFitInQuiz').data('experience', '');

	$('.highlightedRoute').removeClass('highlightedRoute');
	$('.highlightedExp').removeClass('highlightedExp');
	
	$('#fitInIntroduction').show();
	$('#fitInIntroduction *').show();
	
	$('#question2').hide();
	$('#fitInAnswers').hide();
	$('#fitInAnswers .panelInner').html('');
}

function loadAnswers() {
	var selectedRoute = $('#whereWouldYouFitInQuiz').data('route');
	var selectedExperience = $('#whereWouldYouFitInQuiz').data('experience');
	var answers = fitInQuiz[selectedRoute][selectedExperience].answers;
	var answerHTML = '<ul>';
	$.each(answers, function(k, answer) {
		if (k == answers.length - 1) {
			answerHTML += '<li class="last">';
		}
		else {
			answerHTML += '<li>';
		}
		answerHTML += '<a href="'+answer.link+'">'+answer.text+'</a></li>';
	});
	answerHTML += '</ul>';
	$('#fitInAnswers .panelInner').html(answerHTML);
	if (!$('#fitInAnswers').is(':visible')) {
		$('#fitInAnswers').slideDown();
	}
}

$(function() {
	$('#whereWouldYouFitInQuiz').data('route', '');
	$('#whereWouldYouFitInQuiz').data('experience', '');
	
	$('#routeAnswer a').bind('click', function() {
		if (!$(this).is('.highlightedRoute')) {
			$('.highlightedRoute').removeClass('highlightedRoute');
			$('.highlightedExp').removeClass('highlightedExp');
			$(this).addClass('highlightedRoute');
			
			$('#whereWouldYouFitInQuiz').data('route', $(this).attr('rel'));
			
			$('#fitInIntroduction *').fadeOut();
			$('#fitInIntroduction').slideUp();
			
			$('#question2').slideDown();
			//reset the experience question when clicking back here
			$('#whereWouldYouFitInQuiz').data('experience', '');
			$('#fitInAnswers').slideUp('normal', function() {
				$('#fitInAnswers .panelInner').html('');
			});
		}
	});
	
	$('#experienceAnswer a').bind('click', function() {
		if (!$(this).is('.highlightedExp')) {
			$('.highlightedExp').removeClass('highlightedExp');
			$(this).addClass('highlightedExp');
			$('#whereWouldYouFitInQuiz').data('experience', $(this).attr('rel'));
			loadAnswers();
		}
	});
});
