/* called from onChange */
/* default is hide */
/* before change *.oldBS.oldSit.oldWho.oldWhen.oldTP { display: block }
   now that changed to newX, replace .oldX with newX */
/* if newX is anyX then don't replace with anything (since no requirement for X */

//CSSStyleRule.selectorText


function updateResults() {
  //alert("in update");
  if (document.getElementById ) {
    //determine current restraints
    var select = document.getElementsByTagName('select');
    var value;
    var matchAll;
    var numMatches = 0;
  
    //for each <a> inside of results 
    var a = document.getElementById('results').getElementsByTagName("a");
    //alert("before for")
    for (var i=0; i < a.length; i++) {
      matchAll = true; //for each <a>, presume is match to all constraints
      //if for any value of any selector effect is not a match then matchAll = false;
    
      for (var j=0; j < select.length; j++) {
	value = select[j].value;
	if(value.match(/^any/)) { //no constraint
	  value = "";
	}
	//alert(value);
	if(a[i].className.match(value)) {
	  //good so far
	  
	}
	else {
	  matchAll = false;
	}
      }
      if(matchAll) {
	//alert("I think " + a[i] + " (" + a[i].className +") matches all constraints");
	a[i].style.display = 'block';
	numMatches++;
      }
      else {
	//alert("I think " + a[i] + " (" + a[i].className +") DOES NOT match all constraints");
	a[i].style.display = 'none';
      }

        
    } 
  
    //alert("end fors");
    //display number of matches
    var header = document.getElementById('results').getElementsByTagName('h2')[0];
  
    header.firstChild.nodeValue = "the results: (" + numMatches + ")";
  }
}

