function validInput() {
	var orderemail = window.document.auth.orderemail.value;
	var productid = window.document.auth.productid.value;
	var inputstring = window.document.auth.inputstring.value;

	if (!validEmail(orderemail)) {
		alert("Enter the email address to which the authorization string is to be sent.")
		window.document.auth.orderemail.focus()
		return false
	}
	
	if (productid.length != 10) {
		alert("The Product ID is not valid, please re-enter!")
		window.document.auth.productid.focus()
		window.document.auth.productid.select()
		return false
	}

	if (inputstring.length != 10) {
		alert("The Input String is not valid, please Re-enter!")
		window.document.auth.inputstring.focus()
		window.document.auth.inputstring.select()
		return false
	}
}


/*------------------------------------------------------*/
function validEmail(email) { 
	//alert(email);

	// email adress must be 5 characters
	if (email.length<5) {
		return false
	}

	// checking for bad characters
	invalidChars = " /:,;"
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) != -1) {
			return false
		}
	}

	// check for @
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
	
	// make sure there's only one @
	if (email.indexOf("@",atPos+1) != -1) {
		return false
	}

	// must include at least one .
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}

	// TLDs > 3 characters or TLDs < 2 are rejected
	re		= /\.([a-zA-Z]*)$/;
	tld		= email.match(re);

	re		= /aero|coop|info|jobs|mobi|name/;
	if ((tld[1].length > 3 || tld[1].length < 2) && (email.search(re) == -1)) {
		return false
	}

	// additional email address validation using a regular expression
	if (!verifyEmail(email)) {
		return false
	}

	return true
}

/*------------------------------------------------------*/
function verifyEmail(emailaddress) {
	//return false;

	//re		= /[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9\w]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	re		= /[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9\w]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]*\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;

	srch	= emailaddress.search(re);

	if (srch<0) {
		return false;
	} else {
		return true
	}
	return true;

}

