
function digitvalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") 
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function ValidateForm(theForm) {

		if (theForm.first_name.value == "") {
			alert("Please enter your first name");
			theForm.first_name.focus();
			return (false);
		}

		if (theForm.last_name.value == "") {
			alert("Please enter your last name");
			theForm.last_name.focus();
			return (false);
		}
		
		if (theForm.email.value == "") {
			alert("Please enter your Email address");
			theForm.email.focus();
			return (false);
		}
		
		if (theForm.org_name.value == "") {
			alert("Please enter your group name");
			theForm.org_name.focus();
			return (false);
		}

		if (theForm.address_bil.value == "") {
			alert("Please enter your address");
			theForm.address_bil.focus();
			return (false);
		}	

		if (theForm.city_bil.value == "") {
			alert("Please enter your city's name");
			theForm.city_bil.focus();
			return (false);
		}

		if (theForm.us_state_id_bil.value == "") {
			alert("Please select your state");
			theForm.us_state_id_bil.focus();
			return (false);
		}
		
		if (theForm.country_id_bil.value == "") {
			alert("Please select your Country");
			theForm.country_id_bil.focus();
			return (false);
		}

		if (theForm.zip_code_bil.value == "") {
			alert("Please enter your ZIP code");
			theForm.zip_code_bil.focus();
			return (false);
		}
		
		if (theForm.tel1.value == "") {
			alert("Please enter your phone number");
			theForm.tel1.focus();
			return (false);
		}
		
		if (theForm.tel1_id.value == "") {
			alert("Please select a phone number location");
			theForm.tel1_id.focus();
			return (false);
		}
		
		if (theForm.type_org_id.value == "") {
			alert("Please select your organization type");
			theForm.type_org_id.focus();
			return (false);
		}
		
		if (theForm.subtype_org_id.value == "") {
			alert("Please select your group type");
			theForm.subtype_org_id.focus();
			return (false);
		}

		if (digitvalidation(theForm.members,0,5000,"Please enter the size of your group","I")==false) 
		{theForm.members.focus(); 
		return false;};
		
		if (digitvalidation(theForm.month,1,12,"Please select month(s) your group fundraises","I")==false) 
		{theForm.month.focus(); 
		return false;};
		
		if (theForm.item_id.value == "0") {
			alert("Please select the fundraiser(s) that interest you");
			theForm.item_id.focus();
			return (false);
		}
		
		if (theForm.company_id.value == "0") {
			alert("Please select the fundraising companie(s) to send you information");
			theForm.company_id.focus();
			return (false);
		}

		theForm.first_name.value = theForm.first_name.value.toUpperCase();
		theForm.last_name.value = theForm.last_name.value.toUpperCase();
		theForm.org_name.value = theForm.org_name.value.toUpperCase();
		theForm.address_bil.value = theForm.address_bil.value.toUpperCase();
		theForm.city_bil.value = theForm.city_bil.value.toUpperCase();
		theForm.zip_code_bil.value = theForm.zip_code_bil.value.toUpperCase();
		return (true);
}
