////////////////////////////////////////////////////////////
////////////// ***     you could read this    *** //////////
////////////// *** but it would spoil the fun *** //////////
////////////////////////////////////////////////////////////

oldcount=0;
newword=false;
lastsuccess='';
midle='';
word=new Array();
oldword='';
veryoldword='';
jscounter=0;
fin_l='';
consecutive=0;
bad=true;
bad_string='';
first='When I encounter the word ';
second=', I am always reminded of ';
third='';
fourth=',<br></font>but what would be your response to the word ';
fifth='';



function bad_result() {

keyboard=true;
bad=true;
ancient=veryoldword;	
clearTimeout(cycletimer);
clearTimeout(scrolltimer);
helpscreen();
maintext=table_top+fontvalue+'<font size=+3><br><br></font><font class=denser><font class=denser><b><br><!/font><font color=#669900>'+(cycle?'consecutive entries:'+consecutive+'<br>':'')+'</font>';
cycle=false;
	if (newword) {
		bad_string='<table height='+(available_height-posit)+' width='+available_width+' border=0 cols=2><tr><td colspan=2 align=center valign=top height=1><font color=red>'+fontvalue+'<font size=+3><br><br></font><font class=denser><font class=denser><b><br><!/font><font color=#669900>'+(cycle?'consecutive entries:'+consecutive+'<br>':'')+'</font><font color=#669966>&laquo;&laquo; To remind you, you now have two choices &raquo;&raquo;</font></td></tr><tr><td valign=top align=center width='+available_width/2+'>'+fontvalue+'<br><b><font class=denser><font class=denser><font color=gold>If <font color=coral> "'+theword+'"</font> is not in common use, <font color=red><U>or in the plural</U>,</font><br>or in the wrong tense or spelt incorrectly then, as it does not fit our criteria:<br><br><a href=# onclick="deleter(); return false;"><font color=white><B>*** YOU MUST CANCEL YOUR ENTRY ***<br>*** BY CLICKING HERE ***</B></font></a></td><td valign=top align=center>'+fontvalue+'<br><b><font class=denser><font class=denser><font color=gold>Otherwise, if you are happy with <font color=coral>"'+ theword+'"</font>, then <font color=red>please retype this word to confirm your entry</font> and then press <font color=white>[enter],</font> or it will not be included in the database</font>';
		maintext=bad_string+'<font color=red>.</font>';
		}
		else {
		maintext=maintext+'<br>What would you say if I were to say <font color=white> "'+theword+'"</font> to you?';

	if (oldword!='') { maintext=maintext+'<br> (Please avoid using ' ; 
		if (veryoldword!='' && veryoldword!=oldword) { 
			maintext=maintext+'either the word <font color=orange>"'+veryoldword+'"</font> or ';} 
		maintext=maintext+'the word <font color=orange>"'+oldword+'".</font>)';} 
	}
maintext=maintext+'<br><font color=red><u>&raquo;</u><font color=white> ?</td></tr></table>';
destination=responseHTML;
magiccontents();
jscounter=oldcount;
counter=0;

	if (newword) {veryoldword=oldword;}
oldword=theword;
lastsuccess=theword;
bottom_control();
}


function query() {
clip_out(1);
clip_out(2);
clip_out(3);
clearTimeout(scrolltimer);
keyboard=false;
rnd2 = Math.round(19*Math.random());

	if (rnd2==0) {midle='Well?';}
	if (rnd2==1) {midle='Have you nothing to say?';}
	if (rnd2==2) {midle='I\'m waiting...';}
	if (rnd2==3) {midle='C\'mon, have a go.';}
	if (rnd2==4) {midle='Honestly, it\'s not as hard as you think.';}
	if (rnd2==5) {midle='In your own time.';}
	if (rnd2==6) {midle='I\'m ready when you are...';}
	if (rnd2==7) {midle='Don\'t be shy - I won\'t bite.';}
	if (rnd2==8) {midle='When you\'re quite ready.';}
	if (rnd2==9) {midle='Cat got your tongue?';}
	if (rnd2==10) {midle='I need your input.';}
	if (rnd2==11) {midle='C\'mon, think dammit!';}
	if (rnd2==12) {midle='I don\'t want to be pushy, but an answer would be nice.';}
	if (rnd2==13) {midle='It\'s gone very quiet at your end.';}
	if (rnd2==14) {midle='What\'s keeping you?';}
	if (rnd2==15 && jscounter>1) {midle='You can use <font color=gold>[F2]</font> to select one of '+jscounter+' alternatives for : <font color=coral>"'+veryoldword+'"</font> or<br>submit <font color=coral>"'+oldword+'"</font> by pressing <font color=gold>[F7]</font>';}
	if (rnd2==16) {midle='So far you have created <br><font color=gold>'+newentry+'</font> new entries and <font color=gold>'+connections+'</font> new connections in the database.<br>There have been <font color=gold>'+consecutive+'</font> connections in this thread.';}
	if (rnd2==17) {midle='Just place your fingers on your keyboard and type - it\'s easy!';}
	if (rnd2==18) {midle='Hello?<br>Is there some sort of problem at your end?';}
	if (oldword=='') {midle='Just about anything will get you started.';}

maintext=table_top+infostring+'<BR><font color=gold>'+midle+'</font><br>&nbsp;</td></tr></table>';
destination=responseHTML;
magiccontents();
bottomLyr.visibility="hidden";

	if (!cycle) {scrolltimer = setTimeout("onscreen()", 2500);}
}


function query1() {
maintext=table_top+infostring+'To remind you, first there was <font color=white>'+veryoldword+'</font> and then there was <font color=white>'+lastsuccess+',</font><br>pray continue...</td></tr></table>';
destination=responseHTML;
	if (veryoldword!='') {magiccontents();}
scrolltimer = setTimeout("query()", 30000);
}
	

function output(val) {
keyboard=true;
info_string();

	if (val==1) {
		keyboard=false;
		maintext=table_top+infostring+'<font color=#669900>Thank you for your answer.</font><br>Please wait for a moment while I think of a reply for <font color=gold>"' +theword+'..."</font><br>'+(cycle?'</B><font size=-1><font color=firebrick>[chase mode]</font></font><B>':'')+'&nbsp;</td></tr></table>';}

	if (val==2) {maintext=table_top+infostring+'<font color=#669900>I am unable to accept this word - it contains an expletive.</font><br>Please refrain from using such language and try something a bit cleaner...<br><font color=red><u>&raquo;</u><font color=white> ?</td></tr></table>';}

	if (val==3) {maintext=table_top+infostring+'Obviously, I can\'t accept <font color=white>"'+theword+'"</font> in response to <font color=white>"'+oldword+'",</font><br>please reconsider...<br><font color=red><u>&raquo;</u><font color=white> ?</td></tr></table>';} 

	if (val==4) {maintext=table_top+infostring+(ancient&&ancient!=veryoldword?'Both <font color=white>"'+ancient+'"</font> and ':'')+'<font color=white>"'+veryoldword+'"</font> '+(ancient?'have':'has') +' just been used.<br>I need an alternative answer for <font color=white>"'+lastsuccess+'",</font> please try again...<br><font color=red><u>&raquo;</u><font color=white> ?</td></tr></table>';}

	if (val==5) {
		newentry=newentry-1;
		newword=false;
		maintext=table_top+infostring+'<br>Try another response to <font color=white>"'+veryoldword+'"</font> <br><font color=red><u>&raquo;</u><font color=white> ?</td></tr></table>';
		oldword=veryoldword;
		veryoldword=ancient;
		ancient=lastsuccess;
		lastsuccess=oldword;}

	if (val==6) {
		consecutive=consecutive+1;
		oldcount=jscounter;
		big_value();
		bad=false;
		if (lil_counter==0) {
			rnd = Math.round((jscounter-1)*Math.random());
			rnd=rnd+1;
			rnd=parseInt(rnd);
			fin_l=word[rnd];}
		else
		{	fin_l=word[lil_counter];}

	info_string();

	var rndm = Math.round(8*Math.random());
	if (rndm==0) {first='I believe ';second=' is not unrelated to ';third='';}
	if (rndm==1) {first='The word ';second=' can sometimes be associated with ';third='';}
	if (rndm==2) {first='Hmm, I find the relationship between ';second=' and ';third=' interesting';}
	if (rndm==3) {first='There is an acceptable connection between ';second=' and ';third='';}
	if (rndm==4) {first='There\'s no denying a link between ';second=' and ';third='';}
	if (rndm==5) {first='There is a reasonable correlation between ';second=' and ';third='';}
	if (rndm==6) {first='If I think of ';second=', ';third=' comes to mind';}
	if (rndm==7) {first='When considering ';second=', I think of ';third='';}
	if (rndm==8) {first='When I encounter the word ';second=', I am always reminded of ';third='';}

	var rndm = Math.round(8*Math.random());
	if (rndm==0) {fourth=',<br></font>but what does ';fifth=' say to you';}
	if (rndm==1) {fourth=',<br></font>but what comes to mind when you think of ';fifth='';}
	if (rndm==2) {fourth=',<br></font>but can you think of something else related to ';fifth='';}
	if (rndm==3) {fourth=',<br></font>but can you suggest another word that ties in with ';fifth='';}
	if (rndm==4) {fourth=',<br></font>but what else would you associate with ';fifth='';}
	if (rndm==5) {fourth=',<br></font>but what else does ';fifth=' suggest to you';}
	if (rndm==6) {fourth='<br></font>but, if I were to say ';fifth=' to you, what would you think of';}
	if (rndm==7) {fourth=',<br></font>what do you think of when you see the word ';fifth='';}
	if (rndm==8) {fourth=',<br></font>but what would be your response to the word ';fifth='';}

	veryoldword=theword;
	lastsuccess=fin_l;
	oldword=fin_l;
	newword=false;
	onscreen();
	if (nu_connection) {nu_connection=false;bottom_control();helpscreen();}
	if (!fullhelp) {helpscreen();}
	}

//i have a fairly sizeable vocabulary, but unfortunately it does not contain this word

	if (val==7) {maintext=table_top+infostring+'<font color=#669900>Sorry, but I\'m afraid that you have to start the session with a word that I can recognise. However, as I possess a constantly growing vocabulary, this should not pose too much of a problem, so please try again...<br><font color=red><u>&raquo;</u><font color=white> ?</td></tr></table>';}

	if (val==9) {maintext=table_top+infostring+'<font color=#669900>New entry confirmed.</font><br><br>I now require a new association for '+theword+':<br><font color=red><u>&raquo;</u><font color=white> ?</td></tr></table>';}

	if (val==10) {maintext=table_top+fontvalue+'<br><font class="denser"><font class="denser"><font class="denser"><font color=white><b>The backspace button resets the entire game.<br><br>In future, please use the DELETE key to amend your entry.<br><br>The page is now reloading - please wait...</td></tr></table>';}

	if (val==12) {maintext=table_top+infostring+'<font color=gold>I am having problems recognising the word <font color=white>"'+theword+'"</font>.<br>Please check your spelling'+(lastsuccess!=''?', or think of another response to <font color=white>"'+lastsuccess+'"</font>:':' and try again.')+'<br><font color=red><u>&raquo;</u><font color=white> ?</td></tr></table>';}

	if(val!=1&&val!=10) {clearTimeout(scrolltimer);counter=0;scrolltimer = setTimeout("query()",25000);}
	else{
	bottomLyr.visibility="hidden";streamLyr.visibility="hidden";}

	if (val!=6) {destination=responseHTML;magiccontents();}

}

function reset_stream() {sumtotal='';show_stream();streamLyr.top=available_height*0.66;}

function show_stream() {
	maintext=(sumtotal?'<table cols=1 width='+(available_width*0.155)+' background='+image12.src+' border=0 cellpadding=0 cellspacing=0 ><tr><td align=center '+(available_width*0.155)+' valign=top><!center>'+fontvalue+'<font class="nssize">'+sumtotal+'</font><!/center></td></tr><tr><td bgcolor=midnightblue align=center '+(available_width*0.155)+'><!center>'+fontvalue+'<font class="lesser" color=white>previous responses</font></font></td></tr></table>':'');
	destination=streamHTML;
	magiccontents();
	streamLyr.top=parseInt(streamLyr.top)-10;
	if (streamLyr.visibility.indexOf('hid') != -1) {streamLyr.visibility="visible";}
//	if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer") {alphaBackgrounds();}
}


function onscreen() {
	keyboard=true;
	clearTimeout(scrolltimer);
	if (!cycle) {scrolltimer = setTimeout("query()", 30000);}
	info_string();
	maintext=table_top+(bad&&newword?fontvalue+'<font class=lesser>&nbsp;</font><font size=+3><b><br><br></font><font class=denser><font class=denser><br><br>':infostring)+'<font color=#669900>';

	if (counter>20) {
		counter=0;
		maintext=maintext+'<font color=gold>Too many characters.<br>&#164;<br>Please start again.</td></tr></table>';
		screenresult='';}
	else{
		if (oldword!='') {
			if (veryoldword!='') {
				if (bad && newword) {maintext=bad_string;}
				else{
					maintext=maintext+first+'<font color=#669966>"'+veryoldword+'"</font>'+second+'<font color=#669966>"'+oldword+'"</font>'+third+fourth+'<font color=gold>"'+oldword +'"</font>'+fifth;}
			}
			else{
				maintext=maintext+'<br></font>What do you think when you see the word <font color=white>"'+oldword +'"</font>';}
		}
		else{
			maintext=maintext+'</font><font color=#669900>You go first...</font><br>Just type a word to start, then press <font color=gold>[enter]</font>';}
	maintext=maintext+'.<br><font color=red><u>&raquo</u> <font color=white>'+screenresult+'?</font></font></td></tr></table>';}
	destination=responseHTML;
	magiccontents();
	bottom_control();
}


function do_it(doval) {

cycle=false;
clearTimeout(scrolltimer);
mainLyr.visibility='hidden';
shadowLyr.visibility='hidden';
questionLyr.visibility='hidden';
keyboard=false;

	if (!document.layers) {       // copys contents of prexisting layers, reformat and rewrite to screen 
		maintext=eval('outputHTML['+doval+'].innerHTML');
		maintext='<table height='+available_height+' width='+(available_width-16)+' border=0 cellspacing=0 cellpadding=0 cols=3><tr><td colspan=3  height='+(available_height-40)+' valign=top><ul><font color=white>' +fontvalue +'<br><br>'+maintext+'<br>'+(alerter&&doval==1?'<center><A href=# onclick="do_it(5); return false;"><font color=gold><b>[Important note for ' +alerter+' users - please click here]</a>':'')+'</td></tr><tr><td width=153 valign=top align=left>'+(doval>2?'<a href=# onmouseout="window.status=\'\'; return true;" onmouseover="window.status=\'previous page\'; return true;" onclick="do_it('+(doval-1)+'); return false;"><img src='+image6.src+' border=0 alt="previous page"></a>':'')+'</td><td valign=top align=left>'+(doval<(no_pages-1)?'<a href=# onmouseout="window.status=\'\'; return true;"  onmouseover="window.status=\'next page\'; return true;" onclick="do_it('+(doval+1)+'); return false;"><img src='+image5.src+' border=0 alt="next page"></a>':'<a href=# onmouseout="window.status=\'\'; return true;"  onmouseover="window.status=\'to the game\'; return true;" onclick="opener(); return false;">'+ (oldword?'<img src='+image7.src+' border=0 alt="back to the game">':'<img src='+image3.src+' border=0 alt="start the game">')+'</a>')+'</td><td valign=top align=right>';

		if (doval<no_pages-1) 	{
			maintext=maintext+'<a href=# onmouseout="window.status=\'\'; return true;"  onclick="opener();return false;" '; 
			if (oldword) {
				maintext=maintext+'onmouseover="window.status=\'back to game\'; return true;"><img src='+image7.src+' border=0 alt="back to the game">';} 
			else {
				maintext=maintext+'onmouseover="window.status=\'skip intro\'; return true;"><img src='+image4.src+' border=0 alt="skip the intro">';}

			maintext=maintext+'</a>';}
		maintext=maintext+'</td></tr></table>';
		destination=help1HTML;
		magiccontents();}
	else {
		help1Lyr.load('section'+doval+'.html', (available_width));
		}
if (doval==1) {hintLyr.visibility="hidden"; }
}



function higher() {theword=theword.substr(0,1).toUpperCase()+theword.substr(1);}
function lower(){theword=theword.toLowerCase();}	