var Alphabet1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
var Alphabet3 = Alphabet1
var Alphabet2 = '                          '
var message = new Array()
var mlib = new Array()
var enM = new Array()

mlib = [[	'A pioneer on a wagon train was amazed to see a baby bear jump on',
 			'a horse and race ahead of the wagons. When the bear returned,', 
 			'it headed for the wagon master and drew a map of what lay ahead',
  			'and the best route for the wagon train to take.\"That\'s amazing,"', 
  			'said the pioneer to the wagon master.',
   			'\"I\'ve never seen anything like it!"\"You mean to', 
   			'tell me,\" the wagon master said in surprise,', 
   			'\"you\'ve never seen a Cub Scout?"'],
		 [	'An usher in a theater noticed a man sprawled across three seats.',
			'"I\'m sorry, sir", the usher said, "but you\'re allowed only one',
			'seat." The man didn\'t budge. "Sir," the usher said, "if you',
			'don\'t get up, I\'m going to have to call the manager." When the',
			'man just groaned, the infuriated usher marched up the aisle and',
			'returned with the manager. "All right, buddy", the manager said,',
			'"what\'s your name?" "Sam," the man moaned.',
			'"Where did you come from, Sam?" "The balcony."'],
		[	'Patient: I hurt everywhere I touch! My elbow, my knee,',
			'even my stomach!',
			'Doctor: Let me look at you.',
			'Patient: So what do you think, Doc?',
			'Doctor: I think your finger is broken!'],
		[	'Three old men went to the doctor for a memory test. The',
			'doctor asked the first man, "What\'s three times three?"',
			'The first man replied, "274." The doctor asked the second',
			'man, "What\'s three times three?" The second man answered,',
			'"Tuesday." So the doctor asked the third man, "What\'s',
			'three times three?" "Nine," said the third man. "Great!"',
			'exclaimed the doctor. "How did you get that?" The third',
			'man replied, "I took 274 from Tuesday."'],
		[	'The sheriff of a small western town was also the town',
			'veterinarian. Late one night, the phone rang and his wife',
			'answered. "Is your husband there?" Came an agitated voice.',
			'"Do you require his services as a sheriff or as a vet?"',
			'asked the wife. "Both," came the reply. "We can\'t get our',
			'dog\'s mouth open, and there\'s a burglar in it!"'],
		[	'Two boys on their first camping trip found the mosquitoes',
			'so bad they had to hide under their blankets to keep away',
			'from being bitten. One of them peeped out and saw some',
			'fireflies. "We might as well give up," he told his buddy,',
			'"now they\'re coming after us with flashlights!"'],
		[	'A duck walks into a store and asks, "Got any grapes?" The man at the',
			'counter says, "Sorry, no grapes." The next day the duck returns to',
			'the store. "Got any grapes?" it asks. "No," says the man. The third',
			'day: same duck, same question, but this time the man says, "No! And',
			'if you come back and ask for grapes again, I\'ll staple your feet',
			'to the floor!" The next day the duck comes into the store. "Got any',
			'staples?" it asks. "No," the man says. "Well then," asks the duck,',
			'"have you got any grapes?"'],
		[	'Goosey, Goosey, Gander, Whither dost thou wander?',
			'Upstairs and downstairs and in my lady\'s chamber.',
			'There I met an old man who wouldn\'t say his prayers;',
			'I took him by the left leg, and threw him down the stairs.'],
		[	'When good King Arthur ruled this land, he was a godly king;',
			'He stole three pecks of barley meal, to make a bag-pudding.',
			'A bag-pudding the King did make, and stuffed it well with',
			'plums.',
			'And in it put great lumps of fat, as big as my two thumbs.',
			'The King and Queen did eat thereof, and noblemen beside;',
			'And what they could not eat that night, the Queen next',
			'morning fried.'],
		[	'A little cock-sparrow sat on a green tree,',
			'And he chirruped; he chirruped, so merry was he;',
			'A naughty boy came with his wee bow and arrow,',
			'Determined to shoot this little cock-sparrow.',
			'"This little cock-sparrow shall make me a stew,',
			'And his giblets shall make me a little pie, too."',
			'"Oh, no," says the sparrow, "I won\'t make a stew."',
			'So he flapped his wings and away he flew.'],
		[	'Little Jack Jelf was put on the shelf',
			'Because he could not spell "pie."',
			'When his aunt, Mrs. Grace saw his sorrowful face',
			'She could not help saying, "Oh, fie!"',
			'And since Master Jelf was put on the shelf',
			'Because he could not spell "pie,"',
			'Let him stand there so grim, and no more about him',
			'For I wish him a very good-by!'],
		[	'I had a little pony, his name was Dapple-Gray',
			'I lent him to a lady, to ride a mile away.',
			'She whipped him, she slashed him,',
			'She rode him through the mire.',
			'I would not lend my pony now',
			'For all the lady\'s hire.'],
		[	'There were once two cats of Kilkenny',
			'Each thought there was one cat too many.',
			'So they fought and they fit,',
			'And they scratched and they bit,',
			'Till excepting their nails,',
			'And the tips of their tails,',
			'Instead of two cats, there weren\'t any.']	]

function shuffle() {
	for ( var j = 0; j < 10; j ++ ) {
		for ( var i = 25; i >= 0; i -- ) { 
			var temp, tempindex
			temp = Alphabet3.charAt(25)
			
			tempindex =  Math.floor(Math.random() * i )
			Alphabet3 = Alphabet3.substring(0, 25) + Alphabet3.charAt(tempindex)
			var str1 = Alphabet3.substring(0, tempindex)
			var str2 = Alphabet3.substring(tempindex + 1, 26)
			Alphabet3 = str1 + temp + str2
		}
	}
}
shuffle()

function InitM()
{	var MItems = mlib.length
	var randnum = Math.floor(Math.random()*MItems)
	message = mlib[randnum]
	for (var i = 0; i < message.length; i ++ ) {
		message[i] = message[i].toUpperCase()}
}
InitM()

function zM()
{	for (var i = 0; i < message.length; i ++ ) {
		enM[i] = ''
		for (var j = 0; j < message[i].length; j ++ ) {
			var c = message[i].charAt(j)
		 	var ind = Alphabet1.indexOf(c)
			var ch
			if(ind == -1) { ch = c}
			else { ch = Alphabet3.charAt(ind) }
			enM[i] += ch
		}
	}
}
zM()