function buildArray(){
	//factsArr = [1,2,3,4,5];
	factsArr = [];	
	factsArrLength = $('.factoid').length;
	for (i=0 ; i<factsArrLength ; i++)
		factsArr[i] = i+1;
}

function chooseRandomFactoid(){
	return Math.ceil(Math.random()*factsArr.length);
}

function changeFactoid(){

	$('.factoid').hide();

	randomFactoid = chooseRandomFactoid();
	
	$('#Fact'+factsArr[randomFactoid-1]).show();
	
	factsArr.splice(randomFactoid-1, 1);
	
	if (factsArr.length == 0) buildArray();
	
}


$(document).ready(function() {

	$('#factoid-controls').show();

	// Redirect to the URL of the selected profession in the dropdown when the 'Go' button is clicked
	$('#btnProfessionSelector').click(function(){	
		window.location = $('#selectProfessionList').val();
	});
	
	$('a#factoid-prev').hide();
	$('.factoid').hide();

	$('a#factoid-next').click(function(){
		changeFactoid();
		return false;
	});
	
	buildArray();
	changeFactoid();
	
});