function FindValuesInObjectMap(objNeedle,objHaystack) {
	//objNeedle		= an object with properties and values we're trying to find a match for
	//objHaystack	= an object whose props' values are objs with props that have the same names as objNeedle's
	//Function returns the first property name in objHaystack that matches
	var boFlag = false; // Flag that we'll reset when we find a match
	for (var item in objHaystack) {
		for (prop in objNeedle) {
			if (objNeedle[prop] == objHaystack[item][prop]) {
				boFlag = true;
			} else {
				boFlag = false;
				break;
			}
		}
		// If we finish looping through an item and the flag remains true, we have our match!
		if (boFlag) {
			return item;
		}
	}
	// If we didn't find the match ...
	return "";
}

function CombineNewsFilters(objMap) {
	// This function needs arguments beyond objMap; 
	// 		these are any number of strings that are the IDs of select elements
	//		whose values we need to check to set the newsConfigId we need to search
	var objNdmFinder = new Object();
	// Loop through the function's arguments
	for (var i=1; i<arguments.length; i++) {
		var fieldId = arguments[i];
		var field = document.getElementById(fieldId);
		// Error handling, making sure element with that ID exists and is a select element
		if (field != null && field.tagName == "SELECT") {
			// Add the select Element ID as the name of a property of the objNdmFinder
			//		and the value of the selected option as the property's value
			objNdmFinder[fieldId] = field.options[field.selectedIndex].value;
		}
	}
	// Now find the match for objNdmFinder in the objMap and return its name (the ndmConfigId we want);
	var strMatch = "";
	strMatch = FindValuesInObjectMap(objNdmFinder,objMap);
	// Make sure the returned string begins with "ndmId"
	if (strMatch.indexOf("ndmId") == 0) {
		strMatch = strMatch.substring(5);
	} else {
		strMatch = "";
	}
	return strMatch;
}

// Get returned ndmConfig and set select fields accordingly
function CheckForSelection(strNeedle,objHaystack) {
	if (strNeedle != null && objHaystack != null && objHaystack.tagName == "SELECT") {
		for (var i=0; i<objHaystack.options.length; i++) {
			if (strNeedle == objHaystack.options[i].value) {
				objHaystack.options[i].selected = "selected";
				return;
			}
		}
	}
}

