function validateField(field, alerttxt)
{
	with (field)
	{
		if (value == null || value == "")
		{
			alert(alerttxt);
			return false;
		}
		else
		{
			return true;
		}
	}
}

function validateEmail(field, alerttxt)
{
	with (field)
	{
		apos	= value.indexOf("@");
		dotpos	= value.lastIndexOf(".");
		
		if (apos < 1 || dotpos-apos < 2) 
		{
			alert(alerttxt);
			return false;
		}
		else
		{
			return true;
		}
	}
}

function trim(string)
{
	return string.replace(/^\s+|\s+$/g, "");
}

function isInt(s, l)
{
	var n = trim(s.value);
	return (n.length == l && !(/[^0-9]/).test(n));
}

function validatePhoneNumber(field1, field2, field3, alerttxt)
{	
	if (!isInt(field1, 3) || !isInt(field2, 3) || !isInt(field3, 4))
	{
		alert(alerttxt);
		return false;
	}
	else
	{
		return true;
	}
}

function validatePasswords(pass1, pass2, alerttxt)
{
	if(pass1.value != pass2.value)
	{
		alert(alerttxt);
		return false;	
	}
	else
	{
		return true;	
	}
}

function validateForm(thisform)
{	
	with (thisform)
	{	
		if (validateField(Contact_Name, "First Name must be filled out!") == false)
		{
			return false;
		}
		if (validateField(Last_Name, "Last Name must be filled out!") == false)
		{
			return false;
		}
		if (validateField(Title_Position, "Title/Position must be filled out!") == false)
		{
			return false;
		}
		if (validateField(Address, "Address must be filled out!") == false)
		{
			return false;
		}
		if (validateField(City, "City must be filled out!") == false)
		{
			return false;
		}
		if (validateField(State, "State must be filled out!") == false)
		{
			return false;
		}
		if (validateField(Zip, "ZIP must be filled out!") == false)
		{
			return false;
		}
		if (validateField(Day_Phone, "Day Phone must be filled out!") == false)
		{
			return false;
		}
		if (validateField(Night_Phone, "Night Phone must be filled out!") == false)
		{
			return false;
		}
		if (validateField(Email_Address, "Email must be filled out!") == false)
		{
			return false;
		}
		if (validateEmail(Email_Address, "Email is in an invalid format!") == false)
		{
			return false;
		}
		if (validateField(Product_or_Service, "Product or Service must be filled out!") == false)
		{
			return false;
		}
		if (validateField(Which_shows_are_of_interest, "Shows of Interest must be filled out!") == false)
		{
			return false;
		}
	}
}