// Requires Wayne's addRemoveClassName from dom/dom_functions.js
// Also requires (var) mapping to be defined
// and element_specific/multiselect.js
function checkValue  (node)
{
    if ( node.multiple ) {

        var multi = true;

        var selected = getMultiSelectedValues(node);
    }

    // find the first input node in this answer section (has the question number)
    var input = node.parentNode.childNodes[0];
    if (input.nodeType != 1)
        input = node.parentNode.childNodes[1];

    for (var i=0; i<mapping.length; i++)
    {
        if (typeof(mapping[i]) != 'undefined' && mapping[i].parentId == input.value)
        {
            var subDivId = "subquestion" + mapping[i].childId;
            var subDiv = document.getElementById (subDivId);

            if ( multi ) {

                if (in_array(mapping[i].answerId, selected, false) || mapping[i].answerId == 0) 
                     addRemoveClassName(subDiv, 'hidden', 'remove' );
                else addRemoveClassName(subDiv, 'hidden', 'add'    );

            } else {

                if (mapping[i].answerId == node.value || mapping[i].answerId == 0) 
                     addRemoveClassName(subDiv, 'hidden', 'remove' );
                else addRemoveClassName(subDiv, 'hidden', 'add'    );
            }
        }
    }
}


function showFullAnswer (hiddenDivId)
{
    //if ( typeof(elem_yui_panel) == 'undefined' )
        //YUIInitPanel();

    //document.getElementById('yui_panel_content_container').innerHTML = document.getElementById(hiddenDivId).innerHTML;
    //showYUIPanel();

    showInYUIPanel(document.getElementById(hiddenDivId).innerHTML);
}


function showInYUIPanel(HTML, title, preShowEval)
{
    if ( typeof(elem_yui_panel) == 'undefined' )
        YUIInitPanel();


    if ( typeof(title) == 'string' )
        document.getElementById('yui_panel_header').innerHTML = title;

    if ( typeof(HTML) == 'string' )
        document.getElementById('yui_panel_content_container').innerHTML = HTML;


    if ( typeof(preShowEval) == 'string' ){

        eval(preShowEval);
    }
    else if ( typeof(preShowEval) == 'object' && preShowEval.length ) {

        for (var i=0; i<preShowEval.length; i++) {

            //alert(preShowEval[i]);
            eval(preShowEval[i]);
        }
    }

    showYUIPanel();
}
