var questions = [
	[ "What is Jacob's last name?", [ "Cullen", "Swan", "Black", "Volturi" ]],
	[ "Bella moved from Phoenix, Arizona to Forks, _________.", [ "Nevada", "Washington", "Oregon", "Alaska" ]],
	[ "In sunlight, Edward's skin _______.", [ "Turns red", "Sparkles", "Burns", "Stays the same" ]],
	[ "Which Cullen family member turned Edward into a Vampire?", [ 'Esme', 'Carlisle', 'Jasper', 'None of them' ]],
	[ "Where do the Volturi live?", [ 'France', 'Italy', 'Canada' ]],
	[ "In the movie <i>New Moon</i>, Jane is played by actress Dakota Fanning.", [ 'True', 'False' ]],
	[ "At her 18th birthday party, Bella started to bleed from a cut on her _______.", [ 'Foot', 'Knee', 'Finger']],
	[ "Which book comes after New Moon?", [ 'Breaking Dawn', 'Eclipse', 'Midnight Sun' ]],
	[ "At the end of New Moon, Bella's wish comes true and she becomes a Vampire.", [ 'True', 'False' ]],
	[ "What is the name of the female Vampire that has been hunting Bella?", [ 'Laurent', 'Jane', 'Victoria', 'Alice' ]]
];
var quiz = {
	answers: '',
	show: function() {
		if (quiz.curQuestion > questions.length) {
			location.href='/tm3/registrationForm.jsp?answers='+quiz.answers;
			return;
		}
		var num = quiz.curQuestion;
		var q = questions[num - 1];
		quiz.s.num.text(num);
		quiz.s.question.html(q[0]);
		var html = '';
		for (a in q[1])
			html += '<div class="question_option" onClick="quiz.select(\''+a+'\')">'+q[1][a]+'</div>';
		quiz.s.answers.html(html);
		jQuery('#q_answers div.question_option')
			.mouseover(function() { jQuery(this).css({'background-color': '#E7A43E', 'color': '#000'}); })
			.mouseout(function() { jQuery(this).css({'background-color': '#000', 'color': '#fff'}); });
	},
	answer: function() {
		var answer = jQuery('input:checked', quiz.s.answers).val();
		if (answer == null)
			answer = 'x';
		quiz.select(answer);
	},
	select: function(answer) {
		quiz.answers += answer.charAt(0);
		quiz.curQuestion++;
		quiz.show();	
	},
	s: {
		question: null,
		num: null,
		answer: null
	},
	init: function() {
		quiz.s.question = jQuery('#q_question');
		quiz.s.num = jQuery('#q_num');
		quiz.s.answers = jQuery('#q_answers');
		quiz.show();	
	},
	curQuestion: 1
};

function ValidateForm() {
	if (jQuery('#operatorlist').val() <= 0) {
		alert("Please be sure to select your cell phone's carrier.");
		return false;
	}
	var phone = jQuery('#areacode').val() + jQuery('#prefix').val() + jQuery('#suffix').val();
	if ( /\d{10}/.test(phone) != true) {
		alert("Please enter a valid phone number");
		return false;
	}
	
	return true;
}

function ValidatePIN() {
	if (!jQuery('#signup_form_terms').attr('checked')) {
		alert("You must agree to the Terms and Conditions to sign up.");
		return false;
	}
	if (/^\d{4}$/.test(jQuery('#password').val()) != true) {
		alert("Please enter a valid 4-digit PIN number to proceed.");
		return false;
	}
	return true;
}

function nextField(obj,len,next) {
	if (obj.value.length >= len)
		jQuery('#'+next).focus();
}
function goStep(step) {
	jQuery('div.steps').hide();
	jQuery('#step'+step).show();
	if (step == 2) {
		var carrier = jQuery('#operatorlist').val();
//		alert(carrier);

		if (carrier == '31005' || carrier == '31009') {
			jQuery('#price').show();
		} else if (carrier == '31002') {
			jQuery('#price_att').show();
		} else {
			jQuery('#price').hide();
			jQuery('#tab3').html('Get Results to your Cell phone, $9.99/mo Text Subscription, 3 msg/wk.');
		}
	}
}

