var categories = new Array("Witty Riposte", "Technical Query", "Identity Crisis", "Jokes", "Light Banter", "Rant", "Deeply Meaningful", "Surreal", "Obituary");
var keywords = new Array("Magic", "Folks", "Cheery Hinton", "Soddit", "Drivel List", "Hale", "Mornington Crescent", "Mobile 'phone", "B@st@rds", "Gosh");

var Witty = new Array("I'm deeply %hurt% by that.", "If only it were that easy.", "I'm beginning to wonder why I asked.", "Sorry I asked.", "Good point, well made.", "Well I, for one, am glad we have that sorted out.", "Sorry for being even thicker than usual, %name%.", "Uh? What does he mean by that?", "S#dd#t. B#gg#r.  S#dd#t.");
var hurt = new Array("hurt", "touched", "moved", "wounded");
var name = new Array("Dave", "MBD", "AJB", "everyone", "Farrar");
var name2 = new Array("Dave", "MBD", "AJB", "Philip Earis", "David Bryant", "Farrar");

var Technical = new Array("Anyone know whether (i) upgrading to %software% version %version% is worth doing; and (ii) whether, if I do upgrade it will still be compatible with %software%? %torch%", "Anyone know anything about the toxicology of %chemical%?", "Why is it when in Word I press a %key% I get a %key%? %torch%", "Can anyone tell me where is it my characters go when I delete them? %deletetheory%");
var software = new Array("WinZip Self-Extractor", "Adobe Acrobat", "Netscape", "Windows 95", "Hotmail");
var version = new Array("1.0", "8.1");
var torch = new Array("", "", "", "", "<br><br>OK, torch the UK support office.");
var chemical = new Array("Boron", "Phosforus", "1,2-di-benzo-toblerone", "Wadworths 6X");
var key = new Array("comma", "space", "semi-colon", "hash sign", "flight simulator");
var deletetheory = new Array("Is it into a wormhole in space and time?", "Is there a little storage bin underneath my keyboard?", "Do they find their way into the washing up?", "Do they go back to Microsoft for recycling?", "Do they jump from the screen into my tea mug?", "Do they go to the deleted character recycling plant in Hale?");

var Identity = new Array("I'd ask on Ringing Chat.", "Anyone else suffer from being me?", "Say, is there another IWD on this list?", "Yes, I'm for real.", "How long before we all get tired of this?", "Oh no, the IWD generator is mutating.", "I and I alone am the original IWD.");

var Jokes = new Array("That reminds me of a joke. Why are there no aspirins in the jungle?");

var Light = new Array("Is it near Hale?", "Are folk really that pathetic?", "Now look what you've done - you've made him feel normal.", "I can't believe I stayed awake typing this.", "So how do you know?", "Bet you %name2% would know.", "%daughter% says she gets more porn than all her friends.");
var daughter = new Array("Holly (my eldest)", "Hazel (my youngest)", "Poppy (my second eldest)", "Pansy (my second youngest)", "Peony (my third oldest)", "Rosie (my third youngest)");

var Rant = new Array("Why is it automatically assumed that nowadays folks all %cando%? Let's form a %nondo% Guild. We could devote our time to grabbing local %grabbee%.", "How many folk carry %mobiles% around with them when they're down the pub, on the train, in the church... ? There's nothing wrong with technology as long as it does not irritate me.", "I can't stand folk who %badfolk%.", "In the last 25+ years the only people to have done well are those who %badfolk%. My missus reckons the %system% is failing the vast majority of our %kids%. Many, of course, deserve to be %deserve%.", "Gosh, when you consider how much dosh these bastards must be making ...", "To hell with %democracy%.  Anyone think of a better reason for installing a fascist government?", 
"I am looking forward to hearing the %farmers% moaning that they can't shift their %lambs%, and seeing pictures of them pouring the latter down the drains as a gesture of defiance against %defiance%");
var cando = new Array("can drive", "have mobile 'phones", "can ring 8-spliced");
var nondo = new Array("non-Drivers", "non-Mobile Users", "non-8-Spliced Ringers");
var grabbee = new Array("pubs", "towers", "women");
var mobiles = new Array("mobile 'phones", "computers", "motion dectectors", "8-port hubs");
var badfolk = new Array("always turn up late on practice night", "associate with twelve-bell hobbyists", "drink halves", "vote New Bloody Labour");
var system = new Array("education system", "Central Council", "government");
var kids = new Array("kids", "ringers", "twelve-bell hobbyists");
var deserve = new Array("flogged", "sent to the labour camps", "made to ring at Cheery Hinton");
var democracy = new Array("democracy", "Farrar", "Camp", "the Ringing World", "the Methods Committee", "the IWD Generator");
var farmers = new Array("farmers", "RW Board", "College Youths");
var lambs = new Array("lambs and milk", "peal records", "comic");
var defiance = new Array("... what?", "non-mobile 'phone users.");

var Deeply = new Array("Worked for me, anyway.", "Can %sun% be said to have a 'purpose'?", "Sorry. Is this supposed to be clarification?", "So. What was the answer?", "Then why the %punctuation%?", "Did he mean to say '%stuff%'?", "Say, this site really works."); 
var sun = new Array("the sun", "the Drivel List", "Farrar", "the Central Council", "God", "life", "a pint of Bass");
var stuff = new Array("p*ss", "Hale", "Mornington Crescent", "gas manifold");
var punctuation = new Array("apostrophes", "commas", "question mark", "smilie");

var Surreal = new Array("I'm happy to explain privately.", "When I next have a %surrealfish%, I will not also need a %surrealphone%, because my wife cannot %surrealverb%.", "When I next have a %surrealfish%, I will not also need a %surrealphone%, because my wife cannot %surrealverb%.", "When I next have a %surrealfish%, I will not also need a %surrealphone%, because my wife cannot %surrealverb%.", "Soddit Mark, that's absolutely magic.  It will save me hours of thought. Only one trouble though - there's only one joke.");
var surrealfish = new Array("Turbot", "bottle of alcopops", "full body massage");
var surrealphone = new Array("mobile 'phone", "car", "sally warmer", "gas manifold", "motion dectector");
var surrealverb = new Array("fly", "toast kippers", "wax coasters", "repair carburettors", "titrate", "polish olives");

var Obituary = new Array("Sod off Sullivan.", "Happy to write it for you.", "You'll miss me when I'm gone.");

var endings = new Array("", "<br>Sod 'em all, I say.", "<br>Anyone else think things were better in the sixties?", "<br>Right. That's it. You're banned from Cheery Hinton.", "<br>'%keywords%' my arse.", "<br>Magic.", "<br>B@st@rds.", "<br>And how many millions did they pay consultants to come up with this one?", "<br>B#gg#r.  S#dd#t.", "", "", "", "", "", "", "", "", "", "", "", "");

var sig = new Array("IWD", "IWD", "IWD", "IWD", "IWDull", "IWDense", "IWDonut", "IWDunce", "IWDead");

function emitTypeSelector()
{
	document.writeln('<select name="type" size="1">');
	for (var i=0; i<categories.length; i++)
		document.writeln('<option>'+categories[i]);
	document.writeln('</select>');
}

function emitKeywordSelector()
{
	document.writeln('<select name="keyword" size="1">');
	for (var i=0; i<keywords.length; i++)
		document.writeln('<option>'+keywords[i]);
	document.writeln('</select>');
}

function emitMail()
{
	var form = document.forms.selector;
	var emailType = form.type.options[form.type.selectedIndex].text;
	var i = emailType.indexOf(' ');
	if (i<0)
		i = emailType.length;
	var arrayName = emailType.substring(0, i);
	var s = genRandom(arrayName);
	if (arrayName!="Jokes")
		s+= "<br>"+genRandom("endings");
	s = "<h3>[r-c] Re: "+emailType+"</h3><hr><p style='font-family: monospace; font-size: 12pt'>"+s+"</p><p style='font-family: monospace; font-size: 12pt'>"+genRandom("sig")+"</pre>";
	var w = parent.email.document;
	w.open();
	w.write(s);
	w.close();
}

function genRandom(arrayName)
{
	var a = eval(arrayName);
	var i = Math.round(Math.random()*(a.length-1));
	var j1 = 0;
	var j2 = a[i].indexOf('%');
	var s = "";
	while (j2>=j1)
	{
		s+= a[i].substring(j1, j2);
		j1 = j2+1;
		j2 = a[i].indexOf('%', j1);
		s+= genRandom(a[i].substring(j1, j2));
		j1 = j2+1;
		j2 = a[i].indexOf('%', j1);
	}
	s+= a[i].substring(j1);
	return s;
}

