//selectObj is a form <select> to be populated with values and ids from allOptions
//allOptions is an array with each row being an Array(Array of filters to return true on, id for option, value for option)
//filterID is the filter to apply to allOptions before populating selectObj.

function filterList(selectObj,allOptions,filterID,selectedID) {
    var index=0;
    // Clear the select list so nothing is displayed
    selectObj.options.length = 0;
	selectObj.options[index++] = new Option("All", "0");
    for (var loop=0; loop < allOptions.length; loop++) {

		// This is the option that we're currently testing
		var optionInfo = allOptions[loop];
//		alert(optionInfo);

		var id = filterID;
		var inFilter = false;
		//check to see if the option is in the filterList
		for (var i=0; i < optionInfo[0].length; i++ ) {
			if (optionInfo[0][i] == filterID) {
				inFilter = true;
			}
		}
		// Check if we have a match
		if (filterID == 0 || inFilter ) {
		
		// We have a match, so add this option to the select list
		// and increment the index
		var sel = false;
		if  (selectedID == optionInfo[1]) { sel = true; }
		
		selectObj.options[index++] =  new Option(optionInfo[2], optionInfo[1], sel);
		}
    }
}

function filterList2(selectObj,allOptions,filterID,selectedID) {
    var index=0;
    // Clear the select list so nothing is displayed
    selectObj.options.length = 0;
	if (filterID == 0) { selectObj.options[index] = new Option("Choose a Software option.", "0"); selectObj.options[index++].setAttribute('LinkURL','/index.cfm/LearningCenter/Software_Lessons');  }
	if (filterID != 0) { selectObj.options[index] = new Option("All Lessons","0"); selectObj.options[index++].setAttribute('LinkURL',''); selectObj.selectedIndex = index-1; }
    for (var loop=0; loop < allOptions.length; loop++) {

		// This is the option that we're currently testing
		var optionInfo = allOptions[loop];
//		alert(optionInfo);

		var id = filterID;
		var inFilter = false;
		//check to see if the option is in the filterList
		for (var i=0; i < optionInfo[0].length; i++ ) {
			if (optionInfo[0][i] == filterID) {
				inFilter = true;
			}
		}
		// Check if we have a match
		if (inFilter ) {
		
		// We have a match, so add this option to the select list
		// and increment the index
		var sel = false;
		if  (selectedID == optionInfo[1]) { sel = true; }
		
		selectObj.options[index] =  new Option(optionInfo[2], optionInfo[1], sel);
		selectObj.options[index++].setAttribute('LinkURL',optionInfo[3]);
		if (sel) {	selectObj.selectedIndex = index-1; }
		}
    }
}

function filterList3(selectObj,allOptions,filterID,selectedID) {
    var index=0;
    // Clear the select list so nothing is displayed
    selectObj.options.length = 0;
	if (filterID == 0) { selectObj.options[index] = new Option("<- Choose a Category.", "0"); selectObj.options[index++].setAttribute('LinkURL','/index.cfm/LearningCenter/Techniques');  }
	if (filterID != 0) { selectObj.options[index] = new Option("All Techniques","0"); selectObj.options[index++].setAttribute('LinkURL',''); selectObj.selectedIndex = index-1; }
    for (var loop=0; loop < allOptions.length; loop++) {

		// This is the option that we're currently testing
		var optionInfo = allOptions[loop];
//		alert(optionInfo);

		var id = filterID;
		var inFilter = false;
		//check to see if the option is in the filterList
		for (var i=0; i < optionInfo[0].length; i++ ) {
			if (optionInfo[0][i] == filterID) {
				inFilter = true;
			}
		}
		// Check if we have a match
		if (inFilter ) {
		
		// We have a match, so add this option to the select list
		// and increment the index
		var sel = false;
		if  (selectedID == optionInfo[1]) { sel = true; }
		
		selectObj.options[index] =  new Option(optionInfo[2], optionInfo[1], sel);
		selectObj.options[index++].setAttribute('LinkURL',optionInfo[3]);
		if (sel) {	selectObj.selectedIndex = index-1; }
		}
    }
}