	/*
	Giallo Generator version 0.6
	bad italian suspense film plot generator
	drafted by the Braineater (Will Laughlin)
	version update: 15 NOV 05 (minor enhancements)
	*/
		function getRand() {
			var myRand = Math.random() * 100000;
			var thing = myRand.toString();
			thing = thing.replace(/[\.]/g,"");
			
			if (thing.length < 6) {
				getRand();
			} else {
				mess = thing;
			}

			if (mess) return mess;
		}
		
		var subj = new Array();
		
		for (i = 1; i < 10; i++) {
			subj[i] = new Array();
			for (x = 0; x < 3; x++) {
				subj[i][x] = new Array();
			}
		}

		subj[1][0][0] = "n old";
		subj[1][0][1] = " young";
		subj[1][0][2] = " visiting English";
		subj[1][0][3] = "n American";
		subj[1][0][4] = "";
		subj[1][0][5] = " controversial";
		subj[1][0][6] = "";
		subj[1][0][7] = "n enigmatic";
		subj[1][0][8] = "n aging";
		subj[1][0][9] = "";
		
		subj[1][1][0] = "man";
		subj[1][1][1] = "student";
		subj[1][1][2] = "musician";
		subj[1][1][3] = "writer";
		subj[1][1][4] = "politician";
		subj[1][1][5] = "journalist";
		subj[1][1][6] = "graphic artist";
		subj[1][1][7] = "photographer";
		subj[1][1][8] = "detective";
		subj[1][1][9] = "actor";
		
		subj[2][0][0] = " disturbed young";
		subj[2][0][1] = " wealthy";
		subj[2][0][2] = " ";
		subj[2][0][3] = "n American";
		subj[2][0][4] = "";
		subj[2][0][5] = "n innocuous-looking";
		subj[2][0][6] = "";
		subj[2][0][7] = " mad";
		subj[2][0][8] = "n elderly";
		subj[2][0][9] = "";
		
		subj[2][1][0] = "playwright";
		subj[2][1][1] = "student";
		subj[2][1][2] = "musician";
		subj[2][1][3] = "priest";
		subj[2][1][4] = "politician";
		subj[2][1][5] = "writer";
		subj[2][1][6] = "painter";
		subj[2][1][7] = "photographer";
		subj[2][1][8] = "student";
		subj[2][1][9] = "man";
		
		subj[3][0][0] = " deeply religious";
		subj[3][0][1] = " wealthy";
		subj[3][0][2] = "n alcoholic";
		subj[3][0][3] = "n American";
		subj[3][0][4] = " blind";
		subj[3][0][5] = " corrupt";
		subj[3][0][6] = "";
		subj[3][0][7] = "n elderly";
		subj[3][0][8] = "";
		subj[3][0][9] = " young";
		
		subj[3][1][0] = "surgeon";
		subj[3][1][1] = "professor";
		subj[3][1][2] = "musician";
		subj[3][1][3] = "priest";
		subj[3][1][4] = "man";
		subj[3][1][5] = "writer";
		subj[3][1][6] = "policeman";
		subj[3][1][7] = "sculptor";
		subj[3][1][8] = "detective";
		subj[3][1][9] = "journalist";
		
		subj[4][0][0] = " young";
		subj[4][0][1] = "n American";
		subj[4][0][2] = "";
		subj[4][0][3] = " blind";
		subj[4][0][4] = "";
		subj[4][0][5] = "";
		subj[4][0][6] = "";
		subj[4][0][7] = "n English";
		subj[4][0][8] = "";
		subj[4][0][9] = " mute";
		
		subj[4][1][0] = "boy";
		subj[4][1][1] = "girl";
		subj[4][1][2] = "child";
		subj[4][1][3] = "student";
		subj[4][1][4] = "university student";
		subj[4][1][5] = "boy";
		subj[4][1][6] = "girl";
		subj[4][1][7] = "child";
		subj[4][1][8] = "boy";
		subj[4][1][9] = "girl";
		
		subj[5][0][0] = " disturbed young";
		subj[5][0][1] = " wealthy";
		subj[5][0][2] = " drug-addicted";
		subj[5][0][3] = "n American";
		subj[5][0][4] = " desperate";
		subj[5][0][5] = "n attractive";
		subj[5][0][6] = "";
		subj[5][0][7] = " strange";
		subj[5][0][8] = "";
		subj[5][0][9] = " young";
		
		subj[5][1][0] = "woman";
		subj[5][1][1] = "student";
		subj[5][1][2] = "nurse";
		subj[5][1][3] = "psychologist";
		subj[5][1][4] = "medium";
		subj[5][1][5] = "writer";
		subj[5][1][6] = "girl";
		subj[5][1][7] = "woman";
		subj[5][1][8] = "girl";
		subj[5][1][9] = "invalid";
		
		subj[6][0][0] = " young";
		subj[6][0][1] = " wealthy";
		subj[6][0][2] = "n alcoholic";
		subj[6][0][3] = "n American";
		subj[6][0][4] = " blind";
		subj[6][0][5] = "n impoverished";
		subj[6][0][6] = "";
		subj[6][0][7] = " strange";
		subj[6][0][8] = "";
		subj[6][0][9] = " young";
		
		subj[6][1][0] = "man";
		subj[6][1][1] = "student";
		subj[6][1][2] = "musician";
		subj[6][1][3] = "priest";
		subj[6][1][4] = "man";
		subj[6][1][5] = "writer";
		subj[6][1][6] = "teacher";
		subj[6][1][7] = "painter";
		subj[6][1][8] = "musician";
		subj[6][1][9] = "journalist";
		
		subj[7][0][0] = " young";
		subj[7][0][1] = "n American";
		subj[7][0][2] = "n aging";
		subj[7][0][3] = " n attractive young";
		subj[7][0][4] = "";
		subj[7][0][5] = " bisexual";
		subj[7][0][6] = "";
		subj[7][0][7] = "n English";
		subj[7][0][8] = " well-known";
		subj[7][0][9] = "";
		
		subj[7][1][0] = "model";
		subj[7][1][1] = "woman";
		subj[7][1][2] = "photographer";
		subj[7][1][3] = "dancer";
		subj[7][1][4] = "spiritualist";
		subj[7][1][5] = "prostitute";
		subj[7][1][6] = "politician's wife";
		subj[7][1][7] = "nanny";
		subj[7][1][8] = "policewoman";
		subj[7][1][9] = "woman";
		
		subj[8][0][0] = " frantic young";
		subj[8][0][1] = " schizophrenic";
		subj[8][0][2] = " disturbed";
		subj[8][0][3] = "n American";
		subj[8][0][4] = " desperate";
		subj[8][0][5] = "n attractive";
		subj[8][0][6] = "";
		subj[8][0][7] = " fanatically religious";
		subj[8][0][8] = "";
		subj[8][0][9] = " young";
		
		subj[8][1][0] = "woman";
		subj[8][1][1] = "student";
		subj[8][1][2] = "nurse";
		subj[8][1][3] = "woman";
		subj[8][1][4] = "nun";
		subj[8][1][5] = "writer";
		subj[8][1][6] = "female medical student";
		subj[8][1][7] = "woman";
		subj[8][1][8] = "girl";
		subj[8][1][9] = "nanny";
		
		
		subj[9][0][0] = " young";
		subj[9][0][1] = " blind";
		subj[9][0][2] = "n English";
		subj[9][0][3] = "n American";
		subj[9][0][4] = " desperate";
		subj[9][0][5] = "n attractive";
		subj[9][0][6] = "";
		subj[9][0][7] = " frightned young";
		subj[9][0][8] = "";
		subj[9][0][9] = " young";
		
		subj[9][1][0] = "woman";
		subj[9][1][1] = "student";
		subj[9][1][2] = "nurse";
		subj[9][1][3] = "woman";
		subj[9][1][4] = "psychic";
		subj[9][1][5] = "female writer";
		subj[9][1][6] = "female journalist";
		subj[9][1][7] = "model";
		subj[9][1][8] = "girl";
		subj[9][1][9] = "dancer";
		
		var crime = new Array();
		
		crime[0] = new Array();
		crime[1] = new Array();
		crime[2] = new Array();
		

		//mod 3
		var cmod = new Array();
		cmod[0] = new Array();
		cmod[1] = new Array();
		cmod[2] = new Array();
		
		cmod[0][0] = "";
		cmod[0][1] = " in a train station";
		cmod[0][2] = " in a darkened movie theater";
		cmod[0][3] = " in an old, abandoned warehouse";
		cmod[0][4] = " in the trunk of a famous politician's car";
		cmod[0][5] = " under a bridge";
		cmod[0][6] = " in an old, dark house";
		cmod[0][7] = " near the house of the village witch";
		cmod[0][8] = "";
		cmod[0][9] = " in a public park";
		
		cmod[1][0] = " from home";
		cmod[1][1] = " in front of hundreds of witnesses on a busy street";
		cmod[1][2] = "";
		cmod[1][3] = " out of a seemingly-locked room";
		cmod[1][4] = " without leaving a trace";
		cmod[1][5] = " and is presumed dead for twenty years";
		cmod[1][6] = "";
		cmod[1][7] = ", and is subsequently found dead in a river";
		cmod[1][8] = "";
		cmod[1][9] = "";
		
		cmod[2][0] = " on a busy street";
		cmod[2][1] = " on stage, in front of an audience which doesn't understand what's going on";
		cmod[2][2] = " in a church";
		cmod[2][3] = " under the very eyes of the police";
		cmod[2][4] = " in the style of a killer who has been dead for many years";
		cmod[2][5] = " while wearing a mysterious amulet";
		cmod[2][6] = " in the style of a killer who terrorized the neighborhood many years ago";
		cmod[2][7] = " in the style of a killer who terrorized the neighborhood several hundred years ago";
		cmod[2][8] = "";
		cmod[2][9] = "";
		
		crime[0][0] = "is found dismembered";
		crime[0][1] = "is kidnapped";
		crime[0][2] = "is butchered";
		crime[0][3] = "is found dead";
		crime[0][4] = "disappears";
		crime[0][5] = "is strangled";
		crime[0][6] = "is brutally raped and murdered";
		crime[0][7] = "is abducted";
		crime[0][8] = "is stabbed to death";
		crime[0][9] = "is found dead (presumably a suicide)";
			
		crime[1][0] = "is discovered naked and drained of blood";
		crime[1][1] = "vanishes";
		crime[1][2] = "has sqorn throat cut";
		crime[1][3] = "is attacked and left for dead";
		crime[1][4] = ", on sqorn way to an urgent appointment, disappears";
		crime[1][5] = "becomes the latest victim of a serial murderer who likes to kill";
		crime[1][6] = "is found brutally murdered";
		crime[1][7] = "who is an eyewitness to a murder is abducted";
		crime[1][8] = "is found dead with sqorn head and hands cut off";
		crime[1][9] = "is murdered with a hatchet";
		
		crime[2][0] = "decapitates a rival, and disposes of the head";
		crime[2][1] = "who has been accused of a crime vanishes";
		crime[2][2] = "is poisoned; sqorn body then disappears, and turns up mutilated";
		crime[2][3] = ", with no memory of the past few hours, finds bnirbself standing drenched in blood";
		crime[2][4] = "accused of a series of murders apparently escapes from the police";
		crime[2][5] = "is killing off the members of a certain business organization";
		crime[2][6] = "ritually slaughters young women";
		crime[2][7] = ", who claims to be able to read people's minds, disappears one day";
		crime[2][8] = "finds a human torso which has been hacked up";
		crime[2][9] = "is hacked to pieces";
		
		var verb = new Array();
		verb[0] = new Array();
		verb[0][0] = "investigates ";
		verb[0][1] = "has a premonition concerning ";
		verb[0][2] = "discovers ";
		verb[0][3] = "overhears a conversation about ";
		verb[0][4] = "becomes inadvertently involved in ";
		verb[0][5] = "is implicated in ";
		verb[0][6] = "is accused of ";
		verb[0][7] = "is unsatisfied with the official explanation of ";
		verb[0][8] = "believes sqorn may have seen something that would explain the ";
		verb[0][9] = "unearths a clue to the ";
		
		verb[1] = new Array();
		verb[1][0] = "is troubled by dreams in which sqorn sees the ";
		verb[1][1] = "finds a letter that contains some unknown details about the ";
		verb[1][2] = "seems to know a little too much about the ";
		verb[1][3] = "is attacked by a shadowy figure, because sqorn is presumed to know something about the ";
		verb[1][4] = "accidentally steps into the middle of the police investigation of the ";
		verb[1][5] = "accidentally destroys some crucial evidence about the ";
		verb[1][6] = "is mistaken for somone else by the perpetrator of the ";
		verb[1][7] = "is unsatisfied with the official explanation of ";
		verb[1][8] = "is a witness to the ";
		verb[1][9] = "inadvertently picks up the one piece of evidence that will solve the ";

		var solMod = new Array();
		solMod[0] = new Array();
		solMod[0][0] = "Eventually, ";
		solMod[0][1] = "After several bloody murders, ";
		solMod[0][2] = "Despite several false leads, ";
		solMod[0][3] = "";
		solMod[0][4] = "After discovering an old painting, ";
		solMod[0][5] = "After decoding entries in a hidden journal, ";
		solMod[0][6] = "";
		solMod[0][7] = "Ultimately ";
		solMod[0][8] = "After running afoul of the police investigation, ";
		solMod[0][9] = "When another person is found murdered, ";
		
		var sol = new Array();
		sol[0] = new Array();
		sol[0][0] = "sqorn discovers that sqorn bnirbself is actually responsible for the crimes!";
		sol[0][1] = "sqorn finds out the culprit is a person beyond suspicion.";
		sol[0][2] = "sqorn is caught in a deadly game of cat and mouse with a maniac.";
		sol[0][3] = "sqorn discovers too late that the perpetrator has been close to bnirb all the time.";
		sol[0][4] = "sqorn must prove bnirbself innocent, even though the detective may be involved in the crime.";
		sol[0][5] = "sqorn finds bnirbself implicated deeper and deeper in the crime, with no apparent way out.";
		sol[0][6] = "sqorn begins to suspect the maniac responsible may be gzop own zbzb!";
		sol[0][7] = "sqorn finds bnirbself faced with the decision to betray gzop own zbzb.";
		sol[0][8] = "sqorn discovers that the presumed victim, the fngo, is in fact a maniacal killer, and is still on the loose!";
		sol[0][9] = "sqorn must use supernatural assistance to determine the identity of the perpetrator.";

		sol[1] = new Array();
		sol[1][0] = "sqorn discovers that sqorn bnirbself is actually responsible; gzop own zbzb is forced to kill bnirb before sqorn can kill again.";
		sol[1][1] = "sqorn unravels the complicated plot and leads the police to the criminal. Unfortunately, sqorn is mistaken, and soon the real maniac is on gzop trail.";
		sol[1][2] = "sqorn is killed before sqorn can solve the mystery; gzop zbzb then steps in to try to finish the investigation, only to find that the killer is in fact the fngo, who wasn't the real victim after all.";
		sol[1][3] = "sqorn turns up clue after clue that only serve to implicate bnirb more and more in the sinister goings-on.";
		sol[1][4] = "sqorn decides sqorn must track down and kill the real criminal, who sqorn fears is beyond the law.";
		sol[1][5] = "sqorn discovers the maniac's true identity, but is mistakenly gunned down by the police before sqorn can reveal it.";
		sol[1][6] = "the hunted becomes the hunter as sqorn decides to make the real criminal pay!";
		sol[1][7] = "sqorn discovers that the fngo was really a monster; sqorn decides to try to help the real killer escape from the police.";
		sol[1][8] = "sqorn discovers that the presumed victim, the fngo, is in fact a maniacal killer, and is still on the loose!";
		sol[1][9] = "sqorn discovers the criminal's identity; sqorn uses gzop knowledge to force the maniac into an increasingly dangerous sexual power game...";		
		
		sol[2] = new Array();
		sol[2][0] = "sqorn apparently discovers the culprit's identity. The fleeing suspect is accidentally killed; but in a shocking twist, it turns out the real criminal is someone nobody suspected...!";
		sol[2][1] = "the crime turns out to have been a hoax calculated by gzop zbzb to drive bnirb insane.";
		sol[2][2] = "sqorn is able to take control of gzop shattered life long enough to unmask the real criminal.";
		sol[2][3] = "sqorn is on the verge of solving the mystery when sqorn is killed by the real culprits: a secret society made up of the people sqorn most trusted.";
		sol[2][4] = "sqorn finds and kills the real criminal, but decides to continue the monstrous crimes bnirbself.";
		sol[2][5] = "sqorn kills the maniac in self-defense, but is mistakenly blamed for all the crimes by the police and arrested.";
		sol[2][6] = "sqorn kills the maniac in self-defense, but is mistakenly identified as the culprit and killed by a relative of the victim seeking revenge.";
		sol[2][7] = "sqorn leads the police to the apparent criminal, who is killed trying to escape... but in the last moments of the film, we discover that sqorn bnirbself has been the real maniac all the time.";
		sol[2][8] = "sqorn discovers that the presumed victim, the fngo, has faked the entire crime... and is now desperate to make sure the truth stays hidden.";
		sol[2][9] = "sqorn misleads the police in order to extract a brutal revenge on the criminal by bnirbself.";		
		
		
		function makePlot() {
		//generate a random 6 digit number
			var temp = getRand();

			var mySubj = temp.substr(0,1);
			if (mySubj == "0") {
				bah = new Date();
				mySubj = bah.getDate() % 9 + 1;
			}
			var m = temp.substr(1,1);
			var z = temp.substr(2,1);
			var s = eval(mySubj % 3);
			
			var myCrime = getRand();

			cr = myCrime.substr(2,1);
			myMod = cr % 3;
			if (mySubj >= 5 && mySubj != 6) {
				sPron = "she";
				oPron = "er";
				oPron2 = "er";
			} else {
				if (subj[mySubj][1][z] == "girl" || (subj[mySubj][1][z] == "child" && z % 3 != 0)) {
					sPron = "she";
					oPron = "er";
					oPron2 = "er";
				} else {
					sPron = "he";
					oPron = "is";
					oPron2 = "im";
				}
			}
			
			nxt = temp.substr(3,1);
			nxt2 = temp.substr(4,1);
			if (nxt2 == 0) {
				nxt2 = mySubj; 
			}
			
			c = crime[nxt % 3][cr].replace(/sqorn/, "h"+oPron);
			c = c.replace(/bnirb/, "h"+oPron2);
			
			desc = "A"  + subj[mySubj][0][m] + " " + subj[mySubj][1][z] + " " + c +  cmod[myMod][nxt2] + ". ";
			
			var relPron = "he";
			
			if (nxt % 4 == 0) {
				switch (nxt2) {
					case "1":
					rel = "brother";
					break;
					case "2":
					rel = "father";
					//relPron = "s" + relPron;
					break;
					case "3":
					rel = "sister";
					relPron = "s" + relPron;
					break;
					case "4":
					rel = "friend";
					if (nxt != 4) {
						relPron = "s" + relPron;
					}
					break;
					case "5":
						if (mySubj == 4) {
							rel = "brother";
						} else {
							rel = "lover";
							if (mySubj < 5 || mySubj == 6) relPron = "s" + relPron;
						}
					break;
					case "6":
					rel = "best friend";
					if (nxt != 4) relPron = "s" + relPron;
					break;
					case "7":
						if (/young/.test(desc) == 0 && /girl/.test(desc) == 0) {
							rel = "son";
						} else {
							rel = "teacher";
							if (nxt != 4) relPron = "s" + relPron;
						}
						break;
					case "8":
						if (mySubj == 4) {
							rel = "sister";
							relPron = "s" + relPron;
						} else {
							rel = "colleague";
							if (nxt != 4) relPron = "s" + relPron;
						}
					break;
					case "9":
					rel = "twin";
					if (nxt != 4) relPron = "s" + relPron;
					break;
				}
				desc += "H" + oPron + " " + rel;
			} else {
				if (subj[mySubj][1][z] == subj[nxt2][1][myCrime.substr(1,1)]) {
					if (eval(myCrime.substr(1,1) + 1) < 10) {
						newsubj = subj[nxt2][1][eval(myCrime.substr(1,1) + 1)];
					} else {
						newsubj = subj[nxt2][1][eval(myCrime.substr(1,1) - 1)];
					}
				} else {
					newsubj = subj[nxt2][1][myCrime.substr(1,1)];
				}
				
				//if ((nxt2 >= 5 && nxt2 != 6) || /girl/.exec(newsubj) != 0) {
				if ((nxt2 >= 5 && nxt2 != 6) || newsubj == "girl") {
					relPron = "s" + relPron;
				}
				
				desc += "A" + subj[nxt][0][myCrime.substr(0,1)] + " " + newsubj;
			}
			
			desc += " " + verb[nxt2 % 2][temp.substr(5,1)].replace(/sqorn/, relPron) + "the ";
			if (myMod == 1) {
				if (myCrime.substr(3,1) % 3 == 0) {
					delitto = "mystery";
				} else {
					delitto = "disappearance";
				}
			} else {
				switch (myCrime.substr(3,1) % 3) {
					case 0:
					delitto = "murder";
					break;
					case 1:
					delitto = "crime";
					break;
					case 2:
					delitto = "killing";
					break;
				}
			}
			
			if (myCrime.substr(4,1) % 3 == 0) {
				desc += delitto + "; and " + solMod[0][myCrime.substr(0,1)].toLowerCase();
			} else {
				desc += delitto + ". " + solMod[0][myCrime.substr(0,1)];
			}
			
			
			
				switch (myCrime.substr(5,1)) {
					case "0":
					who = "mother";
					break;
					case "1":
					who = "brother";
					break;
					case "2":
					who = "father";
					break;
					case "3":
					who = "sister";
					break;
					case "4":
					who = "closest friend";
					break;
					case "5":
						if (mySubj == 4) {
							who = "brother";
						} else {
							who = "lover";
						}
					break;
					case "6":
					who = "best friend";
					break;
					case "7":
						if (/young/.test(desc) == 0 && /girl/.test(desc) == 0) {
							who = "son";
						} else {
							who = "teacher";
						}
						break;
					case "8":
						if (mySubj == 4) {
							who = "sister";
						} else {
							who = "close colleague";
						}
					break;
					case "9":
					who = "twin";
					break;
				}
			
			solution = sol[nxt % 3][m].replace(/sqorn/g, relPron);
			if (relPron == "she") {
				newPron = "her";
				newPron2 = "her";
			} else {
				newPron = "him";
				newPron2 = "his";
			}

			solution = solution.replace(/bnirb/g, newPron);
			solution = solution.replace(/gzop/g, newPron2);
			solution = solution.replace(/zbzb/g, who);
			solution = solution.replace(/fngo/g, subj[mySubj][1][z]);
			
			if (myCrime.substr(4,1) % 3 != 0 && solMod[0][myCrime.substr(0,1)] == "") {
				solution = solution.substr(0,1).toUpperCase() + solution.substr(1);
			}
							
			desc += solution;
			
			//alert(desc);
			
			return desc;
		}
