function expand(dog) {
    try {
        callbackFunc = function() { return processOffspring(dog); };
        loadXMLDoc('/scripts/getOffspring.php?dog=' + dog, callbackFunc);
    }
    catch(e) {
        var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
        alert("Unable to get XML data:\n" + msg);
        return;
    }

    element = document.getElementById('expandList_' + dog);
    element.className = 'less';
    element.onclick = null;
}

// handle onreadystatechange event of req object
function processOffspring(dog) {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
          ul = document.createElement("ul");
          ul.innerHTML = buildContent( );
          document.getElementById('expandList_' + dog).appendChild(ul);
          ul = null;
          dog = null;
         } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
         }
    }
}




// fill Topics select list with items from
// the current XML document
function buildContent( ) {
    var html = '';

    var rows = req.responseXML.getElementsByTagName("row");

    // loop through <row> elements, and add each dog to descendents list
    for (var i = 0; i < rows.length; i++) {
        dogID = getElementTextNS("", "dog_id", rows[i], 0);
        regName = getElementTextNS("", "reg_name", rows[i], 0);
        offspring = getElementTextNS("", "count", rows[i], 0);

        if (offspring > 0) {
          html += '<li id="expandList_'+dogID+'" onclick="expand('+dogID+')" class="more">';
        } else {
          html += '<li class="less">';
        }
        html += '<a href="/registry/' + dogID + '/dog.html">' + regName + '</a>';
        if (offspring > 0) {
            html += '(' + offspring + ')';
        }
        html += '</li>';
        //<br/><div style="display: none;" id="dog_' + dogID + '">&#160;</div>';
    }
    return html;
}

