function wordCounter(wscr,msg)	{		// for words	
	m=new Array(10000);
	m1=new Array(10000);
	N=new Array (10000);

	A=document.getElementById(wscr).value
	B="";
	A=" " + A+" ";
	A=A.toUpperCase();		// changes all alphas to Upper case
	
	C="";
	for (i=0;i<=A.length-1;i++)
		{	k=A.charCodeAt(i);
			if (((k>64) && (k<91)) || (k==32))
			{	C=C+A.charAt(i);
			}
			else 
			{	C=C+" ";
			}
		}
	A=C;

	for (i=1;i<=A.length;i++)		//  trims leading spaces and multiple spaces
	{	if ((!(A.charAt(i)==" ")) || (!(A.charAt(i-1)==" ")))
		{B=B + A.charAt(i);
		}
	}
	//count.result1.value=B;
	B=B+" ";// makes sure there is a space at end
		
	k=0; str=" ";
	
	for (i=0;i<=B.length;i++)
	{	k1=B.indexOf(str,k);
		if (k1==-1)		//end of string B
		{	Numwords=i-1;
			break;
		}
		m[i+1]=B.substring(k,k1); // places all the words into an array m
		k=k1+1;
	}
	//count.result1.value=B; 
	C="";
	NN=0;
	for (i=1;i<=Numwords; i++)	// Numwords is total number of words
	{	if (!(m[i]==""))	// only looks at m1 words that have not been processed before (not empty)
		{	NN=NN+1;			//unique word stored in m1 array
			m1[NN]=m[i];
			N[NN]=1;			// initialize counter for word
			for (j=i+1;j<=Numwords+1;j++)	//counts and makes m1 elements with unique word empty.
			{	if (m1[NN]==m[j])
				{	N[NN]=N[NN]+1;
					m[j]="";
				}
			}	
		}	
	}		
	document.getElementById(msg).value = Numwords;
	document.getElementById('wcounter_total').value = (parseInt(document.getElementById('wcounter1').value) + parseInt(document.getElementById('wcounter2').value));
}