function validateEntry(form)
{
	var missinginfo = "";
	var theItem="";
	
	var mail="no"
	
	if(!form.nameinsured || !form.companyname || !form.phonenumber || !form.hearaboutus || !form.signaturename || !form.yearEstablished || !form.companyaddress || !form.companycity || !form.companystate || !form.companyzip)
	{
		alert("Error: Form configured improperly. Please notify site administrator.");
		return false;
	}
	
		var i;
	var selected = -1;
	
	for(i = form.memberType.length - 1; i >= 0 ; i--)
	{
		if(form.memberType[i].checked)
			{
			selected = i; 
			i = -1;
			}
	}	
	if(selected < 0) {
		missinginfo += "\n     -  Member Type";
		if(theItem == ""){theItem = eval("form.memberType[0]")}
	}
	
	if(form.nameinsured.value == "") {
		missinginfo += "\n     -  Name Insured";
		if(theItem == ""){theItem = eval("form.nameinsured")}
	}
	if(form.companyname.value == "") {
		missinginfo += "\n     -  Company Name";
		if(theItem == ""){theItem = eval("form.companyname")}
	}
	
		
	var i;
	var selected = -1;
	
	for(i = form.entity.length - 1; i >= 0 ; i--)
	{
		if(form.entity[i].checked)
			{
			selected = i; 
			i = -1;
			}
	}	
	if(selected < 0) {
		missinginfo += "\n     -  Type of Entity";
		if(theItem == ""){theItem = eval("form.entity[0]")}
	}
	
	if(form.yearEstablished.value == "")
	{
		missinginfo += "\n     -  Year Established";
		if(theItem == ""){theItem = eval("form.yearEstablished")}
	}
	
	if(form.phonenumber.value == "") {
			missinginfo += "\n     -  Phone Number";
			if(theItem == ""){theItem = eval("form.phonenumber")}
	}
	else if(!checkPhone(form.phonenumber.value))
	{
			missinginfo += "\n     -  Phone Number must be valid";
			if(theItem == ""){theItem = eval("form.phonenumber")}			
	}
	
	
	if(form.companyaddress.value == "")
	{
		missinginfo += "\n     -  Company Address";
		if(theItem == ""){theItem = eval("form.companyaddress")}
	}
	
	if(form.companycity.value == "")
	{
		missinginfo += "\n     -  Company City";
		if(theItem == ""){theItem = eval("form.companycity")}
	}

	
	if(form.companystate.value == "")
	{
		missinginfo += "\n     -  Company State";
		if(theItem == ""){theItem = eval("form.companystate")}
	}
	
	if(form.companyzip.value == "")
	{
		missinginfo += "\n     -  Company Zip";
		if(theItem == ""){theItem = eval("form.companyzip")}
	}
	

	
	
	
	
	var i;
	var selected = -1;
	
	for(i = form.hearaboutus.length - 1; i >= 0 ; i--)
	{
		if(form.hearaboutus[i].checked)
			{
			selected = i; 
			i = -1;
			}
	}	
	if(selected < 0) {
		missinginfo += "\n     -  How did you hear about us?";
		if(theItem == ""){theItem = eval("form.hearaboutus[0]")}
	}
	var applicationSelected = form.application.value;
	if(applicationSelected == "")
	{
		missinginfo += "\n     -  Which application do you need to fill out?"; 	
		if(theItem == ""){theItem = eval("form.application")}
		
	}
	else if(applicationSelected == 1 || applicationSelected == 2)
	{
		
		//Event Planner or Wedding Planner application chosen
	
		/*APPLICATION SPECIFIC CHECKS*/
		/*
		if(form.annualgrossrevenue_events.value == "")
		{
			missinginfo += "\n     -  Your Annual Gross Revenues from Planning Events";
			if(theItem == ""){theItem = eval("form.annualgrossrevenue_events")}
			
		}
		*/
		if(form.number_events.value == "")
		{
			missinginfo += "\n     -  Total number of events per year";
			if(theItem == ""){theItem = eval("form.number_events")}
			
		}
		
		
		if(checkRadio(form.occupation_events) == "")
		{
			missinginfo += "\n     -  Is this a Full or Part time occupation?";
			if(theItem == ""){theItem = eval("form.occupation_events[0]")}
			
		}
		
		var r_c = checkRadio(form.risk_contract) ;
		if(!r_c)
		{	
			missinginfo += "\n     -  Contracts - Do you have a contract with all of your clients? ";
			if(theItem == ""){theItem = eval("form.risk_contract[0]")}
		}
		else if(r_c == 'Yes' && form.risk_contractattach.value == "")
		{
			//check for attachment
				missinginfo += "\n     -  Contracts - Submit a copy of the contract.";
				if(theItem == ""){theItem = eval("form.risk_contractattach")}
		}
		
		var subc = checkRadio(form.risk_subcontract);
		if(!subc)
		{
			missinginfo += "\n     -  Subcontractors - Do you use subcontractors on any events you plan? ";
			if(theItem == ""){theItem = eval("form.risk_subcontract[0]")}
			
		}
		else if(subc == 'Yes')
		{
			if(!checkRadio(form.risk_listed))
			{
				missinginfo += "\n     -  Do you require that you/the business be listed as an additional insured on their insurance?";
				if(theItem == ""){theItem = eval("form.risk_listed[0]")}	
			}
		
		
			if(form.risk_limitsofliability.value == "")
			{
				missinginfo += "\n     -  What limits of liability do you require your subcontractor to carry?";
				if(theItem == ""){theItem = eval("form.risk_limitsofliability")}
				
			}
			
			var r_p = checkRadio(form.risk_proof);
			if(!r_p)
			{
				missinginfo += "\n     -  Do you obtain a certificate or proof of insurance from all your subcontractors?";
				if(theItem == ""){theItem = eval("form.risk_proof[0]")}
				
			}
			else if(r_p == 'No' && form.risk_proofexplain.value == '')
			{
				//check if provided no answer
				missinginfo += "\n     -  Explain no certificate or proof of insurance from all your subcontractors.";
				if(theItem == ""){theItem = eval("form.risk_proofexplain")}
				
			}
			
		}
		
		
		
		
		var isYes = false;
		var risk = checkRadio(form.risk_1);
		if( risk == "")
		{
			missinginfo += "\n     -  Do you have any other insurance? ";
			if(theItem == ""){theItem = eval("form.risk_1[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_2)
		if( risk == "" && form.companystate.value != "MO")
		{
			missinginfo += "\n     -  Any insurance declined, cancelled or non-renewed in the past 3 years (N/A in MO) ";
			if(theItem == ""){theItem = eval("form.risk_2[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_3);
		if(risk == "")
		{
			missinginfo += "\n     -   Any operations sold, acquired or discontinued in the last 5 years? ";
			if(theItem == ""){theItem = eval("form.risk_3[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_4);
		if(risk == "")
		{
			missinginfo += "\n     -  Have you been or are you active in any joint ventures or other corporations? ";
			if(theItem == ""){theItem = eval("form.risk_4[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_5);
		if(risk == "")
		{
			missinginfo += "\n     -  Any past losses or claims relating to sexual abuse/molestation allegations?  ";
			if(theItem == ""){theItem = eval("form.risk_5[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_6);
		if(risk == "")
		{
			missinginfo += "\n     -  Any past losses or claims relating to discrimination or negligent hiring allegations? ";
			if(theItem == ""){theItem = eval("form.risk_6[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_7);
		if(risk == "")
		{
			missinginfo += "\n     -  Do you have any inflatable games, other games, rides or concessions? ";
			if(theItem == ""){theItem = eval("form.risk_7[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_8);
		if(risk == "")
		{
			missinginfo += "\n     -  Do you have a formal safety program?  ";
			if(theItem == ""){theItem = eval("form.risk_8[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_9);
		if(risk == "")
		{
			missinginfo += "\n     -  Any animal related exposures? ";
			if(theItem == ""){theItem = eval("form.risk_9[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_10);
		if(risk == "")
		{
			missinginfo += "\n     -  Do any of your events include adult entertainment or adult themes?  ";
			if(theItem == ""){theItem = eval("form.risk_10[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_11);
		if(risk == "")
		{
			missinginfo += "\n     -  Do any of your events provide any gambling entertainment?  ";
			if(theItem == ""){theItem = eval("form.risk_11[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_12);
		if(risk == "")
		{
			missinginfo += "\n     -  Do you organize any sporting events?  ";
			if(theItem == ""){theItem = eval("form.risk_12[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_13);
		if(risk == "")
		{
			missinginfo += "\n     -  Do you use any fireworks or pyrotechnics in your events?  ";
			if(theItem == ""){theItem = eval("form.risk_13[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_14);
		if(risk == "")
		{
			missinginfo += "\n     -  Do you organize any stunts or other special effects?  ";
			if(theItem == ""){theItem = eval("form.risk_14[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_15);
		if(risk == "")
		{
			missinginfo += "\n     -  Any crimes, attempted or successful, on your premises in the last 5 years?  ";
			if(theItem == ""){theItem = eval("form.risk_15[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		risk = checkRadio(form.risk_16);
		if(risk == "")
		{
			missinginfo += "\n     - Any exposure to radioactive or nuclear materials?   ";
			if(theItem == ""){theItem = eval("form.risk_16[0]")}
			
		}
		else if(risk == 'Yes')
		{
			isYes = true;
		}
		
		if(isYes == true && form.describe_risk.value == "")
		{
			missinginfo += "\n     - Explain risk assessment 'Yes' answers.   ";
			if(theItem == ""){theItem = eval("form.describe_risk")}
				
		}
		
		
		/*END APPLICATION SPECIFIC CHECKS*/

		
		
	}

	
	
	
	if(form.signaturename.value == "")
	{
		missinginfo += "\n     -  Signature";
		if(theItem == ""){theItem = eval("form.signaturename")}
	}

	
	if (missinginfo != "") 
	{
		missinginfo ="_____________________________\n" +
		"The following are required fields:\n" +
		missinginfo + "\n_____________________________" +
		"\nPlease re-enter and submit again!";
		alert(missinginfo);
		theItem.focus()
		return false;
	}
	else
	{
		form.submit()
		return true;
	}
}

function checkPhone(str) 
{
	var phone2 = /[^0-9\-\(\)\sx]/; 
	if (str.match(phone2)) {
   		return false;
 	} else {
 		return true;
 	}
}

function checkRadio(radio) {
    var sel = -1;
    for (var i = radio.length-1; i > -1; i--) 
	{
        if (radio[i].checked) 
			{
				sel = i; 
				i = -1;
			}
    }
    if (sel > -1) 
		return radio[sel].value;
    else 
		return '';
}
