// JavaScript functions for madlib.shtml

function storyWrite(form) {

  // check for empty fields
  if (form.TimeofDay.value == "" || form.Color1.value == "" || 
			form.Texture.value == "" || form.Color2.value == "" || 
			form.Noun1.value == "" || form.BodyPart1.value == "" || 
			form.Noun2.value == "" || form.Noun3.value == "" || 
			form.Verb1.value == "" || form.Place1.value == "" || 
			form.Place2.value == "" || form.BodyPart2.value == "" || 
			form.Verb2.value == "" || form.Noun4.value == "" || 
			form.Noun5.value == "" || form.Food1.value == "" || 
			form.Food2.value == "" || form.Food3.value == "" || 
			form.Adverb.value == "" || form.Food3.value == "" || 
			form.Verb3.value == "" || form.Verb4.value == "" || 
			form.Verb5.value == "" || form.Place3.value == "")
    alert("Not so fast, you're not done yet!")

  else { 

	  var story = '<html><head><title>Phydeaux the Cat</title>' +
		  '<LINK rel="stylesheet" href="../sunset.css" type="text/css">' +
			'</head><body><h3>Phydeaux the Cat</h3><p>' +
			'In the ' + form.TimeofDay.value + ', the ' + form.Color1.value +
			' cat woke up on her ' + form.Texture.value + ' ' + form.Color2.value +
			' ' + form.Noun1.value + ' and stretched her ' + form.BodyPart1.value +
			'. Then she sprang from the ' + form.Noun2.value + ' onto the ' +
			form.Noun3.value + ' and ' + form.Verb1.value + ' out of the ' +
			form.Place1.value + '. In the ' + form.Place2.value + ' she stopped to lick her ' +
			form.BodyPart2.value + ', then ' + form.Verb2.value + ' down the ' +
			form.Noun4.value + ' to find some ' + form.Noun5.value +
			'. &ldquo;Maybe there will be some ' + form.Food1.value + ' or ' +
			form.Food2.value + ', or even just some ' + form.Food3.value +
			',&rdquo; she thought. ' + form.Adverb.value + ', there was only ' +
			form.Food3.value + ', so she ' + form.Verb3.value +
			' it anyway. Then, because she needed to ' + form.Verb4.value +
			', she ' + form.Verb5.value + ' on the table and got thrown out of the ' +
			form.Place3.value + '. <p><form>' +
			'<input type=button value="Close Window" onClick="window.close()">' +
			'</form></body></html>';
			
			
    storyWin= open("", "displayWindow", 
      "width=400,height=300,status=no,toolbar=no,menubar=no");

    storyWin.document.open();  // open document for further output
    storyWin.document.write(story);  // create document
    storyWin.document.close();  // close the document - (not the window!)
  }
}


