﻿function VerifyEntries() {
//updated 12/15/2003, 2/23/2004 to combat SQL injection

//	declare variables
	var loginName
	var firstName	
	var lastName
	var jobTitle
	var companyName
	var address1
	var address2
	var city
	var state
	var zip
	var country
	var phone
	var fax
	var strEmail

//	set variable values
	loginName = document.LoginForm.LoginName.value
	firstName = document.LoginForm.FirstName.value
	lastName = document.LoginForm.LastName.value
	jobTitle = document.LoginForm.JobTitle.value
	companyName = document.LoginForm.CompanyName.value
	address1 = document.LoginForm.Address1.value
	address2 = document.LoginForm.Address2.value
	city = document.LoginForm.City.value
	state = document.LoginForm.State.value
	zip = document.LoginForm.Zip.value
	country = document.LoginForm.Country.value
	phone = document.LoginForm.CompanyPhone.value
	fax = document.LoginForm.CompanyFax.value
	strEmail = document.LoginForm.Email.value
	
//	check login name - disallow blank username, <6 or >15 char entries, special characters
	if (loginName == "") {
		alert('You must enter a login name.');
		document.LoginForm.LoginName.focus();
		return false;
	}
	if (loginName.length < 6 || loginName.length > 15 ) {
		alert('The Login name must be between 6 and 15 characters long.');
		document.LoginForm.LoginName.focus();
		return false;
	}
	if (CheckExtendedASCII(loginName) == false) {
		alert('The Login name may only contain alpha and numeric characters. Special characters are not allowed.')
		document.LoginForm.LoginName.focus();
		return false;
	}
	
//	check first name - disallow blanks, 15+ char entries, special characters except period & hyphen
	if (firstName == "") {
		alert('You must enter your first name.');
		document.LoginForm.FirstName.focus();
		return false;
	}
	if (firstName.length > 15) {
		alert('The first name cannot be more than 15 characters long.');
		document.LoginForm.FirstName.focus();
		return false;
	}
	if (CheckASCII_Alpha(firstName) == false) {
		alert('The first name may only contain alpha characters. Special characters are not allowed.')
		document.LoginForm.FirstName.focus();
		return false;
	}
	
//	check last name - disallow blanks, 20+ char entries, some special characters
//  handle apostrophe with DoubleApostrophe	function at server
	if (lastName == "") {
		alert('You must enter your last name.');
		document.LoginForm.LastName.focus();
		return false;
	}
	if (lastName.length > 20) {
		alert('The last name cannot be more than 20 characters long.');
		document.LoginForm.LastName.focus();
		return false;
	}
	if (CheckASCII_ProperName(lastName) == false) {
		alert('The last name may not contain special characters.')
		document.LoginForm.LastName.focus();
		return false;
	}
	
//	check job title - disallow blanks,  30+ char entries, some special characters
//  handle apostrophe with DoubleApostrophe	function at server
	if (jobTitle == "") {
		alert('You must enter your job title.');
		document.LoginForm.JobTitle.focus();
		return false;
	}
	if (jobTitle.length > 30) {
		alert('The Job Title cannot be more than 30 characters long.');
		document.LoginForm.JobTitle.focus();
		return false;
	}
	if (CheckASCII_JobCompany(jobTitle) == false) {
		alert('The Job Title may not contain special characters.')
		document.LoginForm.LoginName.focus();
		return false;
	}
	
//	check company name - disallow blanks, 50+ char entries, some special characters 
//  handle apostrophe with DoubleApostrophe	function at server
	if (companyName == "") {
		alert('You must enter your company name.');
		document.LoginForm.CompanyName.focus();
		return false;
	}
	if (companyName.length > 50) {
		alert('The Company name cannot be more than 50 characters long.');
		document.LoginForm.CompanyName.focus();
		return false;
	}
	if (CheckASCII_JobCompany(companyName) == false) {
		alert('The Company name may not contain special characters.')
		document.LoginForm.CompanyName.focus();
		return false;
	}
	
//	check 1st address line - disallow blanks, 50+ char entries, some special characters
//  handle apostrophe with DoubleApostrophe	function at server
	if (address1 == "") {
		alert('You must enter an address.');
		document.LoginForm.Address1.focus();
		return false;
	}
	if (address1.length > 50) {
		alert('The Address cannot be more than 50 characters long.');
		document.LoginForm.Address1.focus();
		return false;
	}
	if (CheckASCII_Address(address1) == false) {
		alert('The Address may not contain special characters.')
		document.LoginForm.Address1.focus();
		return false;
	}
	
//	check 2nd address line - disallow blanks, 50+ char entries, some special characters
//  handle apostrophe with DoubleApostrophe	function at server
//	if (address2 == "") {
//		alert('You must enter an address.');
//		document.LoginForm.Address2.focus();
//		return false;
//	}
	if (address2.length > 50) {
		alert('The Address cannot be more than 50 characters long.');
		document.LoginForm.Address2.focus();
		return false;
	}
	if (CheckASCII_Address(address2) == false) {
		alert('The Address may not contain special characters.')
		document.LoginForm.Address2.focus();
		return false;
	}	
	
//	check city - disallow blanks, 30+ char entries, some specials characters
//  handle apostrophe with DoubleApostrophe	function at server
	if (city == "") {
		alert('You must enter a city.');
		document.LoginForm.City.focus();
		return false;
	}
	if (city.length > 30) {
		alert('The City name cannot be more than 30 characters long.');
		document.LoginForm.City.focus();
		return false;
	}
	if (CheckASCII_ProperName(city) == false) {
		alert('The city name may not contain special characters.')
		document.LoginForm.City.focus();
		return false;
	}
	
//	check state - disallow blanks, 20+ char entries, special characters
	if (state == "") {
		alert('You must enter a state.');
		document.LoginForm.State.focus();
		return false;
	}
	if (state.length > 20) {
		alert('The State name cannot be more than 20 characters long.');
		document.LoginForm.State.focus();
		return false;
	}
	if (CheckASCII_StateCountry(state) == false) {
		alert('The State name may not contain special characters.')
		document.LoginForm.State.focus();
		return false;
	}
	
//	check zip - disallow blanks, 12+ char entries, special characters
	if (zip == "") {
		alert('You must enter a zip.');
		document.LoginForm.Zip.focus();
		return false;
	}
	if (zip.length > 12) {
		alert('The Zip code cannot be more than 12 characters long.');
		document.LoginForm.Zip.focus();
		return false;
	}
	if (CheckASCII_Zip(zip) == false) {
		alert('The Zip Code may not contain special characters.')
		document.LoginForm.Zip.focus();
		return false;
	}
	
//	check country - disallow blanks, 25+ char entries, special characters
//	if (country == "") {
//		alert('You must enter a country.');
//		document.LoginForm.Country.focus();
//		return false;
//	}

	var selectedItem = document.LoginForm.Country.selectedIndex;
	var selectedText = document.LoginForm.Country.options[selectedItem].text;
	
	if (selectedText == '(Select Country)') {
		alert('Please select a country from the drop-down list.');
		document.LoginForm.Country.focus();
		return false;
	}

//	check phone - non-numerics handled by input box, disallow blanks, 20+ char entries, ' 
	if (phone == "") {
		alert('You must enter a phone number.');
		document.LoginForm.CompanyPhone.focus();
		return false;
	}
	if (phone.length > 20) {
		alert('The phone number cannot be more than 20 characters long.');
		document.LoginForm.CompanyPhone.focus();
		return false;
	}
	if (CheckASCII_PhoneFax(phone) == false) {
		alert('The Phone Number may not contain special characters.')
		document.LoginForm.CompanyPhone.focus();
		return false;
	}
	
//	check fax - non-numerics handled by input box, disallow 20+ char entries, ' 
	if (fax.length > 20) {
		alert('The fax number cannot be more than 20 characters long.');
		document.LoginForm.CompanyFax.focus();
		return false;
	}
	if (CheckASCII_PhoneFax(fax) == false) {
		alert('The Fax Number may not contain special characters.')
		document.LoginForm.CompanyFax.focus();
		return false;
	}
	
//	check email - disallow blanks, emailCheck handles special characters
	if (strEmail == "") {
		alert('You must enter your Email Address.');
		document.LoginForm.Email.focus();
		return false;
	}
	if (strEmail.length > 85) {
		alert('The email address cannot be more than 85 characters long.');
		document.LoginForm.Email.focus();
		return false;
	}
	if (emailCheck(strEmail) == false) {	
		alert('The email address provided cannot be processed.')
		document.LoginForm.Email.focus();
		return false;
	}	
	
//	everything checks out, process request
	document.LoginForm.OKToSend.value="True"
	document.LoginForm.submit()
}

