function makeDateArray()
{
	for (i = 0; i<makeDateArray.arguments.length; i++)
		this[i + 1] = makeDateArray.arguments[i];
}
function getCurrentDate()
{
	var months	= "";
	var date	= "";
	var day		= "";
	var month	= "";
	var yy		= "";
	var year	= "";
	var datedisplay = "";

	months 		= new makeDateArray('January','February','March','April','May','June','July','August','September','October','November','December');
	date 		= new Date();
	day 		= date.getDate();
	month 		= date.getMonth() + 1;
	yy		= date.getYear();
	year		= (yy < 1900) ? yy + 1900 : yy;
	datedisplay 	= months[month] + " " + day + ", " + year;

	return (datedisplay);
}
function makeArray()
{
	for (i = 0; i<makeArray.arguments.length; i++)
		this[i + 1] = makeArray.arguments[i];
}
// query a buttongroup and find the selected button value
function getSelectedValue(buttonGroup)
{
	for (var buttonvalue = 0; buttonvalue < buttonGroup.length; buttonvalue++)
	{
		if (buttonGroup[buttonvalue].checked)
		{
			return buttonvalue;
		}
	}
	return false;
}
// determine whether a text field on a form is empty
function isEmpty(inputStr)
{
	if (inputStr == null || inputStr == "")
	{
		return true;
	}
	return false;
}
// determine whether a string contains only positive integers
function isPosInteger(inputValue)
{
	inputStr = inputValue.toString()
	for (var digit = 0; digit < inputStr.length; digit++)
	{
		var oneChar = inputStr.charAt(digit);
		if (oneChar < "0" || oneChar > "9")
		{
			return false;
		}
	}
	return true;
}
// determine whether a field that is supposed to receive only numeric input 
// actually contains only positive integers by calling the "isPosInteger" function
function validateNumber(inputValue)
{
	var inputStr = "";
	inputStr = (inputValue);
	if (!isPosInteger(inputStr))
	{
		return true;
	}
	return false;
}
// validate email addresses
function validateEmail(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false}
		 if (str.indexOf(at,(lat+1))!=-1){
		    return false}
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false}
		 if (str.indexOf(dot,(lat+2))==-1){
		    return false}
		 if (str.indexOf(" ")!=-1){
		    return false}
 		 return true}
// begin to validate the form
function listSelectedItems(formName, selectName)
{
	var FormID					= new String("window.document." + formName + "." + selectName);
	var ElementIDCount			= new String(eval(FormID + ".options.length"));
	var sSelectString			= new String("");
	var iForIndex				= new Number(0);
	var iForIDCount				= new Number(0);
	
	for(iForIndex = 0; iForIndex < eval(ElementIDCount); iForIndex++)
	{
		//var ElementIDNumber			= new String(eval(FormID));
		//var ElementIDText			= new String(eval(FormID));
		if(eval(FormID + "[iForIndex].selected") == true)
		{
			if(iForIndex != 0)
			{
				if(sSelectString != "")
				{
					sSelectString += ", ";
				}
				if(iForIDCount == 5)
				{
					sSelectString += "\n                             ";
				}
				sSelectString += eval(FormID + "[iForIndex].text");
				iForIDCount += 1;
			}
		}		
	}
	if(sSelectString == "")
	{
		sSelectString = "None selected";
	}
	return sSelectString;
}

function valContactForm()
{
	// establish the variables
	var Form = "";
	var SubmitDate = "";
	var NameValue = "";
	var CompanyValue = "";
	var EmailValue = "";
	var AreaCodeValue = "";
	var Phone_complete = "";
	var InterestCount = "";
	var InterestList = "";
	var bFormValidate = "";

	// assign initial values to the variables
	Form = document.forms[0];
	SubmitDate = getCurrentDate();
	NameValue = Form.name.value;
	EmailValue = Form.email.value;
	Phone_complete = Form.phone.value;
	AlertMessage = "";
	bFormValidate = Boolean(true);

	//document.forms[0].recipient.value=EmailValue;
	//document.forms[0].Date.value = SubmitDate;


	// establish the beginning message that should be included in the alert message -
	// selection is based on which method of contact the user selects from a set of 
	// radio buttons
		AlertMessage = "We cannot process your information because the\nfollowing items are missing:\n\n";

	// if the "eMail address" field is empty, add to the alert message and set the form validation to "false"
	if(isEmpty(EmailValue))
	{
		AlertMessage += "Your eMail Address\n";
		bFormValidate = false;
	}
	else
	{
		if(validateEmail(EmailValue) == false)
		{
			AlertMessage += "A valid eMail Address\n";
			bFormValidate = false;
		}
	}
	
	// if any alert strings were generated, then construct the message and send it in an alert box
	if (bFormValidate == false)
	{
		alert(AlertMessage+ "\n\nPlease provide the missing information and resubmit.");
	}

	//otherwise, process the form
	if (bFormValidate == true)
	{
		Form.submit();
	}
}