function hasOptions(obj) {
	if (obj!=null && obj.options!=null) { return true; }
	return false;
	}


/** generic function that sets options of the obj as selected based on the selections array based in **/
function setSelections(obj, selections){
	if( hasOptions(obj)){
		if( selections != null && selections.length > 0){	
			for(var i=0; i < obj.length; i++){
				for(var m = 0; m < selections.length; m++){
					if( m == 0) 
						obj.options[i].selected="";
					if(obj.options[i].value==selections[m]){
						obj.options[i].selected='selected';
					}
				}
			} 
		}
	}

}

   function updateSelectionObject(selectObject, setToArray, selectionsArray ) {
		var j = 0;					     
        var value = null;
        var label = null;

		//iterate array we are setting object to
        for (var i = 0; i < setToArray.length; i++) {
			var select = false;

            label = setToArray[i].Name;
            value = setToArray[i].ID;
	
			if( selectionsArray != null && selectionsArray != "" && selectionsArray.length > 0 ){			
				//iterate through value we want to be shown as selected				
				for(var m = 0; m < selectionsArray.length; m++){
					if(setToArray[i].ID == selectionsArray[m]){
						select = true;
					}
				}
			}
            selectObject[i] = new Option(label, value, false, select);
        }//eof
    }

