<!--

var originalSelectionList = new Array();
var optionsChange = false;
var copyOriginalValues = true;

function copySlaveSelect(slaveSelect){
    var theValue = "";
    var theText = "";
    //alert('initial loaded array = ' + slaveSelect);
    for(var i = 0; i < slaveSelect.length ; i++){
        theValue = slaveSelect.options[i].value;
        theText = slaveSelect.options[i].text;
        originalSelectionList[i] = new Option( theText , theValue );
    } 

    //alert( "originalSelectionList size = " + originalSelectionList.length );
    copyOriginalValues = false;
}


function updateDynamicSelectionList( aMasterSelect, aSlaveSelect, aMasterArray){
    if (copyOriginalValues) copySlaveSelect(aSlaveSelect);
    if (aMasterSelect.options.length == 0)
        return;

    var selectionArray = 
        aMasterArray[aMasterSelect.options[aMasterSelect.selectedIndex].value];

    //reset the dropdown to all the original values
    var theValue = "";
    var theText = "";
    //alert('copying values...');
    for(var i = 0; i < originalSelectionList.length; i++){
        theValue = originalSelectionList[i].value;
        theText = originalSelectionList[i].text;
        //alert(theValue + " - " + theText);
        aSlaveSelect.options[i] = new Option( theText , theValue );
    }

    if( selectionArray == null){
        return null;
    }
    //alert( ' selectionArray  size = ' + selectionArray.length );

    if(aMasterSelect.options[aMasterSelect.selectedIndex].value==0) {
    	return true;
    }
    else{
	    var found = false;
	    //alert('size = ' + aSlaveSelect.options.length);
	    for(var i = aSlaveSelect.options.length - 1; i >= 0 ; i--){
	        found = false;
	        for(var j=0; j < selectionArray.length; j++){
	            //alert('aSlaveSelect value = ' + aSlaveSelect.options[i].value);
	            //alert('selectionArray[j] value = ' +selectionArray[j]);
	            if( aSlaveSelect.options[i].value == selectionArray[j]){
	                found = true;
	                break;
	            }
	        }
	        if( !found ){
	            optionsChange = true;
	            aSlaveSelect.options[i] = null;
	        }
	    }
	}
    if(aSlaveSelect.options.length>0){
        aSlaveSelect.options[0].selectedIndex=0;
    }
    return true;

}

//-->
