﻿function enforceExclusivity(strCurrentId, aryExclusiveIds, strType) {
	//I created this function to enforce mutual exclusivity among specific groups of fields - RD, 2006-10-12
	var blnReturn = true;
	var blnConfirm = true;
	var strFailedAry = new Array();
	var strCaptionAry = new Array();

	for (var intX = 0; intX < aryExclusiveIds.length; intX += 2) {
		var elmTemp = document.getElementById(aryExclusiveIds[intX]);
		if (elmTemp.value != '0' && elmTemp.value != '' && elmTemp.id != strCurrentId) {
			//Add the element's id to the array of elements that are conflicting
			strFailedAry.push(aryExclusiveIds[intX]);
			strCaptionAry.push(aryExclusiveIds[intX + 1]);			
			blnReturn = false;
		}
	}

	if (blnReturn == false) {
		//If there was a conflict...
		blnConfirm = window.confirm('You can not have more than one ' + strType + ' size selected.\nThe following sizes will be reset if you continue:\n' + strCaptionAry.join(', '));
		
		if (blnConfirm == true) {
			for (var intX = 0; intX < strFailedAry.length; intX++) {
				//Reset all the fields that were conflicting
				elmTemp = document.getElementById(strFailedAry[intX]);
				elmTemp.selectedIndex = 0;
			}
		} else {
			//Reset the field that was changed
			document.getElementById(strCurrentId).selectedIndex = 0;
		}
	}
}