var HF_ACTION = 'hfAction';

function trim(s) {
    var l=0;
    var r=s.length -1;
    while(l < s.length && s.charAt(l) == ' ') {
                l++;
        }
    while(r > l && s.charAt(r) == ' ') {
                r-=1;
        }
    return s.substring(l, r+1);
}

function enableGroup(caller,destination_group,enable){
    if(caller != null && destination_group != null && caller.checked){
        var elements = document.getElementsByName(destination_group);
        for(var i=0;i<elements.length;i++){
            elements[i].disabled = !enable;
            elements[i].focus();
        }
    }
}

function updateForm(form){
    form.submit();
}

function sendForm(form,action){
    var hfAction = document.getElementById(HF_ACTION);
    if(hfAction != null && form != null){
        hfAction.value = action;
        form.submit();
    }
}
