﻿var ASPID_PREPEND = 'ctl00_cphBody_';
var ASPNAME_PREPEND = 'ctl00$cphBody$';

function ShowDecision(thisChoice) {
    var listResults = document.getElementById('ulProductResults');
    listResults.style.display = 'none';
    
    var decisionID = parseInt(thisChoice.getAttribute('decisionid'));
    //alert(decisionID);
    var divDecision = document.getElementById(ASPID_PREPEND + decisionID);
    //alert(divDecision);
    if (divDecision != null) {
        //alert(divDecision);
        if (thisChoice.checked) {
            divDecision.style.display = 'block';
        }

        //hide other divs of related choices
        //alert('thisChoice.name: ' + thisChoice.name);
        var choices = document.getElementsByName(thisChoice.name);
        //alert(choices.length);
        for (var i = 0; i < choices.length; i++) {
            if (choices[i] != thisChoice) {
                //alert(choices[i]);
                HideDecision(choices[i]);
                
            }
        }
        
        

    } else {    //leaf node
        //alert('');
    }
}
function HideDecision(thisChoice) {
    var decisionID = parseInt(thisChoice.getAttribute('decisionid'));
    //alert(decisionID);
    var divDecision = document.getElementById(ASPID_PREPEND + decisionID);
    if (divDecision != null) {
        var childDivs = divDecision.getElementsByTagName('div');
        divDecision.style.display = 'none';
        //hide children
        //alert(childDivs.length);
        for (var i = 0; i < childDivs.length; i++) {
            childDivs[i].style.display = 'none';
        }
    }
}

function ShowResult(thisChoice) {
    //capture final leaf value
    var choiceValue = thisChoice.getAttribute('choicevalue');
    //alert(choiceValue);
    GetProduct(choiceValue);
    var listResults = document.getElementById('ulProductResults');
    listResults.style.display = 'block';
}