
/*
*	function capFirst
*
*	precondition:  A form object must be submitted to 
*                  this function.
*
*	postcondition: The first letter of each word, in each text input 
*                  on the form will be capitalized and returned to the 
*                  text input.
*
*/
function capFirst( theForm ) {


	if( theForm.type == "text" ) {
	
		var newarray = new Array();
		var tempChar = new String();
		var tempString = new String();
						
		newarray = theForm.value.split(" ");
		
		for( j = 0; j < newarray.length; j++ ) {
			for( k = 0; k < newarray[j].length; k++ )
				( k == 0 ) ? tempString += newarray[j].charAt(k).toUpperCase() : tempString += newarray[j].charAt(k).toLowerCase();	

			tempString += " ";
		}
		
		tempString = tempString.replace(/^\s*|\s*$/g,"");
		
		theForm.value = tempString;					
	}
}

