// SCRIPT MUST FOLOW AFTER THE BOX CONTAINING THE QUESTIONS

//////////////////////////////
//  Trash or Fact section   //
//////////////////////////////

var currQuestion = Math.floor(Math.random()*10);  // generate random number between 0 and 9 (inclusive).
var questions = new Array;
var answers = new Array;
var nextQuesCode = "<a href='#' onclick=\'nextQues();return false;'>Next question.</a>";

questions[0] = 'You can recycle bubble wrap. ';  //TRASH	 [That's trash! You can't recycle bubble wrap.]
questions[1] = 'Each person in the United States uses about 749 pounds of paper every year. '; //	FACT
questions[2] = 'You can recycle magazines. '; //	FACT
questions[3] = 'Paper was first made in India. '; //	TRASH	//[That's trash! Paper was first made almost 2,000 years ago in China.]
questions[4] = 'Junk mail is unopened, unread and trashed 44 percent of the time. '; //		FACT
questions[5] = 'A piece of paper can only be recycled once. ';  // 	TRASH 	[That's trash! Paper can be recycled five to seven times.]
questions[6] = 'The paper grocery bag was invented in 1883.'; //		FACT
questions[7] = 'The world uses less paper now than it did 40 years ago. '; //	TRASH [That's trash! The world uses 400 percent more paper now than it did 40 years ago.]
questions[8] = 'There are more trees in the U.S. today than there were 75 years ago. '; //	FACT
questions[9] = 'Only half of the states in the U.S. have paper mills that recycle. '; //	TRASH 	[Forty-two of the 50 states have mills using recovered paper.]

// Factual answers should contain FACT in all caps
answers[0] = 'That\'s trash! You can\'t recycle bubble wrap. ';
answers[1] = 'FACT';
answers[2] = 'FACT';
answers[3] = 'That\'s trash! Paper was first made almost 2,000 years ago in China. ';
answers[4] = 'FACT';
answers[5] = 'That\'s trash! Paper can be recycled five to seven times. ';
answers[6] = 'FACT';
answers[7] = 'That\'s trash! The world uses 400 percent more paper now than it did 40 years ago. ';
answers[8] = 'FACT';
answers[9] = 'That\'s trash! Forty-two of the 50 states have mills using recovered paper. ';

// Display initial question to user 
document.getElementById('trashOrFactQues').innerHTML = questions[currQuestion];

function nextQues() { 
	currQuestion = Math.floor(Math.random()*10); 
	document.getElementById('trashOrFactQues').innerHTML = questions[currQuestion];
}

// Check answer given (supplied string arguments are FACT or TRASH)
function checkAnswer(answer) {
	
	if (answer == 'TRASH') {  // user pressed Trash
		if (answers[currQuestion] != "FACT") {
			//alert('That\'s correct! You\'re on your way to becoming a recycling pro!');
			document.getElementById('trashOrFactQues').innerHTML = 'That\'s correct! '+nextQuesCode;
		} else {
			//alert('Sorry, but that\'s incorrect.');
			document.getElementById('trashOrFactQues').innerHTML = 'Sorry, but that\'s incorrect. '+nextQuesCode;
		}
	} else {  // User pressed fact
		
		if (answers[currQuestion] == "FACT") {
			//alert('That\'s correct! You\'re on your way to becoming a recycling pro!');
			document.getElementById('trashOrFactQues').innerHTML = 'That\'s correct! '+nextQuesCode;
		} else {
			//alert(answers[currQuestion]);
			document.getElementById('trashOrFactQues').innerHTML = answers[currQuestion] + nextQuesCode;
		}
	
	}
	//nextQues();
} 


function swapImg(element, imgSrc) {document.getElementById(element).src = imgSrc;}


///////////////////////////////
// END TRASH OR FACT SECTION //
///////////////////////////////

