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 valGenlCUForm()
{
	// establish the variables
	var Form 					= "";
	var NameValue 				= new String("");
	var CompanyValue 			= new String("");
	var EmailValue 				= new String("");
	var AlertMessage 			= new String("");
	
	// assign initial values to the variables
	Form 						= document.forms[0];
	NameValue 					= Form.name.value;
	CompanyValue 				= Form.company.value;
	EmailValue 					= Form.email.value;
	
	var bFormValidate 			= new Boolean(true);
	
		

	// 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 "name" field is empty, add to the alert message and set the form validation to "false"
	if (isEmpty(NameValue))
	{
		AlertMessage += "Your Name\n";
		bFormValidate = false;
	}

	// if the "company name" field is empty, add to the alert message and set the form validation to "false"
	if (isEmpty(CompanyValue))
	{
		AlertMessage += "Company's Name\n";
		bFormValidate = false;
	}

	// 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)
	{		
		document.cookie = "name=";
		document.cookie = "company=";
		document.cookie = "email=";
		document.cookie = "phone=";
		document.cookie = "ext=";
		document.cookie = "fax=";
		document.cookie = "add1=";
		document.cookie = "add2=";
		document.cookie = "city=";
		document.cookie = "state=";
		document.cookie = "zip=";
		//document.cookie = "topic=";
  		document.cookie = "comments=";
  		document.cookie = "mailingList=";
		Form.submit();
	}
}

//Begin functions for retaining form field values on contact form
function name_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.name.value);
	document.cookie = "name=" + myString;
}

function company_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.company.value);
	document.cookie = "company=" + myString;
}

function email_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.email.value);
	document.cookie = "email=" + myString;
}

function phone_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.phone.value);
	document.cookie = "phone=" + myString;
}

function ext_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.ext.value);
	document.cookie = "ext=" + myString;
}

function fax_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.fax.value);
	document.cookie = "fax=" + myString;
}

function add1_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.add1.value);
	document.cookie = "add1=" + myString;
}

function add2_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.add2.value);
	document.cookie = "add2=" + myString;
}

function city_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.city.value);
	document.cookie = "city=" + myString;
}

function state_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.state.value);
	document.cookie = "state=" + myString;
}

function zip_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.zip.value);
	document.cookie = "zip=" + myString;
}

//function topic_changed()
//{
//	var form = "";
//	form = document.forms[0];
//	var myString = escape(form.topic.value);
//	document.cookie = "topic=" + myString;
//}

function comments_changed()
{
	var form = "";
	form = document.forms[0];
	var myString = escape(form.comments.value);
	document.cookie = "comments=" + myString;
}

function validate()
{
  var form = "";
  form = document.forms[0];
  if (form.Join.checked)
  {
    document.cookie = "mailingList=checked";
  }
  else
  {
    document.cookie = "mailingList=";
  }
}


function clear_all()
{
  document.cookie = "name=";
  document.cookie = "company=";
  document.cookie = "email=";
  document.cookie = "phone=";
  document.cookie = "ext=";
  document.cookie = "fax=";
  document.cookie = "add1=";
  document.cookie = "add2=";
  document.cookie = "city=";
  document.cookie = "state=";
  document.cookie = "zip=";
  //document.cookie = "topic=";
  document.cookie = "comments=";
  document.cookie = "mailingList=";
  window.location.reload();
}

//End functions for retaining form field values on contact form