// Universal Variables 
	var nTextBoxes = 0;
	var FirstTextBox = -1;
		
//*********************************************************************
//The following function sets the form.
function StartIt(FocusNoFocus)
{
//alert("Enter function StartIt")
	
	var LengthOfForm = document.forms[0].elements.length;
//		alert("length of form = " + LengthOfForm)			
	if (LengthOfForm <= 0)
	{
		alert("Message:01 from function StartIt() \n \n  THE FORM IS EMPTY !");		
		return;
	}	
	var loopcounter;		
	for(loopcounter = 1; loopcounter <= LengthOfForm; loopcounter ++)
	{
//		alert("type = " + document.forms[0].elements[loopcounter -1].type)
		if ((document.forms[0].elements[loopcounter -1].type == "text") ||
			(document.forms[0].elements[loopcounter -1].type == "password") ||
			(document.forms[0].elements[loopcounter -1].type == "textarea"))
		{
			nTextBoxes = nTextBoxes + 1;
//			alert("number of boxes " + nTextBoxes)
			if (FirstTextBox == -1)
			{
				 FirstTextBox = loopcounter -1;
			}			
		}
	}
	
	if (nTextBoxes == 0)
	{
		alert("Message:02 from function StartIt() \n \n  THE FORM HAS NO USABLE TEXT BOXES");
		return;
	}
	if (FocusNoFocus == "Focus")
	{	
	document.forms[0].elements[FirstTextBox].focus();
	scrollTo(0,0);
	}
//	alert("exit function StartIt");
return;
} //End function to initialize the form page

//*********************************************************************
//The following function resets the form.
function ResetTheForm(pixToMove)
{
	if (nTextBoxes == 0)
	{
		 return
	}
	document.forms[0].reset();	
	document.forms[0].elements[FirstTextBox].focus();
	document.forms[0].elements[FirstTextBox].scrollIntoView();
	window.scrollBy(0,pixToMove);
	//document.forms[0].elements[loopcounter-1].focus();					
	//scrollTo(0,0);
return;	
} //End function ResetTheForm

//*********************************************************************
//This function verifies that all text boxes are filled in before sending.
function SendIt(pixToMove) //pixToMove is the pixel value to move down.
{
//alert("SentIt entered")
	if (nTextBoxes == 0)
	{
		alert("Form has no input fields !")
		 return
	}
	var elementName;
	var LengthOfForm = document.forms[0].elements.length;	
	var loopcounter;
	var noReq;
	var x;
	for(loopcounter = 1; loopcounter <= LengthOfForm; loopcounter ++)
	{
		if ((document.forms[0].elements[loopcounter -1].type == "text") ||
			(document.forms[0].elements[loopcounter -1].type == "password") ||
			(document.forms[0].elements[loopcounter -1].type == "textarea"))
		{
			elementName = document.forms[0].elements[loopcounter-1].name;
			//Determine if field is required.
			if ((elementName.search("REq") == 0) ||
			   (elementName.search("REq") == 1))
			{
				//Determine if field is blank.			
				if (document.forms[0].elements[loopcounter-1].value == "")
				{
					x = document.forms[0].elements[loopcounter-1].name;
					noReq = x.replace("NREq","");
					x = noReq;
					noReq = x.replace("REq","");
					alert("Please enter the " + noReq + " field");
					document.forms[0].elements[loopcounter-1].scrollIntoView();
					window.scrollBy(0,pixToMove);
					document.forms[0].elements[loopcounter-1].focus();					
						//Note:  These two lines together will work under the right circumstances.
						//x = document.forms[0].elements[loopcounter-1].offsetTop;
						//alert("The offset x is: " + x) 					
						//scrollTo(0,x);										
					return false;
				}
				//Determine if field should be numeric.
				if (elementName.search("N") == 0)
				{					
					var CheckData = isNaN(document.forms[0].elements[loopcounter-1].value);
					if (CheckData)
					{
						x = document.forms[0].elements[loopcounter-1].name;
						noReq = x.replace("NREq","");
						alert(noReq + " field must be numeric");						
						document.forms[0].elements[loopcounter-1].value = "";
						document.forms[0].elements[loopcounter-1].scrollIntoView();
						window.scrollBy(0,pixToMove);
						document.forms[0].elements[loopcounter-1].focus();
						//Note:  These two lines together will work under the right circumstances.
							//x = document.forms[0].elements[loopcounter-1].offsetTop;
							//alert("The offset x is: " + x) 					
							//scrollTo(0,x);										
						return false;
					}
				} 
			}			
		}
	}	
//	alert("This form is being sent to Fred  \n \n  In real life a database of names is needed.");	
return true;
} //End of function SendIt
// ************************* END FUNCTIONS TO PROCESS FORMS *************************************************
//***********************************************************************************************************
//This function moves the document to a desired position less 40px(the height of the header and menu elements).
function positionTop(GoToElement)
{
	//alert("PositionTop entered   GoToElement =  " + GoToElement)
	var bodyElement = document.getElementById(GoToElement);
	var y = bodyElement.offsetTop - 50;
	//alert(bodyElement + "     " + y);
	scrollTo(0,y);
return;
} //End function positionTop.

//***********************************************************************************************************
//This function opens a new window.
function getWindow(windowToOpen,windowName)
{
	//window.open("","myWindow","width=250,height=250,location");
	window.open(windowToOpen,windowName);
	//window.open(windowToOpen,windowName,"copyHistory=yes");
	//window.open(windowToOpen,windowName,"copyHistory=yes,directories=yes");
	//window.open(windowToOpen,windowName,"copyHistory=yes,directories=yes,location=yes");
	//window.open(windowToOpen,windowName,"copyHistory=yes,directories=yes,location=yes,menubar=yes");			
	//window.open(windowToOpen,windowName,"copyHistory=yes,directories=yes,location=yes,menubar=yes,resizable=yes");
	//window.open(windowToOpen,windowName,"copyHistory=yes,directories=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes");
	//window.open(windowToOpen,windowName,"copyHistory=yes,directories=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes");
	//window.open(windowToOpen,windowName,"copyHistory=yes,directories=yes,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes");
return;
} //End function getWindow.

//***********************************************************************************************************
//This function also opens a new window.
function goPage(src)
{
	window.location.href = src;
}//End function goPage.

//***********************************************************************************************************
//This function establishes the current date and and appends it to the id="dateSpot" element on a page. 
function dateRoutine()
{
	var months = new Array("January","February","March","April","May","June","July","August",
						"September","October","November","December");
	var dayOfWeek = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var dateNow = new Date();
	var yearNow = dateNow.getFullYear();
	var monthNow = months[dateNow.getMonth()];
	var dayNow = dateNow.getDate ();
	var dayName = dayOfWeek[dateNow.getDay()];
	
	var dateElement = document.getElementById("dateSpot");
	var newText =document.createTextNode(dayName + " " + monthNow + " " + dayNow + ", " + yearNow)
	dateElement.appendChild(newText)
	//alert("\n" + dayName + " " + monthNow + " " + dayNow + ", " + yearNow);
return;
}  //End function dateRoutine.

//***********************************************************************************************************
//This function adds Operating System, Browser, and screen resolution information to the form before sending it.
function FillIt()
{	
	var sBrowser = navigator.appName;
	var sOS = navigator.userAgent;
	var theMessage = document.forms[0].REqProblemDescription.value ;
	theMessage = theMessage + "\nOperating System Information: " + sOS +
		"\nBrowser Information: " + sBrowser + 
		"\nScreen Height : " + screen.height + "\nScreen Width : " + screen.width + "\n";
	document.forms[0].REqProblemDescription.value = theMessage;
return;	
} //End of function FillIt.
