function isUndefined(v) {
    var undef;
    return v===undef;
}

function rawPopup(url, target, features) {
    if (isUndefined(target)) {
        target = '_blank';
    }

    var newWindow = window.open(url, target, features);
    newWindow.focus();
    return newWindow;
}

function linkPopup(src, features) {
    return rawPopup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}
/**
 * Alle Input-Element vom Typ Checkbox innerhalb
 * des identifizierten Containers mit dem ?bergebenen
 * Element (einer Checkbox) synchronisieren.
 */
function checkAllCheckboxes(containerId, syncElement)
{
    //alert("call: "+containerId);
    var containerElement = document.getElementById(containerId);
    if (containerElement == null) return;
    if (!containerElement.hasChildNodes()) return;

    var allChildren = containerElement.childNodes;
    var i;
    for (i = 0; i < allChildren.length; i++) {
      var currentChild = allChildren[i];
        if (currentChild.nodeType != 1) continue; // Textknoten ignorieren
        
        if (currentChild.type != null &&
            currentChild.type.toLowerCase() == 'checkbox') {
            currentChild.checked = syncElement.checked;
        }
        
        if (currentChild.tagName != null && 
            currentChild.tagName.toLowerCase() == 'div') {
            //alert("descending to div with id: "+allChildren[i].id+", ");
            checkAllCheckboxes(currentChild.id, syncElement);
        }
    }
}
