var aItemWords = new Array()
var aItemCodes = new Array()
var aCheckArray = new Array()
var aCheckText = new Array()
var aDescSeed = new Array()
var aVocab = new Array();


var iCounter=0

//Example data.
//Data has binary flags (1,2,4,8,16, etc.)
// In this example we have
// 1 - Thousands
// 2 - Other numbers
// 4 - Hundreds

aItemWords[iCounter]="1"
aItemCodes[iCounter++]=1
aItemWords[iCounter]="2"
aItemCodes[iCounter++]=1

aItemWords[iCounter]="0"
aItemCodes[iCounter++]=2
aItemWords[iCounter]="1"
aItemCodes[iCounter++]=2
aItemWords[iCounter]="2"
aItemCodes[iCounter++]=2
aItemWords[iCounter]="3"
aItemCodes[iCounter++]=2
aItemWords[iCounter]="4"
aItemCodes[iCounter++]=2
aItemWords[iCounter]="5"
aItemCodes[iCounter++]=2
aItemWords[iCounter]="6"
aItemCodes[iCounter++]=2
aItemWords[iCounter]="7"
aItemCodes[iCounter++]=2
aItemWords[iCounter]="8"
aItemCodes[iCounter++]=2
aItemWords[iCounter]="9"
aItemCodes[iCounter++]=2

aItemWords[iCounter]="1"
aItemCodes[iCounter++]=4
aItemWords[iCounter]="2"
aItemCodes[iCounter++]=4
aItemWords[iCounter]="3"
aItemCodes[iCounter++]=4
aItemWords[iCounter]="4"
aItemCodes[iCounter++]=4
aItemWords[iCounter]="5"
aItemCodes[iCounter++]=4
aItemWords[iCounter]="6"
aItemCodes[iCounter++]=4
aItemWords[iCounter]="7"
aItemCodes[iCounter++]=4
aItemWords[iCounter]="8"
aItemCodes[iCounter++]=4
aItemWords[iCounter]="9"
aItemCodes[iCounter++]=4


iCounter=0


//These are ways data can be formated.
//The first array is what value the tagged items must contain
//The second array contains the text that follows (first), is after each word (the latter) and finishes the construct (final one)
aCheckArray[iCounter] = new Array(1,2,2,2)
aCheckText[iCounter++] = new Array("Todays word count is ", "", "", "", " words")
aCheckArray[iCounter] = new Array(4,2,2)
aCheckText[iCounter++] = new Array("Todays word count is ", "", "", " words")
aCheckArray[iCounter] = new Array(1,2,2,2)
aCheckText[iCounter++] = new Array("Write until ", "", "", "", " more words have been produced")
aCheckArray[iCounter] = new Array(4,2,2)
aCheckText[iCounter++] = new Array("Write until ", "", "", " more words have been produced")
aCheckArray[iCounter] = new Array(1,2)
aCheckText[iCounter++] = new Array("Try writing a story of ", "", "00 words")
aCheckArray[iCounter] = new Array(4,2)
aCheckText[iCounter++] = new Array("Try writing a story of ", "", "00 words")
aCheckArray[iCounter] = new Array(1,2)
aCheckText[iCounter++] = new Array("", "", "00 more words until the end of your story or chapter")
aCheckArray[iCounter] = new Array(4)
aCheckText[iCounter++] = new Array("", "00 more words until the end of your story or chapter")
aCheckArray[iCounter] = new Array(1,2)
aCheckText[iCounter++] = new Array("Try writing a chapter of about ", "", "00 words")
aCheckArray[iCounter] = new Array(4,2)
aCheckText[iCounter++] = new Array("Try writing a chapter of about ", "", "00 words")


//Regular functions


	function DoExponent(intBase, intExp)
	{
	   var intCount = 1;
	   var intReturn = intBase;

	   if(intExp < 1)
		{
			intReturn = 1;
		}


	   while(intCount < intExp) {

		intReturn = intReturn * intBase;

		intCount = intCount + 1;

	      }

		return intReturn;
	}
 
 
	function GenNumber(nRange)
	{
		var iNumGen;
		iNumGen = Math.round((Math.random() * (nRange+1)))-1;
 
		if (iNumGen < 0)
		{
			iNumGen = GenNumber(nRange);
		}
 
		if (iNumGen>nRange)
		{
			iNumGen = GenNumber(nRange);
		}
 
	    return iNumGen;
	}
 
 
	function GetNumber(aCurrArray, intCheckNumber)
	{
		var intReturn, intLooper
		var bEnd=false
	
		while (bEnd==false)
		{
			intReturn=GenNumber(aItemCodes.length-1)
 
			if ((aItemCodes[intReturn]  &  intCheckNumber)==intCheckNumber)
			{
				bEnd=true;
			}
 
			for (intLooper=0;intLooper<aCurrArray.length;intLooper++)
			{
				if (aCurrArray[intLooper]==intReturn)
				{
					bEnd=false;
				}
			}
		}
 
		return intReturn;
	}
 
 
 
	function GenTitle()
	{
		var aUseNumber=new Array();
		var intArrayUse
		var strReturn=""
		var strPass
		var intNumber=-1
		var intLooper
		var bEnd = false
 
		intArrayUse=GenNumber(aCheckArray.length-1);
 
		for (intLooper=0;intLooper<aCheckArray[intArrayUse].length;intLooper++)
		{
			aUseNumber[intLooper]=-1;
		}
 
		for (intLooper=0;intLooper<aCheckArray[intArrayUse].length;intLooper++)
		{
                        intNumber=GetNumber(aUseNumber,aCheckArray[intArrayUse][intLooper]);
                        aUseNumber[intLooper]=intNumber;
		}
 
		strReturn = aCheckText[intArrayUse][0];
 
		for (intLooper=0;intLooper<aUseNumber.length;intLooper++)
		{
			if (aUseNumber[intLooper]>-1)
			{		
				strReturn=strReturn + aItemWords[aUseNumber[intLooper]];
				strReturn=strReturn + aCheckText[intArrayUse][intLooper+1];
			}
		}
 
		document.GENFORM.TITEM.value = strReturn;            
	}

