
function CkNme(XNme)  {
  var UcNme = XNme.toUpperCase()
  var LcNme = XNme.toLowerCase()
    
  if (XNme==UcNme || XNme==LcNme){
      XNme = LcNme;
      XNme = XNme.charAt(0).toUpperCase() + XNme.substring(1,15);
    }  
 return XNme;
 }

function compute(fern)  {
var ages=new Array("one","two","three","four","five", "six", "seven", "eight", "nine","ten","eleven","twelve","thirteen","fourteen")
if(fern.gender.value == "Male"){
 var boyGirl = "boy"
 var heShe = "he"
 var heSheCap = "He"
 var hisHer = "his"
 var hisHerCap = "His"
 var himHer = "him"
 var self = "himself"
} 
else {
 var boyGirl = "girl"
 var heShe = "she"
 var heSheCap = "She"
 var hisHer = "her"
 var hisHerCap = "Her"
 var himHer = "her"
 var self = "herself"
};
  var firstName = fern.firstName.value
    firstName = CkNme(firstName);
  var lastName = fern.lastName.value
    lastName = CkNme(lastName);
  var fullName = firstName +" "+lastName
  var fullCaps = fullName.toUpperCase()
  var nbr = fern.age.value
  var ageNow = ages[nbr]
  var ageThen = ages[nbr - 3]
  var eyes = fern.eyes.value
  var hair = fern.hair.value
  var imp = fern.imp.value
  var color = fern.color.value
  var thing = fern.thing.value
  var nbr = fern.nbr.value
  var story = ("<html><HEAD><TITLE>" + firstName + "\'s Surprise!</TITLE>  <LINK REL=stylesheet Type='text/css' HREF='SansTxt.css'></HEAD>");

story = (story +"<BODY text='#996600' BGCOLOR = '#6666FF'><Font size='+2'>");

story = (story +"<H1 align=center>" + firstName +"\'s Surprise!<br><sup>By " + fullName + "</sup></h1><P>This is " + firstName + "'s story. It begins three years ago. " + firstName + " was " + ageThen + " years old at that time. To this day " + heShe + " says it really happened just like this:<P>One afternoon " + heShe + " was having a snack in the kitchen by " + self + ". " + heSheCap + " jumped when " + heShe + " heard a loud thump by the front door. " + heSheCap + " went outside to see what was there. " + heSheCap + " saw a box. A tag was on the box. The tag said, \"URGENT! FOR <B>" + fullCaps + "!</B> OPEN RIGHT AWAY!\"<P>When " + firstName + " took the lid off the box, out popped a little person who was just " + nbr + " inches tall. \"Whew! It sure was hot and dark in there. I didn't think I was ever going to get here and find you.\" The person seemed to be mad at " + firstName + ".<P>" + firstName + " stared back and then asked, \"Who are you?\"<P>\"I'm " + imp + " and I've come to stay with you,\" " + heShe + " replied. " + heSheCap + " seemed calmer now and spoke in a nice way.<P>" + imp + " had " + hair + " hair and " + eyes + " eyes just like " + firstName + " had. But, " + heShe + " was dressed very oddly. " + heSheCap + " had on a swimming suit and flippers, and a wool hat and mittens. The swimming suit, flippers, hat, and mittens were " + color + ".<P>" + firstName + " knew it was rude, but had to say, \"I do like the color, but why do you have on that funny outfit? It doesn't go together.\"<P>" + imp + "'s bright " + eyes + " eyes flashed. \"It's so I can always be ready to go fun places and do fun things with you, of course.\" " + imp + " sounded very sure of " + self + " and had " + hisHer + " hands on " + hisHer + " hips while " + heShe + " spoke.<P>From that day, " + firstName + " and " + imp + " were best friends. They had fun together. When " + firstName + " rode " + hisHer + " bike or went to school, " + imp + " sat on top of " + firstName + "'s backpack. " + heSheCap + " said " + heShe + " could see more that way. Sometimes on long car trips, " + imp + " would slip out of the crack in the back seat of the car and want to sit on top of " + firstName + "'s head. That made " + firstName + " restless and giggly and soon " + firstName + "'s family would get upset with " + himHer + ".<P>" + imp + " played tricks,  too... Once " + firstName + " had to look and look for " + hisHer + " missing " + thing + ". Finally, " + firstName + " found it under the bed. As " + heShe + " pulled it out, " + imp + " popped up, winked, and said, \"GOTCHA!\" Another time, when " + firstName + " was taking a bath, " + imp + " hid behind the soap and yelled really loudly, \"You forgot to wash behind your ears!\"<P>At night " + imp + " liked to sleep with " + firstName + ". After saying \"goodnight and have sweet dreams,\" the little friend would slip under the pillow. That was a good place to be safe, yet close to " + firstName + ", all night long. <P>It's funny, but " + firstName + "'s family never saw or heard " + imp + ". After a time, " + firstName + " stopped talking to them about " + himHer + ". That was O.K. with " + firstName + " because " + heShe + " didn't want to share " + himHer + " anyway.<P>" + firstName + " is " + ageNow + " years old now and doesn't see " + imp + " anymore. They never said goodbye. Just little by little they stopped seeing each other. " + firstName + " says " + heShe + " thinks " + imp + " went to live with another kid who needed a friend. And   that just may be what happened.<h2>WHAT DO YOU THINK?</h2><hr> <font color='#0066FF' size='-4'>&copy;2002 Kay Wittes </body></html>");

msgWindow=window.open("","displayWindow","toolbar=yes,width=640,height=400,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=yes")
msgWindow.document.write(story)
<!-- ?writeln instead of 'write' -->
msgWindow.focus()
msgWindow.document.close()
}
