function createcode(){

// This script is Copyright (c) 2007 by Larry T. Jost of WorkWebs.com
// This code is part of a service offered through http://www.workwebs.com
// Please support WorkWebs.com by using the WorkWebs.com Virtual Mall
// It costs you nothing to start your shopping at WorkWebs.com
// and the Commissions are appreciated.
//
// Documentation can be found at http://www.workwebs.com
//
// If you do happen to copy this code for your own uses, please inclde
// the above in the code.  However, Copyright proteciton does not allow
// copying of this  code...so please use it from WorkWebs.com
// Please also leave the workwebs.com references in generated code.
// 
	var input = document.theform.input.value;
	var lines=input.split("\n"); // build the entire array of lines based on newlines
	
	var cols="0001"; // default
	var intable="no";
	var ovly="n";
	
	// start assembling the form code for the table
	var buildoutput="";
	
	
	
	
	buildoutput += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
	buildoutput += "<HTML><HEAD>\n";
	buildoutput += "<META http-equiv=Content-Type content=\"text/html; charset=windows-1250\">\n";
	buildoutput += "<META content=\"MSHTML 6.00.6000.16544\" name=GENERATOR>\n";
	buildoutput += "<title>Test Yourself Code Generated by http://www.workwebs.com</title>\n";
	buildoutput += "<body>\n";
	
	
	
	
	buildoutput += "<form method=\"POST\" name=\"theform\">\n";
	buildoutput += "<hr><b>Test Yourself</b><hr>\n";

	
	
	// lines now contains each line of the entry area in its own line
	// now sort it just in case it was not sorted in order
	
	lines.sort();
	
	
	
	buildoutput += "<font face=\"Trebuchet MS, Arial, Helvetica\">\n"; // set a font
	

	
	for (var i=0; i < lines.length ;i++) // start with entry 2 since entry 0 is control info
	{
		lines[i]=lines[i].substring(0,lines[i].length-1); // remove line feeds in the strings
		// since the array is sorted and it is up to the user to be sure it is good...
		// the first row is the question followed by the choice set followed by the response set
		// the response set is used later so need to just accumulate them for much later
		// the choices  are in order followng the question so that part is easy
		// bottom line...show the question and choice entries and store up the responses for later
		
		if(lines[i].substring(5,6) == "x")
		{	// is  a comment
			;
		}
		else if(lines[i].substring(5,6) == "*")
		{	// is a conrol code
			if(lines[i].substring(7,11) == "cols")
			{ // sets column count
				cols = lines[i].substring(12,16);
				if (intable == "yes")
				{
					buildoutput += "</table>\n";
				}
				buildoutput += "<table border=\"1\" width=\"100%\"  style=\"border-collapse: collapse\" bordercolor=\"#808080\">\n"; // start the table
				intable="yes";
			}
			else if(lines[i].substring(7,11) == "ovly")
			{ // set flag
				if(lines[i].substring(12,13) == "y")
				{
					ovly="y";
				}
				else if (lines[i].substring(12,13) == "n")
				{
					ovly="n";
				}
			}
		}
		else if(lines[i].substring(5,6) == "a") 
		{ // is a question ... remember starts at 0
			buildoutput +="\n\n <!-- Next Question v1.4 of Test Yourself -->\n\n"; // make it easy to read
			buildoutput += "<tr><td colspan=\""+cols+"\" bgcolor=\"#C0C0C0\" height=\"2\">&nbsp;</td></tr>\n"; // add a gray row
			buildoutput += "<tr><td colspan=\""+cols+"\"><b>"+lines[i].substring(7)+"</b></td></tr>\n";
		}
		else if (lines[i].substring(5,6) == "b") 
		{ // is a choice 
			if(lines[i].substring(7,11) == "0001") 
			{ // is the first choice
				buildoutput += "<tr>\n"; // start the row for the choices
			}
			buildoutput += "<td><input type=\"radio\" name=\"Q" + lines[i].substring(0,4) + "\" onclick=\"calculate(\'Q" + lines[i].substring(0,4) + "R" + lines[i].substring(7,11) + "\');\">" + lines[i].substring(12) + "</td>\n";
			if(lines[i].substring(7,11) == cols)
			{ // last choice written....now end the row 
				buildoutput += "</tr>\n"; // ended the row
			}
		}
		else if (lines[i].substring(5,6) == "c") 
		{ // is a response
			if(lines[i].substring(7,11) == "0001") 
			{ // is the first response
				
				buildoutput += "<tr>\n";
				if(lines[i].substring(0,4) == "0001") 
				{ // first question
					var tempstring=""; // place to hold the response code components
					tempstring = "if      (myQA == \"Q"+lines[i].substring(0,4) + "R"+ lines[i].substring(7,11) + "\"){Q" + lines[i].substring(0,4);
					if(ovly == "n")
					{
						tempstring += "R" + lines[i].substring(7,11) + "X";
					}
					tempstring += ".innerHTML=\"" + lines[i].substring(12)+"\";}\n";
				}
				else 
				{
					tempstring += "else if (myQA == \"Q"+lines[i].substring(0,4) + "R"+ lines[i].substring(7,11) + "\"){Q" + lines[i].substring(0,4);
					if(ovly == "n")
					{
						 tempstring += "R" + lines[i].substring(7,11) + "X";
					}
					 tempstring += ".innerHTML=\"" + lines[i].substring(12)+"\";}\n";
				}
			}
			else 
			{
				tempstring += "else if (myQA == \"Q"+lines[i].substring(0,4) + "R"+ lines[i].substring(7,11) + "\"){Q" + lines[i].substring(0,4);
				if(ovly=="n")
				{
					tempstring += "R" + lines[i].substring(7,11) + "X";
				}
				tempstring += ".innerHTML=\"" + lines[i].substring(12)+"\";}\n";
			}
			
			if(ovly == "n")
			{
				buildoutput += "<td><span class=\"result\" id=\"Q"+lines[i].substring(0,4) + "R" + lines[i].substring(7,11) + "X\">&nbsp;</span></td>\n";
			}
			else
			{
				if(lines[i].substring(7,11) == "0001")
				{
					buildoutput += "<td colspan=\"" + cols + "\"><span class=\"result\" id=\"Q"+lines[i].substring(0,4) + "\">&nbsp;</span></td>\n";
				}

			}
			
			
			if(lines[i].substring(7,11) == cols) 
			{ // last question
				buildoutput += "</tr>\n"; // end the row
			}	
		}
	}
	
	
	// now end the table
	
	buildoutput += "</table></form>\n";
	
	// now display the script that calcualtes and populates responses
	
	buildoutput += "\n\n<!--  The following script is invoked when a table radio button is clicked to populate the desired result -->\n\n";
	buildoutput += "<script language=\"javascript\">\n";
	buildoutput += "function calculate(myQA){\n";
	buildoutput += "var myQA;\n";
	buildoutput += tempstring;
	buildoutput += "\n}\n";
	buildoutput += "<"+ "/"+"script>\n";
	
	buildoutput += "<font size=\"2\"> - This page was generated by the <i>Test Yourself</i> tool at <a href=\"http://www.workwebs.com\">http://www.workwebs.com</a> - </font>\n";
	buildoutput += "</body></html>\n";




	document.theform.output.value=buildoutput;
	// alert(answer);
}
