// JavaScript Documentfunction isLetter(c)
{
	if(((c < "a") || (c > "z")) && ((c < "A") || (c > "Z")))
	{
		return false;
	}//end if
	return true;
}//end isAlpha()

/**
*Checks for alphabetic characters, hyphens and spaces
*/
function isAlpha(c)
{
	if(((c < "a") || (c > "z")) && ((c < "A") || (c > "Z")) && ((c != "-") && (c != " ")))
	{
		return false;
	}//end if
	return true;
}//end isAlpha()

/**
*Checks for numeric characters
*/
function isNumber(c)
{
	if((c < "0") || (c > "9"))
	{
		return false;
	}//end if
	return true;
}//end isNumber

/**
*Checks for numeric characters, () and -
*/
function isPhoneNumber(c)
{
	if(((c < "0") || (c > "9")) && ((c != "(") && (c != ")") && (c != "-")))
	{
		return false;
	}//end if
	return true;
}//end isNumber

/**
*Checks for alphanumeric characters, spaces, hyphens, periods and pound
*/
function isAlphaNum(c)
{
	if(((c < "0") || (c > "9")) && (((c < "a") || (c > "z")) && ((c < "A") || (c > "Z")) && (c != " ") && (c != "-") && (c != ".") && (c != "#")))
	{
		return false;
	}//end if
	return true;
}//end isAlphaNum()

/**
*Makes sure that the fname field has been filled and contains appropriate characters
*/
function checkFName()
{
	var fname = document.form.fname.value;
	
	if((fname == "") || (fname == null))
	{
		document.form.fname.style.color = "FFFFFF";
		document.form.fname.style.backgroundColor = "FF0000";
		return false;
	}//end if
	
	for(var i = 0; i < fname.length; i+=1)
	{
		var isGood = isAlpha(fname.charAt(i));
		if(!isGood)
		{
			document.form.fname.style.color = "FFFFFF";
			document.form.fname.style.backgroundColor = "FF0000";
			return false;
		}//end if
	}//end for
	return true;
}//end checkFName()

/**
*Makes sure that the lname field has been filled and contains appropriate characters
*/
function checkLName()
{
	var lname = document.form.lname.value;	
		
	if((lname == "") || (lname == null))
	{
		document.form.lname.style.color = "FFFFFF";
		document.form.lname.style.backgroundColor = "FF0000";
		return false;
	}//end if	
		
	for(var i = 0; i < lname.length; i+=1)
	{
		var isGood = isAlpha(lname.charAt(i));
		if(!isGood)
		{
			document.form.lname.style.color = "FFFFFF";
			document.form.lname.style.backgroundColor = "FF0000";
			return false;
		}//end if
	}//end for
	return true;
}//end checkLName()

function checkPhone()
{
	var phone = document.form.phone.value;
	
	if(phone == null || phone == "")
	{
		document.form.phone.style.color = "FFFFFF";
		document.form.phone.style.backgroundColor = "FF0000";
		return false;
	}//end if
	
	for(var i = 0; i < phone.length; i += 1)
	{
		var isGood = isPhoneNumber(phone.charAt(i));
		
		if(!isGood)
		{
			document.form.phone.style.color = "FFFFFF";
			document.form.phone.style.backgroundColor = "FF0000";
			return false;
		}//end if
	}//end for
	return true;
}//end checkPhone()

/**
*Checks to make sure a valid email address has been added
*/
function checkEmail() 
{
	var email = document.form.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.ca)|(\..{2,2}))$)\b/gi);
	
	if (email)
	{
	    return true;
	}//end if
	else 
	{
		document.form.email.style.color = "FFFFFF";
		document.form.email.style.backgroundColor = "FF0000";
	    return false;
	}//end if
}//end checkEmail()

/**
*Checks to make sure the address field is filled out
*/
function checkAddress()
{
	var address = document.form.address.value;
	
	if((address == "") || (address == null))
	{
		document.form.address.style.color = "FFFFFF";
		document.form.address.style.backgroundColor = "FF0000";
		return false;
	}//end if
	
	for(var i = 0; i < address.length; i+=1)
	{
		var isGood = isAlphaNum(address.charAt(i));
		
		if(!isGood)
		{
			document.form.address.style.color = "FFFFFF";
			document.form.address.style.backgroundColor = "FF0000";
			return false;
		}//end if
	}//end for
	return true;
}//end checkAddress

/**
*Checks to see if the 2nd address line has been filled and verifies that the info is correct if it has
*/
function checkAddress2()
{
	var address = document.form.address2.value;
	
	if((address == "") || (address == null))
	{
		return true;
	}//end if
	else
	{
		for(var i = 0; i < address.length; i+=1)
		{
			var isGood = isAlphaNum(address.charAt(i));
			
			if(!isGood)
			{
				document.form.address2.style.color = "FFFFFF";
				document.form.address2.style.backgroundColor = "FF0000";
				return false;
			}//end if
		}//end for
		return true;
	}//end else
}//end checkAddress2()

/**
*Checks to make sure the city field has been filled and contains correct characters
*/
function checkCity()
{
	var city = document.form.city.value;
	
	if((city == "") || (city == null))
	{
		document.form.city.style.color = "FFFFFF";
		document.form.city.style.backgroundColor = "FF0000";
		return false;
	}//end if
	
	for(var i = 0; i < city.length; i+=1)
	{
		var isGood = isAlpha(city.charAt(i));
		
		if(!isGood)
		{
			document.form.city.style.color = "FFFFFF";
			document.form.city.style.backgroundColor = "FF0000";
			return false;
		}//end if
	}//end for
	return true;
}//end checkCity()

/**
*Checks to see that a country has been chosen
*/
function checkCountry()
{
	if(document.form.country.options[0].selected)
	{
		document.form.country.style.color = "FFFFFF";
		document.form.country.style.backgroundColor = "FF0000";
		return false;
	}//end if
	else
	{
		var country = document.form.country.value;
		if(country == "OTH")
		{
			var name = document.form.othercountry.value;
			
			if((name == "") || (name == null))
			{
				document.form.othercountry.style.color = "FFFFFF";
				document.form.othercountry.style.backgroundColor = "FF0000";
				return false;
			}//end if
			
			for(var i = 0; i < name.length; i+=1)
			{
				var isGood = isAlpha(name.charAt(i));
				
				if(!isGood)
				{
					document.form.othercountry.style.color = "FFFFFF";
					document.form.othercountry.style.backgroundColor = "FF0000";
					return false;
				}//end if
			}//end for
		}//end if
	}//end else
	return true;
}//end checkCountry()

/**
*Checks to make sure the province/state was selectec if country is Canada or US
*/
function checkProvince()
{
	var country = document.form.country.value;
	var otherprovince = document.form.otherprovince.value;
	
	if(country == "US" || country == "CA")
	{
		if(document.form.province.options[0].selected == true)
		{
			document.form.province.style.color = "FFFFFF";
			document.form.province.style.backgroundColor = "FF0000";
			return false;
		}//end if
		return true;
	}//end if
	else if(country == "OTH")
	{
		if(otherprovince == null || otherprovince == "")
		{
			document.form.otherprovince.style.color = "FFFFFF";
			document.form.otherprovince.style.backgroundColor = "FF0000";
			return false;
		}//end if
		
		for(var i = 0; i < otherprovince.length; i += 1)
		{
			var isGood = isLetter(otherprovince.charAt(i));
			
			if(!isGood)
			{
				document.form.otherprovince.style.color = "FFFFFF";
				document.form.otherprovince.style.backgroundColor = "FF0000";
				return false;
			}//end if
		}//end for
		return true;
	}//end if
}//end checkProvince

/**
*Checks to make sure the postal code is valid if client chose US or Canada as a contry
*/
function checkPostalCode()
{
	var country = document.form.country.value;
	var test = document.form.postalcode.value;
	if(test == null || test == "")
	{
		document.form.postalcode.style.color = "FFFFFF";
		document.form.postalcode.style.backgroundColor = "FF0000";
		return false;
	}//end if
	
	if(country == "CA")
	{
		if(test.length != 6)
		{
			document.form.postalcode.style.color = "FFFFFF";
			document.form.postalcode.style.backgroundColor = "FF0000";
			return false;
		}//end if
		else
		{
			for(i=0;i<test.length;i+=1)
			{
				var isGood = true;
				if(i==0 || i==2 || i==4)
				{
					isGood = isLetter(test.charAt(i));
					if(!isGood)
					{
						document.form.postalcode.style.color = "FFFFFF";
						document.form.postalcode.style.backgroundColor = "FF0000";
						return false;
					}//end if
				}//end if
				else
				{
					if(i==1 || i==3 || i==5)
					{
						isGood = isNumber(test.charAt(i));
						if(!isGood)
						{
							document.form.postalcode.style.color = "FFFFFF";
							document.form.postalcode.style.backgroundColor = "FF0000";
							return false;
						}//end if
					}//end if
				}//end else
			}//end for
		}//end else
	}//end if
	else
	{
		if(country == "US")
		{
			if(test.length != 5)
			{
				document.form.postalcode.style.color = "FFFFFF";
				document.form.postalcode.style.backgroundColor = "FF0000";
				return false
			}//end if
			for(i = 0; i < test.length; i += 1)
			{
				var isGood = isNumber(test.charAt(i));
				if(!isGood)
				{
					document.form.postalcode.style.color = "FFFFFF";
					document.form.postalcode.style.backgroundColor = "FF0000";
					return false;
				}//end if
			}//end for
		}//end if 
	}//end else
	return true;
}//end checkPostalCode

/**
*Runs all the validation methods and gives ok to send email if all information is correct
*/
function checkAll()
{
	if(!checkFName())
	{
		return false;
	}//end if
	
	if(!checkLName())
	{
		return false;
	}//end if
	
	if(!checkPhone())
	{
		return false;
	}//end if
	
	if(!checkEmail())
	{
		return false;
	}//end if
	
	if(!checkAddress())
	{
		return false;
	}//end if
	
	if(!checkAddress2())
	{
		return false;
	}//end if
	
	if(!checkCity())
	{
		return false;
	}//end if
	
	if(!checkCountry())
	{
		return false;
	}//end if
	
	if(!checkProvince())
	{
		return false;
	}//end if
	
	if(!checkPostalCode())
	{
		return false;
	}//end if
	return true;
}//end checkAll

function resetDisable()
{
	document.form.othercountry.disabled = true;
}//end resetDisable()

function changeColor(c)
{
	c.style.color = "#000000";
	c.style.backgroundColor = "#FFFFFF";
}//end changeColor()
//-->
