
function TestInput() {
var r;
var a;
var error;
var op;
var cp;
var dc;
var charcount;
op = 0;
cp = 0;
dc = 0;
var text;
var char;
var fn;
var ln;
r = 1;
//get the first char of the name
text = document.inventorsubmissiononline.FirstName.value;
if (text.length > 0)
{
	fn = text.charAt(0).toUpperCase();
}
else
{
	r = 0;
	alert("Please enter a First Name");
}

text = document.inventorsubmissiononline.LastName.value;
if (text.length > 0)
{
	ln = text.charAt(0).toUpperCase();
}
else
{
	r = 0;
	alert("Please enter a Last Name");
}

error = 0;
text = document.inventorsubmissiononline.Initials.value;
if (text.length > 1)
{
	if ((text.toUpperCase().indexOf(fn) == -1) || (text.toUpperCase().indexOf(ln) == -1))
	{
		error = 1;
	}
}
else
{
	error = 1;
}

if (error == 1)
{
	r = 0;
	alert("Please type your initials");
}

text = document.inventorsubmissiononline.Email.value;
if ((((text.indexOf("@") == -1) || (text.indexOf(".") == -1)) || (text.length < 5)) && (text.length > 0))
{
	r = 0;
	alert("Please enter a valid email address");
}
//look in chars for telephone
error = 0;
charcount = 0;
text = document.inventorsubmissiononline.PhoneNumber.value;
for(a=0;a<text.length;a++)
{
	char = text.charAt(a);
	if (((char < '0') || (char > '9')) && (char != '-') && (char != '(') && (char != ')'))
	{
		error = 1;
	}
	else
	{
		charcount++;
	}
	if ((char == '('))
	{
		op++;
		charcount--;
	}
	if ((char == ')'))
	{
		cp++;
		charcount--;
	}
	if ((char == '-'))
	{
		dc++;
		charcount--;
	}
}
if ((document.inventorsubmissiononline.PhoneNumber.value.length == 0) && (document.inventorsubmissiononline.Email.value.length == 0))
{
	r = 0;
	alert("Please enter a phone number and/or email address");
}
if (op != cp)
{
	error = 1;
}
if ((charcount != 10) && (charcount > 0))
{
	error = 1;
}
if (dc > 2)
{
	error = 1;
}
if (error == 1)
{
	r = 0;
	alert("Please enter a valid phone number with area code");
}
if (document.inventorsubmissiononline.C1.checked == false)
{
	r = 0;
	alert("Please check the older than 18 box");
}
if (r != 0)
{
	document.inventorsubmissiononline.submit();
}
return(r);
}