
function setColor (el, bg) {
	if (el.style) el.style.backgroundColor = bg;
}

function isNum(passedVal)
	{
		if (passedVal == "")
			{
				return false
			}
		for (i=0; i<passedVal.length; i++)
			{
				if ((passedVal.charAt(i) < "0") || (passedVal.charAt(i) > "9"))
				{
						return false
				}
				else
				{
						return true	
				}
					
			}
	}
	
function validZip(inzip)
	{
		if (inzip == "")
			{
				return true;
			}
		if (isNum(inzip))
			{
				return true;
			}
		else
		{
			return false;
		}
	}			



function checkInput(form) 
{
	var bgBad = "yellow";
	var bgGood = "white";
	var valid = true;
		
		if (!form.company.value) 
			{
				valid = false;
				setColor (form.company, bgBad);
				alert ("Please fill in the company name.");
				form.company.focus();
				return valid;
			} 
		
		if (!form.name.value) 
			{
				valid = false;
				setColor (form.name, bgBad);
				alert ("Please fill in the name.");
				form.name.focus();
				return valid;
			} 

		if (!form.position.value) 
			{
				valid = false;
				setColor (form.position, bgBad);
				alert ("Please fill in the position.");
				form.position.focus();
				return valid;
			}
			 
		if (!form.address.value)
			{
				valid = false;
				setColor (form.address, bgBad);
				alert ("Please fill in the address.");
				form.address.focus();
				return valid;
			} 
					
		if (!form.city.value)
			{
				valid = false;
				setColor (form.city, bgBad);
				alert ("Please fill in the city.");
				form.city.focus();
				return valid;
			} 
			
		if (!form.state.value) 
			{
				valid = false;
				setColor (form.state, bgBad);
				alert ("Please fill in the state.");
				form.state.focus();
				return valid;
			} 

		if (!form.zip.value) 
			{
				valid = false;
				setColor (form.zip, bgBad);
				alert ("Please fill in the zip code.");
				form.zip.focus();
				return valid;
			} 
		
		if (!form.phone.value) 
			{
				valid = false;
				setColor (form.phone, bgBad);
				alert ("Please fill in the phone.");
				form.phone.focus();
				return valid;
			} 

		if (!form.email.value) 
			{
				valid = false;
				setColor (form.email, bgBad);
				alert ("Please fill in the Email Address.");
				form.email.focus();
				return valid;
			} 


}
  
