function resizeimage(id)
{
	var picwidth=0;
	picw=document.getElementById(id).width;
	pich=document.getElementById(id).height;
	
	if (picw >= pich)
	{
		if (picw > 200)
		{
			document.getElementById(id).width=200;
		}
	}
	else
	{
		if (pich > 200)
		{
			document.getElementById(id).height=200;
		}
	}
}

function moverout(id, color)
{
	document.getElementById(id).style.color=color;
}

function checknumber(id)
{
	var input = document.getElementById(id).value;
	
	if (input != "")
	{
		if (input.lastIndexOf(".") == -1)
		{
			var num = new Number(input);
			
			if (isNaN(num) || num == 0)
			{
				alert("Entry is not valid");
				document.getElementById(id).value = "";
				document.getElementById(id).focus();
			}
		}
		else
		{
			alert("Entry is not valid");
			document.getElementById(id).value = "";
			document.getElementById(id).focus();
		}
	}
}

function checknophone()
{
	if (document.getElementById('nophone').checked == true)
	{
		document.getElementById('phone1').value = "";
		document.getElementById('phone2').value = "";
		document.getElementById('phone3').value = "";
		
		document.getElementById('phone1').disabled = true;
		document.getElementById('phone2').disabled = true;
		document.getElementById('phone3').disabled = true;
	}
	else
	{
		document.getElementById('phone1').disabled = false;
		document.getElementById('phone2').disabled = false;
		document.getElementById('phone3').disabled = false;
	}
}

function checkmemberapp()
{
	var name=document.getElementById('name').value;
	var business=document.getElementById('business').value;
	var address=document.getElementById('address').value;
	var city=document.getElementById('city').value;
	var state=document.getElementById('state').value;
	var zip=document.getElementById('zip').value;
	var phone1=document.getElementById('phone1').value;
	var phone2=document.getElementById('phone2').value;
	var phone3=document.getElementById('phone3').value;
	var email=document.getElementById('email').value;
	var reason=document.getElementById('reason').value;

	var name_ok=true;
	if (name == "") 
	{
		name_ok=false;
	}
	else
	{
		if (name.match("@") == "@" || name.match("href") == "href" || name.match("http://") == "http://" || name.match("https://") == "https://")
		{
			name_ok=false;
		}
	}
	
	var business_ok=true;
	if (business == "") 
	{
		business_ok=false;
	}
	else
	{
		if (business.match("@") == "@" || business.match("href") == "href" || business.match("http://") == "http://" || business.match("https://") == "https://")
		{
			business_ok=false;
		}
	}
	
	var address_ok=true;
	if (address == "")
	{
		address_ok=false;
	}
	else
	{
		if (address.match("@") == "@" || address.match("href") == "href" || address.match("http://") == "http://" || address.match("https://") == "https://")
		{
			address_ok=false;
		}
	}
	
	if (city == "")
	{
		address_ok=false;
	}
	else
	{
		if (city.match("@") == "@" || city.match("href") == "href" || city.match("http://") == "http://" || city.match("https://") == "https://")
		{
			address_ok=false;
		}
	}

	if (state == "")
	{
		address_ok=false;
	}
	else
	{
		if (state.length != 2)
		{
			address_ok=false;
		}
	}

	if (zip == "")
	{
		address_ok=false;
	}
	else
	{
		if (zip.length != 5)
		{
			address_ok=false;
		}
	}
	
	var phone_ok = true;
	if (document.getElementById('nophone').checked == false)
	{
		if (phone1 == "" && phone2 == "" && phone3 == "") 
		{
			phone_ok = false;
		}
		else
		{
			if (phone1 == "" || phone2 == "" || phone3 == "") 
			{
				phone_ok = false;
			}
			else
			{
				if (phone1.length != 3 || phone2.length != 3 || phone3.length != 4)
				{
					phone_ok = false;
				}
			}
		}
	}
	
	var email_ok = true;
	if (email == "") 
	{
		email_ok = false;
	}
	else
	{
		if (email.match("href") == "href" || email.match("http://") == "http://" || email.match("https://") == "https://") 
		{
			email_ok = false;
		}
		else
		{
			var apos = email.indexOf("@");
			var dotpos = email.lastIndexOf(".");
			if (apos < 1 || dotpos-apos < 2)
			{
				email_ok = false;
			}
		}
	}
	
	var reason_ok=true;
	if (reason == "")
	{
		reason_ok=false;
	}
	else
	{
		if (reason.match("@") == "@" || reason.match("href") == "href" || reason.match("http://") == "http://" || reason.match("https://") == "https://")
		{
			reason_ok=false;
		}
	}
	
	form_ok=(name_ok && business_ok && address_ok && phone_ok && email_ok && reason_ok);
	
	if (!form_ok)
	{
		if (!name_ok) 
		{
			alert("Please enter your name.");
		}
		else
		{
			if (!business_ok) 
			{
				alert("Please enter your business name.");
			}
			else
			{
				if (!address_ok) 
				{
					alert("Please enter a complete address.");
				}
				else
				{
					if (!phone_ok) 
					{
						alert("Please enter a complete phone number.");
					}
					else
					{
						if (!email_ok) 
						{
							alert("Please enter a valid email address.");
						}
						else
						{
							if (!reason_ok) 
							{
								alert("Please enter a reason for joining our organization.");
							}
						}
					}
				}
			}
		}
	}
	
	return form_ok;
}

function checkcontact()
{
	var name=document.getElementById('name').value;
	var business=document.getElementById('business').value;
	var address=document.getElementById('address').value;
	var city=document.getElementById('city').value;
	var state=document.getElementById('state').value;
	var zip=document.getElementById('zip').value;
	var phone1=document.getElementById('phone1').value;
	var phone2=document.getElementById('phone2').value;
	var phone3=document.getElementById('phone3').value;
	var email=document.getElementById('email').value;
	var comments=document.getElementById('comments').value;

	var name_ok=true;
	if (name == "") 
	{
		name_ok=false;
	}
	else
	{
		if (name.match("@") == "@" || name.match("href") == "href" || name.match("http://") == "http://" || name.match("https://") == "https://")
		{
			name_ok=false;
		}
	}
	
	var business_ok=true;
	if (business == "") 
	{
		business_ok=false;
	}
	else
	{
		if (business.match("@") == "@" || business.match("href") == "href" || business.match("http://") == "http://" || business.match("https://") == "https://")
		{
			business_ok=false;
		}
	}
	
	var address_ok=true;
	if (address == "")
	{
		address_ok=false;
	}
	else
	{
		if (address.match("@") == "@" || address.match("href") == "href" || address.match("http://") == "http://" || address.match("https://") == "https://")
		{
			address_ok=false;
		}
	}
	
	if (city == "")
	{
		address_ok=false;
	}
	else
	{
		if (city.match("@") == "@" || city.match("href") == "href" || city.match("http://") == "http://" || city.match("https://") == "https://")
		{
			address_ok=false;
		}
	}

	if (state == "")
	{
		address_ok=false;
	}
	else
	{
		if (state.length != 2)
		{
			address_ok=false;
		}
	}

	if (zip == "")
	{
		address_ok=false;
	}
	else
	{
		if (zip.length != 5)
		{
			address_ok=false;
		}
	}
	
	var phone_ok = true;
	if (document.getElementById('nophone').checked == false)
	{
		if (phone1 == "" && phone2 == "" && phone3 == "") 
		{
			phone_ok = false;
		}
		else
		{
			if (phone1 == "" || phone2 == "" || phone3 == "") 
			{
				phone_ok = false;
			}
			else
			{
				if (phone1.length != 3 || phone2.length != 3 || phone3.length != 4)
				{
					phone_ok = false;
				}
			}
		}
	}
	
	var email_ok = true;
	if (email == "") 
	{
		email_ok = false;
	}
	else
	{
		if (email.match("href") == "href" || email.match("http://") == "http://" || email.match("https://") == "https://") 
		{
			email_ok = false;
		}
		else
		{
			var apos = email.indexOf("@");
			var dotpos = email.lastIndexOf(".");
			if (apos < 1 || dotpos-apos < 2)
			{
				email_ok = false;
			}
		}
	}
	
	var comments_ok=true;
	if (comments == "")
	{
		comments_ok=false;
	}
	else
	{
		if (comments.match("@") == "@" || comments.match("href") == "href" || comments.match("http://") == "http://" || comments.match("https://") == "https://")
		{
			comments_ok=false;
		}
	}
	
	form_ok=(name_ok && business_ok && address_ok && phone_ok && email_ok && comments_ok);
	
	if (!form_ok)
	{
		if (!name_ok) 
		{
			alert("Please enter your name.");
		}
		else
		{
			if (!business_ok) 
			{
				alert("Please enter your business name.");
			}
			else
			{
				if (!address_ok) 
				{
					alert("Please enter a complete address.");
				}
				else
				{
					if (!phone_ok) 
					{
						alert("Please enter a complete phone number.");
					}
					else
					{
						if (!email_ok) 
						{
							alert("Please enter a valid email address.");
						}
						else
						{
							if (!comments_ok) 
							{
								alert("Please enter a reason for joining our organization.");
							}
						}
					}
				}
			}
		}
	}
	
	return form_ok;
}
