function getElement(psID) { 
  if(document.all) {return document.all[psID];}
  else{return document.getElementById(psID);}
} 

function setFields() {
  getElement('selActivity').value=getElement('Activity').value;
}

function buildActivity() {
  var objActivityCategory=getElement('ActivityCategory');
  var objActivity=getElement('Activity');
  var objselActivity=getElement('selActivity');
  var arrList=new Array();

  var vActivityValue=objselActivity.value;

  var vActivityFound=false;
  objActivity.options.length=0;
  var j=0;
  if(objActivityCategory.value==0){objActivity.options[j]=new Option('(all activities)', 0);}
  else{objActivity.options[j] = new Option('(all ' + objActivityCategory[objActivityCategory.selectedIndex].innerHTML +  ')', 0);}
  j++;
  for (var i=0; i<arrOptions.length; i++) {
    var opt=arrOptions[i].split(';');
    if(opt[0]==objActivityCategory.value){
      if(vActivityValue+''==opt[1]+''){vActivityFound=true;}
      arrList[j]=opt[1];
      j++;
    }
  }

  //now get the values from the appropriate list
  var k=0;
  for (i=0;i<arrActivity.length;i++) {
    var opt=arrActivity[i].split(';');
    var found=false;
     j=0;
    while (j<arrList.length && found==false) {
      if(arrList[j]==opt[0]){found=true;objActivity.options[k+1]=new Option(opt[1], opt[0]);k++;}
      j++;
    }
  }
  if(vActivityFound){objActivity.value=vActivityValue;}
  else{objActivity.value=0;}
  setFields();
}  
