﻿function expandcollapse(prefix, id){
    /*prefix = "L" : Used to expand buildings at a location*/
    /*prefix = "B" : Used to expand rooms at a building*/
    /*prefix = "C" : Used to expand subcategories under a category*/
	var text = document.getElementById("anc" + prefix + id).innerHTML;	
	if(text=="(+)"){
		/*Expand the proper span*/
		document.getElementById("span" + prefix + id).style.display="inline";
		/*Set the anchor text*/
		document.getElementById("anc" + prefix + id).innerHTML = "(-)"
	}
	else{
		/*Collapse the proper span*/
		document.getElementById("span" + prefix + id).style.display="none";
		/*Set the anchor text*/
		document.getElementById("anc" + prefix + id).innerHTML = "(+)"
	}
}

function expandselections(){
    var sel = document.getElementById("adxFacilitySelectorSelections");
    
    if(sel != null){ /*There is a hidden control of selections*/
        if(sel.value != ""){ /*The hidden control has selection set*/
            var ids = sel.value.split(",");
            
            /*Make sure the proper nodes are expanded based on the selections in the hidden control*/
            for(idx=0;idx<ids.length;idx++)
            {
                var idpts = ids[idx].split("-");
    
                if(idpts[2]!="0"){
                    /*EXPAND THE LOCATION*/
                    document.getElementById("spanL" + idpts[0]+"-0-0").style.display="inline";
                    document.getElementById("ancL" + idpts[0]+"-0-0").innerHTML = "(-)"
                    /*EXPAND THE BUILDING*/
                    document.getElementById("spanB" + idpts[0]+"-"+idpts[1]+"-0").style.display="inline";
                    document.getElementById("ancB" + idpts[0]+"-"+idpts[1]+"-0").innerHTML = "(-)"
                }
                else if(idpts[1]!="0"){
                    /*There is a building selected, expand the location node*/
                    document.getElementById("spanL" + idpts[0]+"-0-0").style.display="inline";
                    document.getElementById("ancL" + idpts[0]+"-0-0").innerHTML = "(-)"
                }
            }
        }
    }
}