function process_string(instr) {
	var result = new Array();
	result = instr.split(',');
	return(result);
}

function process_klingon() {
	var result = new Array();
	var klingonwords = 
"Qum-Communicate,toS-Climb,wIv-Choose,ngor-Cheat,tlha'-Chase,qaD-Challenge,lop-Celebrate,jon-Capture,je'-Buy,pov-Afternoon,pIch-Blame,magh-Betray,jol-Beam,tlhob-Ask,chaw'-Allow,qeS-Advise,vang-Act,chav-Achieve,'oy'-ache,DuQ-stab,QIp-stupid,Qe'-Restaurant,yuch-chocolate,vav-Father,'oy'naQ-painstik,majQa'-Well done!,nuqneH-Greeting,maH-We,'ugh-Heavy,Quch-Happy,Hov-Star,yuQ-Planet,lu'-OK,jIH-Viewscreen,tepqengwI'-Cargo carrier,nIn-Fuel,yo'-Fleet,'IQ-Sad,tlhol-Raw,tuv-Patient,qur-Greedy,QaQ-Good,qab-Face,Quch-Forehead,nach-Head,legh-See,qet-Run,bup-Quit,leS-Relax,Qan-Protect,qaw-Remember,yev-Pause,SuH-Ready!,DaH-Now,qoS-Birthday,ghargh-Gagh,pItlh-Done!,la'quv-Supreme Commander,pu'HIch-Phaser pistol,pu'beH-Phaser rifle,pu'-Phaser,nuHmey-Arsenal,Ich-Gun,veQDuj-Garbage scow,HIchDal-Airlock,pIH-Suspicious,mach-Small,Dogh-Silly,rop-Sick,quv-Honored,bIt-Nervous,qu'-Fierce,qab-Bad,'IH-Beautiful,QeH-Angry,tuH-Ashamed,lIm-Panic,maw-Offend,no'-Ancestors,qempa'-Ancestor,vuv-Respect,chegh-Return,nej-Look for,yIn-Live,puqbe'-Daughter,puqloD-Son,vaghSaD wejvatlh loSmaH Soch-5347,wa''uy'-One million,wa'SaD-One thousand,wa'vatlh-One hundred,ram-Night,po-Morning,jar-Month,Hogh-Week,tup-Minute,lup-Second,'Ij-Listen,nep-Lie,Dev-Lead,tlho'-Thank,HaD-Study,mev-Stop,nIH-Steal,tlhIH-You all,SoH-You,chaH-They (people),mut-Selfish,qawHaq-Memory banks,yuD-Dishonest,Qatlh-Difficult,Hom-Bone,Iw-Blood,mov-Top of foot,qam-Foot,not-Never,peng-Torpedo,'otlh-Photon,Hap-Matter,Dach-Absent,ghItlh-Write,voq-Trust,Qam-Stand,tagh-Lung,Somraw-Muscle,yeb-Wrist,Ha'-Let's go!,Qo'noS-Kronos,lupDujHom-Shuttlecraft,chIjwI'-Navigator,Hong-Impulse power,Hop-Far,toch-Palm of hand,chap-Back of hand,ghop-Hand,DeS-Arm,jach-Shout,DIr-Skin,chu'-New,'ejDo'-Starship,Saqghom-Landing Party,wej-Don't do it yet!,naDev-Here,pa'-There,tlhIngan Hol-Klingon language,tlhIngan-Klingon,voDleH-Emperor,Da'-Corporal,Duy'a'-Ambassador,may'-Battle,rugh-Antimatter,Daj-Interesting,val-Intelligent,Sey-Excited,mIgh-Evil,chIm-Empty,tIq-Heart,tlhon-Nostril,wuS-Lip,woS-Chin,qevpob-Cheek,yaj-Understand,ngab-Vanish,ngev-Sell,tam-Quiet,matlh-Loyal,Huy'-Eyebrow,quHvaj-Dandruff,jIb-Hair on head,Hob-Yawn,naD-Praise,woH-Pick Up,qIm-Pay attention,Sagh-Serious,HanDogh-Nacelle,jInargh-I escape.,jIqu'-I am fierce.,qatlha'-I chase you.,bIqab-You are bad.,jIQeH-I am angry.,bItuH-You are ashamed.,chomaw-You offend me.,chovuv-You respect me.,jIchegh-I return.,qanej-I look for you.,jIyIn-I live.,jI'Ij-I listen.,chotlho'-You thank me.,jIHaD-I study.,jImev-I stop.,DanIH-You steal it.,qaHoH-I kill you.,maDun-We are wonderful.,qaDev-I lead you.,jISov-I know.,qachargh-I conquer you.,bIqej-You are grouchy.,bIvaQ-You are aggressive.,qapIch-I blame you.,qabej-I watch you.,jI'Ip-I vow.,qaqotlh-I tickle you.,qaDuQ-I stab you.,chotIch-You insult me.,bIQup-You are young.,jItlhab-I am independent.,jIyoH-I am brave.,jIchav-I achieve.,jItIn-I am big.,jI'oy'-I ache.,malop-We celebrate.,bIqan-You are old.,bIpum-You fall.,Duy'-It is defective.,qaHIv-I attack you.,qatlhob-I ask you.,HIlob-Obey me.,jIchIj-I navigate.,vIchup-I suggest it.,bItlhaQ-You are funny.,qawIv-I choose you.,Do'Ha'-That is unfortunate,tera'ngan-Terran,jatlh-Speak,jot-Calm,Soy'-Clumsy,ghobe'-No,boH-Impatient,bIr-Cold,lugh-Correct,butlh-Dirt under fingernails,nItlhpach-Fingernail,ngIb-Ankle,yaD-Toe,'uS-Leg,DeSqIv-Elbow,nItlh-Finger,jol-Transport beam,SuyDuj-Merchant ship,botjan-Shields,noch-Sensor,jIjatlh-I speak.,majot-We are calm.,jIvang-I take action.,bISoy'-You are clumsy.,qaHo'-I admire you.,qaQaw'-I destroy you.,jIbIr-I am cold.,qaqeS-I advise you.,jIlugh-I am correct.,qachaw'-I allow you.,jIbel-I am pleased.,maSuv-We fight.,bIyuD-You are dishonest.,chomagh-You betray me.,Qatlh-It is difficult.,vIghItlh-I write it.,qavoq-I trust you.,jIQam-I stand.,chongor-You cheat me.,qaqaD-I challenge you.,jIba'-I sit.,jIjach-I shout.,qabach-I shoot you.,cholobHa'-You disobey me.,jIval-I am intelligent.,jIQoch-I disagree.,jISey-I am excited.,qajon-I capture you.,vIje'-I buy it.,chonuQ-You bother me.,vIngev-I sell it.,bItam-You are quiet.,jImatlh-I am loyal.,jI'el-I enter.,vItIv-I enjoy it.,chonaD-You praise me.,qawoH-I pick you up.,jIqIm-I pay attention.,jISagh-I am serious.,qaQoy-I hear you.,qamuS-I hate you.,HItojQo'-Don't deceive me.,jIQuch-I am happy.,HItlhochQo'-Don't contradict me.,ma'IQ-We are sad.,jIjaH-I go.,yIlIjQo'-Don't forget.,jItuv-I am patient.,HIje'-Feed me.,bIqur-You are greedy.,jIQum-I communicate.,jIQaQ-I am good.,jItoS-I climb.,qalegh-I see you.,jIqet-I run.,jIbup-I quit.,jIleS-I relax.,qaQan-I protect you.,qaqaw-I remember you.,jIyev-I pause.,jISup-I jump.,qayu'-I interrogate you.,jIqap-I insist.,qaQaH-I help you.,jIquv-I am honored.,qajey-I defeat you.";
	result = klingonwords.split(',');
	return(result);
}


var wordlist = new Array();

var nookers = "TEd,trapper john,Patty,Becky,katie,bern,Brandy,Kristy,Bruce,Sheila,Astro-Annie,corbie,Lami,Shannon,April,Sonja,Kate,MJC,Brad,Matt,Danny,squiddy,Bruce 2,rhiannon,Deb,Phil,lawrence solomon,Rebecca,DjP,jim,Bob,Norman,Liam,Andrea,don,Drea,Jennie,Harry,Anne,Becky,Leo,Andrea K.,George!,veronica,jenna,Pilgrim,charlie,Elizabeth,Tom Neff,Michael Packer,CONE HEAD-REX,Jim,Pooh-Bah,tish,Caroline (Dreams),Rocio,Brenda,Buddy,Courtney,Dave,Adam,Andy,ashley,Alan from Axtown,Blair,Joy Elyse,emily,Heather,Allie,Jean,jeremy,Jon,Jonie,Ken,Max,Paul,Meredith,Russell,Scott,Lyndhaven";
var countries = "Spain,Portugal,France,Germany,Britain,Ireland,Netherlands,Germany,Belgium,Lichtenstein,Switzerland,Denmark,Poland,Sweden,Norway,Finland,Hungary,Austria,Italy,Yugoslavia,Romania,Greece,Turkey,Andorra,Croatia,Serbia,Montenegro,Czechosolovakia,Albania,Monaco,Abu Dhabi";
var bigwords = "acrimonious,allegiance,ameliorate,anachronistic,annihilate,antiseptic,articulate,authoritative,benefactor,boisterous,breakthrough,carcinogenic,censorious,chivalrous,collarbone,coeducational,commendable,compendium,comprehensive,conclusive,conscientious,considerate,deferential,denouement,determinate,dictatorial,diffidence,disruption,earthenware,elliptical,entanglement,escutcheon,extinguish,extradition,fastidious,flamboyant,forethought,forthright,gregarious,handmaiden,honeysuckle,hypocritical,illustrious,infallible,lumberjack,mischievous,mollycoddle,nimbleness,nonplussed,obliterate,obsequious,obstreperous,opalescent,ostensible,pandemonium,paraphernalia,pawnbroker,pedestrian,peremptory,perfunctory,pernicious,perpetrate,personable,pickpocket,poltergeist,precipitous,predicament,preposterous,presumptuous,prevaricate,propensity,provisional,pugnacious,ramshackle,rattlesnake,reciprocate,recrimination,redoubtable,relinquish,remonstrate,repository,reprehensible,resolution,resplendent,restitution,retaliation,retribution,saccharine,salubrious,skulduggery,skyscraper,slovenian,soothsayer,tearjerker,transcribe,turpentine,unassuming,underscore,undertaker,underwrite,unobtrusive,vernacular,waterfront,watertight";
var verbs = "revolt,clothe,rally,incriminate,obviate,instantiate,represent,ameliorate,recuse,antagonize,revisit,obfuscate,enjoin";
var lice = "Pediculus humanus capitus,Pediculus humanus corpus,Pthirus pubis,Haematopinus apri,Haematopinus bufali,Haematopinus eurysternus,Haematopinus penicillarus,Haematopinus quadripertusus,Haematopinus suis,Haematopinus tuberculatus,Haematopinus asini,Hoplopleura acanthopus,Hoplopleura arboricola,Hoplopleura arizonensis,Hoplopleura captiosa,Hoplopleura difficilis,Hoplopleura erraticus,Hoplopleura ferrisi,Hoplopleura hesperomydis,Hoplopleura hirsuta,Hoplopleura onychomydis,Hoplopleura oryzomydis,Hoplopleura pacifica,Hoplopleura reithrodontomyis,Hoplopleura sciuricola,Hoplopleura trispinosa,Linognathus africanus,Linognathus breviceps,Linognathus pedalis,Linognathus setosus,Linognathus stenopsus,Linognathus vituli,Linognathus ovillus,Linognathoides cynomyis,Linognathoides laeviusculus,Linognathoides marmotae,Polyplax abyssinica,Polyplax affinis,Polyplax cummingsi,Polyplax geroilli,Polyplax reclinata,Polyplax serrata,Polyplax smallwoodae,Polyplax spinulosa,Polyplax steatomydis,Polyplax steatomys,Polyplax subtaterae,Polyplax waterstoni,Proenderleinellus calva,Neohaematopinus citellinus,Neohaematopinus griseicolus,Neohaematopinus inornatus,Neohaematopinus pacificus,Neohaematopinus sciurinus,Neohaematopinus sciuropteri,Neohaematopinus semifasciatus,Neohaematopinus spilosomae,Theodorus sawchuckius";
var portuguese = "Alexandre Herculano,Alexandre Manuel Vahia de Castro O´Neil de Bulhões,Bocage,José Maria Eça de Queirós,Fernando António Nogueira Pessoa,Florbela Espanca,José Saramago,Jose-Augusto Rodrigues França,Luís Vaz de Camões,Adolfo Correia da Rocha (Miguel Torga),Padre António Vieira,Sophia de Mello Breyner";
var obsadjs = "aculeate,adust,difficileness,froward,insmoother,muniting,prest,seel,rivial,votary,proficuous,adjutorious,exoteric,consectary,dilaniated,obturate,achilding,bonny,bosky,fingerlic,nary,ugsome,unwonted,welkin,plaguey";
var programs = "Lend-Lease,the New Deal,WIC,the Food and Drug Administration,the FBI,the KGB,the Central Intelligence Agency,Welfare,Daughters of the American Revolution,the Boy Scouts,the FDA,the FCC,NASA,HUD";
var bigadjs = "antidisestablishmentarianistic";
var firstnames = "David,David,David,Dave";
var lastnames = "Nields,Nields,Nields,Nields,Hower,Chalfant,David,Nooker";

wordlist[0] = process_string(nookers);
wordlist[1] = process_string(countries);
wordlist[2] = process_string(bigwords);
wordlist[3] = process_string(verbs);
wordlist[4] = process_klingon();
wordlist[5] = process_string(lice);
wordlist[6] = process_string(portuguese);
wordlist[7] = process_string(obsadjs);
wordlist[8] = new Array(
"Political power is not worth a rotten egg",
"So long as there is a state there is no freedom; and when there is freedom, there will be no state",
"Down with words, Down with resolutions, Long live the deed, Long live the creative work of the toiling masses",
"Where authority begins there the revolution ends",
"We have had enough of leaders, let us try to do without them for once",
"The future belongs to people and their liberty",
"Where there is authority there is no freedom",
"Down with Authority and Capitalism",
"Governments derive their just powers from the consent of the governed",
"No Taxation Without Representation",
"Confiscation of the landed estates",
"Long live the indissolute union of the working class, the peasantry, and the intelligentsia",
"Long live socialist democracy, guaranteeing genuine people's power and social justice",
"Long live proletarian internationalism",
"Arm the poor and the oppressed",
"Long live peoples' militias",
"Long live our great motherland",
"Freedom for the prisoners of imperialism and reaction",
"Perfect the preparation of cadres for the national economy",
"Give your talent and craftsmanship to the service of the people",
"Raise the effectiveness of scientific research, strengthen the connection between science and industry",
"Actively struggle to hasten scientific-technical progress",
"In production, make wider use of proper organization of labor, leading experience, and the most recent achievements of science and technology",
"Fervently preserve and increase socialist property",
"Improve the organization of production",
"Raise the effectiveness of agricultural production",
"Struggle for the further development and strengthening of the industrial power of our Motherland",
"Long live the glorious kolkhoz peasantry"
);
wordlist[9] = process_string(programs);
wordlist[10] = process_string(bigadjs);
wordlist[11] = process_string(firstnames);
wordlist[12] = process_string(lastnames);

function PickRandomWord(inobj, listno, capitalize, auxobj, usefirst) {
	// Generate a random number between 1 and size of wordlist
	var rnd = 0;
	if (!inobj.value && usefirst) {
		rnd = 0;
	} else {
		rnd = Math.ceil(Math.random() * wordlist[listno].length - 1);
	}

	// Display the word inside the text box
	var temp = "" + wordlist[listno][rnd];
	if (listno == 4) {
		var temparray = new Array();
		temparray = temp.split('-');
		temp = temparray[0];
		auxobj.value = temparray[1];
	}
	
	if (capitalize) {
		var ch = temp.charAt(0);
		var rest = temp.substring(1, temp.length);
		inobj.value = ch.toUpperCase() + rest;
	} else inobj.value = temp;
}

function FirstLower(instr) {
	var temp = "" + instr;
	var ch = temp.charAt(0);
	var result = ch.toLowerCase() + temp.substring(1, temp.length);
	return(result);
}


function HugeWord(f, inobj) {
	if (!f.BIGWORD1.value) PickRandomWord(f.BIGWORD1, 2, true);
	if (!f.BIGWORD2.value) PickRandomWord(f.BIGWORD2, 2, true);
	if (!f.BIGWORD3.value) PickRandomWord(f.BIGWORD3, 2, true);
	if (!f.BIGWORD4.value) PickRandomWord(f.BIGWORD4, 2, true);
	if (!f.BIGWORD5.value) PickRandomWord(f.BIGWORD5, 2, true);
	if (!f.BIGWORD6.value) PickRandomWord(f.BIGWORD6, 2, true);
	if (!f.BIGWORD7.value) PickRandomWord(f.BIGWORD7, 2, true);
	if (!f.BIGWORD8.value) PickRandomWord(f.BIGWORD8, 2, true);
	if (!f.BIGWORD9.value) PickRandomWord(f.BIGWORD9, 2, true);
	inobj.value = f.BIGWORD1.value.substring(0,8) + 
		FirstLower(f.BIGWORD2.value.substring(0,8)) + 
		FirstLower(f.BIGWORD3.value.substring(0,8)) + 
		FirstLower(f.BIGWORD4.value.substring(0,8)) + 
		FirstLower(f.BIGWORD5.value.substring(0,8)) + 
		FirstLower(f.BIGWORD6.value.substring(0,8)) + 
		FirstLower(f.BIGWORD7.value.substring(0,8)) + 
		FirstLower(f.BIGWORD8.value.substring(0,8)) + 
		FirstLower(f.BIGWORD9.value);
}


function PickRandomYear(inobj) {
    // Generate a random number between 1 and NumberOfWords
    var rnd = 1900 + Math.ceil(Math.random() * 79);

    // Display the word inside the text box
    inobj.value = rnd;
}

function FillAll(f) {
	PickRandomWord(f.FIRST, 11, false, false, true);
	PickRandomWord(f.LAST, 12, false, false, true);
	PickRandomWord(f.NAME1, 0, false, false, true);
	PickRandomWord(f.NATION1, 1);
	PickRandomWord(f.BIGWORD1, 2, true);
	PickRandomYear(f.YEAR1);
	PickRandomWord(f.BIGWORD2, 2, true);
	PickRandomWord(f.GOVPROG1, 9, true);
	PickRandomWord(f.VERB1, 3);
	PickRandomWord(f.BIGWORD3, 2, true);
	PickRandomWord(f.BIGWORD4, 2, true);
	PickRandomWord(f.GOVPROG2, 9, true);
	PickRandomWord(f.VERB2, 3);
	PickRandomWord(f.BIGWORD5, 2, true);
	PickRandomWord(f.BIGWORD6, 2, true);
	PickRandomWord(f.NAME2, 0);
	PickRandomWord(f.BIGWORD7, 2, true);
	PickRandomWord(f.VERB3, 3);
	PickRandomWord(f.BIGADJ1, 10);
	PickRandomWord(f.BIGWORD8, 2, true);
	PickRandomWord(f.BIGWORD9, 2, true);
	PickRandomWord(f.GOVPROG3, 9, true);
	PickRandomWord(f.VERB4, 3);
	PickRandomWord(f.OBJADJ1, 7);
	HugeWord(f, f.HUGEWORD1);
	PickRandomWord(f.KLING1, 4, false, f.KLINGDEF1);
	PickRandomWord(f.LICE1, 5);
	PickRandomWord(f.PHRASE1, 8);
	PickRandomWord(f.AMB1, 6);
	document.WordForm.submit();
}

function SubmitIt(f) {
	if (!f.FIRST.value) PickRandomWord(f.FIRST, 11, false, false, true);
	if (!f.LAST.value) PickRandomWord(f.LAST, 12, false, false, true);
	if (!f.NAME1.value) PickRandomWord(f.NAME1, 0, false, false, true);
	if (!f.NATION1.value) PickRandomWord(f.NATION1, 1);
	if (!f.BIGWORD1.value) PickRandomWord(f.BIGWORD1, 2, true);
	if (!f.YEAR1.value) PickRandomYear(f.YEAR1);
	if (!f.BIGWORD2.value) PickRandomWord(f.BIGWORD2, 2, true);
	if (!f.GOVPROG1.value) PickRandomWord(f.GOVPROG1, 9, true);
	if (!f.VERB1.value) PickRandomWord(f.VERB1, 3);
	if (!f.BIGWORD3.value) PickRandomWord(f.BIGWORD3, 2, true);
	if (!f.BIGWORD4.value) PickRandomWord(f.BIGWORD4, 2, true);
	if (!f.GOVPROG2.value) PickRandomWord(f.GOVPROG2, 9, true);
	if (!f.VERB2.value) PickRandomWord(f.VERB2, 3);
	if (!f.BIGWORD5.value) PickRandomWord(f.BIGWORD5, 2, true);
	if (!f.BIGWORD6.value) PickRandomWord(f.BIGWORD6, 2, true);
	if (!f.NAME2.value) PickRandomWord(f.NAME2, 0);
	if (!f.BIGWORD7.value) PickRandomWord(f.BIGWORD7, 2, true);
	if (!f.VERB3.value) PickRandomWord(f.VERB3, 3);
	if (!f.BIGADJ1.value) PickRandomWord(f.BIGADJ1, 10);
	if (!f.BIGWORD8.value) PickRandomWord(f.BIGWORD8, 2, true);
	if (!f.BIGWORD9.value) PickRandomWord(f.BIGWORD9, 2, true);
	if (!f.GOVPROG3.value) PickRandomWord(f.GOVPROG3, 9, true);
	if (!f.VERB4.value) PickRandomWord(f.VERB4, 3);
	if (!f.OBJADJ1.value) PickRandomWord(f.OBJADJ1, 7);
	if (!f.HUGEWORD1.value) HugeWord(f, f.HUGEWORD1);
	if (!f.KLING1.value) PickRandomWord(f.KLING1, 4, false, f.KLINGDEF1);
	if (!f.LICE1.value) PickRandomWord(f.LICE1, 5);
	if (!f.PHRASE1.value) PickRandomWord(f.PHRASE1, 8);
	if (!f.AMB1.value) PickRandomWord(f.AMB1, 6);
	document.WordForm.submit();
}

