<!-- hide from old browsers
//alert('custom_validations up');

/* CUSTOM VALIDATION SETUP */
/*if (value instanceof Array) {
alert('value is Array!');
} else {
alert('Not an array');
}*/
var uniqueList="";

function customValidations(formName){
	//alert("in customValidations, formName="+formName);
	//run the custom validation scripts here
	formobj=document.forms[formName];
	
	switch(formName){
		case 'tableForm':
			checkList=Array(new Array("OSfind",'how you found out about OH, SNAP!'));
			for(i=0;i<checkList.length;i++){
				if(!checkRadioAndOther(formobj,checkList[i][0],checkList[i][1])){
					//alert('return false');
					return false;
				}
			}
			/*
			checkList=Array("OSfind");
			uniqueList="";
			for(i=0;i<checkList.length;i++){
				formComplete=checkSelectAndOther(formobj,checkList[i])
				if(formComplete==false){
					return false;
				}
			}*/
			/*formComplete=checkChildren(formobj)
			if(formComplete==false){
				return false;
			}
			formComplete=checkBoxGroup(formobj,checkList)
			if(formComplete==false){
				return false;
			}*/
			/*formComplete=checkExpectations(formobj)
			if(formComplete==false){
				return false;
			}
			formComplete=checkSelect(formobj,'whenUsed')
			if(formComplete==false){
				return false;
			}
			checkList=Array("served_family","served_guests");
			formComplete=checkBoxGroup(formobj,checkList)
			if(formComplete==false){
				return false;
			}
			formComplete=checkSelect(formobj,'buyAgain')
			if(formComplete==false){
				return false;
			}
			formComplete=checkAppealRating(formobj)
			if(formComplete==false){
				return false;
			}*/
		break;
		
		case 'iddbaReg':
			if(checkSelect(formobj,'entree','an Entree')==false){return false;}
			if(checkSelectAndOther(formobj,'hotel','a Hotel')==false){return false;}
		break;
	}
	//if we've made it this far then return true - show the alert div if available
	$alertDiv=findObjectPath("loadingAlert");
	if($alertDiv!=null){$alertDiv.style.display='block';}
	return true;
}

/* CUSTOM VALIDATION FUNCTIONS */

function checkSelect(formobj,selectList,title){
	//alert("in checkSelect");
	//make sure the user has selected a value from the select list.
	if(formobj[selectList].options[formobj[selectList].selectedIndex].value=="none"){
		if(title!=null){alert("Please select "+title);}else{alert("Please answer all of the questions");}
		formobj[selectList].focus();
		return false;
	}
	return true;
}

function checkRadioAndOther(formobj,radioID,title){
	//alert("in checkRadioAndOther");
	radioSet=formobj[radioID]; curValue="";
	//alert(radioSet.length);
	for(inc=0;inc<radioSet.length;inc++){
		if(radioSet[inc].checked){
			curValue=radioSet[inc].value;
			break;
		}
	}
	//make sure the user has selected a' value from the select list.
	if(curValue==""){
		if(title!=null){alert("Please select "+title);}else{alert("Please select an option");}
		//formobj[objID].focus();
		return false;
	}else if(curValue=="Other" && formobj[radioID+"Other"].value==""){
		alert("Please enter a description for your 'Other' selection");
		formobj[radioID+"Other"].focus();
		return false;
	}
	return true;
}

function checkSelectAndOther(formobj,selectList,title){
	//alert("in checkSelectAndOther");
	curValue=formobj[selectList].options[formobj[selectList].selectedIndex].value;
	//make sure the user has selected a value from the select list.
	if(curValue=="none"){
		if(title!=null){alert("Please select "+title);}else{alert("Please answer all of the questions");}
		formobj[selectList].focus();
		return false;
	}else if(uniqueList.indexOf(curValue)!=-1 && curValue!="Other"){
		alert("You cannot rank an item more than once");
		formobj[selectList].focus();
		return false;
	}else if(curValue=="Other" && formobj[selectList+"Other"].value==""){
		alert("Please enter a description for your 'Other' selection");
		formobj[selectList+"Other"].focus();
		return false;
	}
	uniqueList+="_"+curValue;
	return true;
}

function checkBoxGroup(formObj,ckBoxes){
	//alert("formobj="+formobj);
	dataOK=0;
	//make sure at least one of the check boxes in this checkBoxGroup has been checked
	for(i=0;i<ckBoxes.length;i++){
		if(formobj[ckBoxes[i]].checked){
			dataOK=1;
			break;
		}
	}
	if(dataOK==0){
		alert("Please answer all of the questions");
		formobj[ckBoxes[0]].focus();
		return false;
	}
	return true;
}

function checkChildren(formobj){
	//alert("in checkChildren");
	//make sure the user has entered SOMETHING for children in household
	checkList=Array("age0_2","age3_5","age6_10","age11_15","age16_17");
	//alert("formobj="+formobj);
	dataOK=0;
	//first see if any of the number fields has been filled
	for(i=0;i<checkList.length;i++){
		//alert("formobj[checkList[i]].value= "+formobj[checkList[i]].value);
		if(formobj[checkList[i]].value!=""){
			//alert("formobj[checkList[i]].value!='' ");
			dataOK=1;
			break;
		}
	}
	//alert("checked the children fields, dataOK result="+dataOK);
	//now, if there was no data entered in the fields just checked, see if the 'no children' checkbox was checked
	if(dataOK==0 && formobj["noChildren"].checked){
		dataOK=1;
	}
	//alert("checked the no children checkbox, dataOK result="+dataOK);
	//now, only proceed if dataOK=1
	if(dataOK==0){
		alert("Please answer all of the questions");
		formobj["age0_2"].focus();
		return false;
	}else{
		return true;
	}			
}

function checkExpectations(formobj){
	//alert("in checkExpectations");
	//make sure the user has selected a ranking for the various VIP package items, and if ranking was dissatisfied, make sure text area has info in it.
	checkList=Array("expectations_entire","expectations_turkey","expectations_stuffing","expectations_sauce");
	titleList=Array("Entire Entertaining Pack","VIP Turkey","Stuffing or Rice","Glaze or Gravy");
	//alert("formobj="+formobj);
	for(i=0;i<checkList.length;i++){
		//alert("checkList[i]= "+checkList[i]);
		selectValue=formobj[checkList[i]].options[formobj[checkList[i]].selectedIndex].value;
		if(selectValue=="none"){
			alert("Please select your satisfaction with the "+titleList[i]);
			formobj[checkList[i]].focus();
			return false;
			//radioSet=formobj[checkList[i]];
			//alert(formobj[checkList[i]])
			//alert("radioSet.length= "+radioSet.length)
		}else if((selectValue=="Not Very Satsfied"||selectValue=="Not Satisfied At All")&&formobj[checkList[i]+"_text"].value==""){
			alert("Please tell us why you were not satisfied with the "+titleList[i]);
			formobj[checkList[i]+"_text"].focus();
			return false;
		}
	}
	return true;
}

/*function checkAppealRating(formobj){
	//alert("in checkAppealRating");
	//make sure the user has ranked his or her top three favorite turkey items
	rankCount=0;
	checkList=Array("appealRank_traditional","appealRank_mole","appealRank_cranberry","appealRank_potatoes","appealRank_apricot");
	//alert("formobj="+formobj);
	for(i=0;i<checkList.length;i++){
		if(formobj[checkList[i]].checked){
			//include this ranking in the rankArray
			rankCount++;
		}
	}
	//now make sure there are ONLY three rankings
	if(rankCount<3){
		alert("Please check your top three product varieties");
		formobj[checkList[0]].focus();
		return false;
	}else if(rankCount>3){
		alert("Please check only your top three product varieties");
		formobj[checkList[0]].focus();
		return false;
	}else
	return true;
}*/
//-->