﻿var randomsentence 			= new Array(2);
randomsentence[0] 			= new Array("","Sometimes","I think","Oh yeah, right,","Because","Well,");
randomsentence[1] 			= new Array("you can","you don't","that'll be","my wife","the government");
randomsentence[1]['x']		= new Array(0,0,0,1,1);
randomsentence[2]				= new Array();
randomsentence[2][0] 			= new Array("use","do","want","pay","nice");
randomsentence[2][1] 			= new Array("uses","does","wants","pays","nice");
randomsentence[3] 			= new Array("more attention","it in the same way","to know","a lot more for that information","the method for free");
var randomlevel				= new Array();
randomlevel[1]				= new Array('0,1,2,3,4','0,1,2,3,4','0,1,2,3,4','0,1,2,3,4','0,1,2,3,4','0,1,2,3,4');
randomlevel[2]				= new Array('0,1,3','0,1,2,3','4','0,1,2,3','0,1,2,3');
randomlevel[3]				= new Array('0,1,4','1','0,1,2,3,4','0,2,3','2');

function printanswer(fi) {
answer				= new Array();
rand				= new Array();
list				= new Array();
option				= new Array();

list[0]				= new Array(0,1,2,3,4,5);
rand[0]				= Math.floor(Math.random() * list[0].length);
answer[0]			= randomsentence[0][rand[0]];
option[0]			= -1;
for (n=1;n<randomsentence.length;n++) {
	list[n]			= randomlevel[n][list[n-1][rand[n-1]]].split(',');
	rand[n]			= Math.floor(Math.random() * list[n].length);
	if (option[n-1] == -1) {
		x			= randomsentence[n][list[n][rand[n]]]; }
	else {
		x			= randomsentence[n][option[n-1]][list[n][rand[n]]];
		}
	if (answer[n-1]	== "") { 
		answer[n] 	= x.charAt(0).toUpperCase() + x.substr(1); 
		}
	else { 
		answer[n] 	= x; 
		}
	option[n]		= -1;
	if (randomsentence[n]['x']) { option[n] = randomsentence[n]['x'][list[n][rand[n]]]; }
	}
MM_changeProp(fi,'','innerHTML',answer.join(" ") + '.','td');
}
