//validate form for contactWidget form
function validate(formObj) {
	for(i=0;i<=4;i++){
		formObj.getElementsByTagName("span")[i].style.display = "none";
	}
	for(i=0;i<=5;i++){
		if(formObj.getElementsByTagName("input")[i].value=="" || formObj.getElementsByTagName("input")[i].value == formObj.getElementsByTagName("input")[i].defaultValue && formObj.getElementsByTagName("input")[i].type != "hidden") {
			alert("All form fields are required. Please fill in the marked fields.");
			//formObj.getElementsByTagName("input")[i].style.background ="#E28E07";
			//formObj.getElementsByTagName("input")[i].style.color="#ff0000";
			formObj.getElementsByTagName("input")[i].focus();
			//formObj.getElementsByTagName("input")[i].value = formObj.getElementsByTagName("input")[i].defaultValue;
			formObj.getElementsByTagName("span")[i-1].style.display = "inline";
			return false;
		}
	}
}
/*-----------------------------------------------------------------------------------------------
validate Careers/contact form [combined - if causes issues then break into 2 separate functions]
-------------------------------------------------------------------------------------------------*/

function validate_form() {
	/*null allowed list -> designate fields that are NOT required*/
	var nullAllowList = new Array();
	//nullAllowList[0] = "expertise[]";
	nullAllowList[0] = "expertise_other";
	nullAllowList[1] = "agency_background";
	nullAllowList[2] = "agency_years";
	nullAllowList[3] = "corporate_background";
	nullAllowList[4] = "corporate_years";
	nullAllowList[5] = "nonprofit_background";
	nullAllowList[6] = "nonprofit_years";
	nullAllowList[7] = "other_background";
	nullAllowList[8] = "other_years";
	nullAllowList[9] = "background_other_explanation";
	nullAllowList[10] = "startdate";
	//nullAllowList[11] = "howfound";
	nullAllowList[11] = "howfound_referral_text";
	nullAllowList[12] = "howfound_other_text";
	nullAllowList[13] = "resume";
	//nullAllowList[15] = "current_title";
	//nullAllowList[16] = "current_employer";
	//nullAllowList[17] = "interests[]";
	var nullAllow = false;
	
	for(i=1;i<=document.forms[1].elements.length;i++){
		/*if i am..radio buttons on contact form*/
		if(window.document.forms[1].elements[i].name=="gotcha"){
			if(!document.forms[1].gotcha[0].checked) {
				nullAllow = false;
				document.forms[1].elements[i].style.background="#98002e";
				document.forms[1].elements[i].focus();
				//document.forms[1].elements[i].parentNode.childNodes[1].style.background="#999999";
				alert("Information is missing and marked in red. If this information is not applicable simply mark with an '-'");
				return false;
				break;
			}
		}
		/*end specific check for contact form radio*/
		
		if(document.forms[1].elements[i].value==""){
			for(x=0;x<= nullAllowList.length;x++){
				if(document.forms[1].elements[i].name == nullAllowList[x]){
					nullAllow = true;
					//alert("this field is allowed to be null");
					break;
				}else{
					nullAllow = false;
					//alert("this field is NOT allowed to be null");
				}
			}
			if(nullAllow == false){
				document.forms[1].elements[i].style.background="#98002e";
				document.forms[1].elements[i].focus();
				//document.forms[1].elements[i].parentNode.childNodes[1].style.background="#999999";
				alert("Information is missing and marked in red. If this information is not applicable simply mark with an '-'");
				return false;	
			}
		}
	}
}