    //filter a dropdown based on a matching screen
    function filterDropdown(txtID, tempID, tarID){
        
        //get references to items 
        var textbox = document.getElementById(txtID);
        var templater = document.getElementById(tempID);
        var target = document.getElementById(tarID);
        
        // clear out target dropdown 
        target.options.length = 0;
        
        // move any item in the template dropdown that matches the 
        // the value in the textbox to the target dropdown 
        for(i=0; i<templater.length; i++){
            
           if((templater.options[i].text.toLowerCase().indexOf(textbox.value.toLowerCase()) > -1) || (textbox.value.toLowerCase() == '')){
                var x = document.createElement('option');
                x.text = templater.options[i].text;
                x.value = templater.options[i].value;
                target.add(x);
            }
        }
        
        // we didn't find anything matching the search string
        // so put in a notification of no items 
        if(target.length < 1){
            
            var g = document.createElement('option');
            g.text = "No Items Found";
            g.value = "";
            target.add(g);
        }
      
        
        // make sure the target dropdown has the same item selected as the template
        target.value = templater.options[templater.selectedIndex].value;
    }
    
    //prepare dropdown for filtering 
    function prepareDropdown(tempID, tarID)
    {   
        //get references to the required form items             
        var target = document.getElementById(tarID);                     
        var templater = document.getElementById(tempID);
        
        //remove all items from the templater
        if(templater.length < 1){         
                    
            //copy all items from target into template 
            for(i=0; i<target.length; i++){
                          
                var x = document.createElement('option');
                x.text = target.options[i].text;
                x.value = target.options[i].value;
                templater.add(x);
              
            }
         }
    }
    //used to ensure that any radio button appearing in a repeater / datagrid
    //is mutually exclusive with other radio buttons in the same group.
    //by default, ASP mangles the GroupName property whenever the radio button appears inside 
    //a databound control. this simple js ensures the radio button name is preserved. 
    function setUniqueRadioButton(nameregex, current) {
        re = new RegExp(nameregex);
        for (i = 0; i < document.forms[0].elements.length; i++) {
            elm = document.forms[0].elements[i]
            if (elm.type == 'radio') {
                if (re.test(elm.name)) {
                    elm.checked = false;
                }
            }
        }
        current.checked = true;
    }
    // update the value of a textbox with an amount based on a percentage of another amount. 
    // apply any rounding the calculated value as well 
    function updateAmountTextbox(txtID, percentage, amount, roundTo) {

        //get references to items 
        var targetTextbox = document.getElementById(txtID);

        //determine what the value of the textbox should be
        var newAmount = (percentage / 100) * amount;

        //apply rounding to the required number of decimal places
        newAmount = Math.round(newAmount * Math.pow(10, roundTo)) / Math.pow(10, roundTo);
        
        //update value of target textbox
        targetTextbox.value = newAmount;
        
    }
    // update the value of a textbox with a percentage based on the parsed amount and totalAmount
    // apply any rounding the calculated value as well 
    function updatePercentageTextbox(txtID, amount, totalAmount, roundTo) {

        //get references to items 
        var targetTextbox = document.getElementById(txtID);

        //determine what the value of the textbox should be
        var newAmount = (amount / totalAmount) * 100;

        //apply rounding to the required number of decimal places
        newAmount = Math.round(newAmount * Math.pow(10, roundTo)) / Math.pow(10, roundTo);
        
        //update value of target textbox
        targetTextbox.value = newAmount;
        
    }