function createDropDowns() {}  //leave this stub!

function populateDropDown(selectId, parentId, defaultValue, sourceArray)
{
	
	var dropdown = document.getElementById(selectId);
	dropdown.options.length = 0;

    var selectedIndex = -1;
     
    for (var c=0;c<sourceArray.length;c++) 
	{
	    var category = sourceArray[c];
		var name = category.t; //attributes['name'].value;
		var id = category.i; //attributes['id'].value;
	 
		if ((parentId && category.m && (category.m == parentId)) || !parentId)  
        {
           var insertionPoint = dropdown.options.length;
		    dropdown.options[insertionPoint] = new Option(name, id);
		    if (id == defaultValue) {
	            selectedIndex = insertionPoint;
	        }	  
	    }  
	}

    if (selectedIndex > -1) {
        dropdown.selectedIndex = selectedIndex;
    }
    
    if (dropdown.selectedIndex>-1) {        
	    return dropdown.options[dropdown.selectedIndex].value;
	}
	else {    
	    return -1;
	}
}

function populateSubCategory(subId, mainField, subField) 
{
    var currentMainCategory = document.getElementById(mainField).value;
    var currentSubCategory = document.getElementById(subField).value;
	currentSubCategory = populateDropDown(subId, currentMainCategory, currentSubCategory, SubCategories);
	document.getElementById(subField).value = currentSubCategory;
}

function linkCategories(mainId, subId, mainField, subField) 
{
    	var mainDropDown = document.getElementById(mainId);
    	var subDropDown = document.getElementById(subId);
    	var ctlMainField = document.getElementById(mainField); 

	if (mainDropDown && subDropDown && ctlMainField) {   
    		var currentMainCategory = ctlMainField.value;

    		ctlMainField .value = populateDropDown(mainId, null, currentMainCategory, MainCategories);    
    
		populateSubCategory(subId, mainField, subField);  

		mainDropDown.onchange = new Function("{ document.getElementById('" + mainField + "').value = this.value; populateSubCategory('" + subId + "', '" + mainField + "', '" + subField + "'); }");
		subDropDown.onchange = new Function("{ document.getElementById('" + subField + "').value = this.value; }");
	}
}


<!--vicweb01-->